├── .gitignore
├── .idea
├── caches
│ └── build_file_checksums.ser
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── DemoGif.gif
├── DemoGifTwo.gif
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── view
│ │ └── calender
│ │ └── horizontal
│ │ └── umar
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── view
│ │ │ └── calender
│ │ │ └── horizontal
│ │ │ └── umar
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── view
│ └── calender
│ └── horizontal
│ └── umar
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── horizontalcalendarview
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── view
│ │ └── calender
│ │ └── horizontal
│ │ └── umar
│ │ └── horizontalcalendarview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── view
│ │ │ └── calender
│ │ │ └── horizontal
│ │ │ └── umar
│ │ │ └── horizontalcalendarview
│ │ │ ├── CalAdapter.java
│ │ │ ├── CallBack.java
│ │ │ ├── DayDateMonthYearModel.java
│ │ │ ├── HorizontalCalendarListener.java
│ │ │ ├── HorizontalCalendarView.java
│ │ │ ├── HorizontalPaginationScroller.java
│ │ │ └── material
│ │ │ └── MaterialCalAdapter.java
│ └── res
│ │ ├── drawable
│ │ ├── background_selected_day.xml
│ │ ├── currect_date_background.xml
│ │ ├── date_picker_border.xml
│ │ ├── ic_appointment_back.xml
│ │ ├── ic_appointment_next.xml
│ │ ├── ic_three_dots.xml
│ │ └── selected_background.xml
│ │ ├── layout
│ │ ├── custom_calender_layout.xml
│ │ ├── custom_day_layout.xml
│ │ └── material_custom_day_layout.xml
│ │ └── values
│ │ ├── color.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── view
│ └── calender
│ └── horizontal
│ └── umar
│ └── horizontalcalendarview
│ └── ExampleUnitTest.java
├── horizontalcalendarviewlibrary
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── view
│ │ └── calender
│ │ └── horizontal
│ │ └── umar
│ │ └── horizontalcalendarlibrary
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── view
│ └── calender
│ └── horizontal
│ └── umar
│ └── horizontalcalendarlibrary
│ └── ExampleUnitTest.java
├── settings.gradle
└── ss
├── DemoGif.gif
├── DemoGifTwo.gif
└── material_ui.png
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/libraries
5 | /.idea/modules.xml
6 | /.idea/workspace.xml
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/DemoGif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/DemoGif.gif
--------------------------------------------------------------------------------
/DemoGifTwo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/DemoGifTwo.gif
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 mybringback22
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Horizontal Calendar View - Android
2 | Horizontal Calender View is android library.
3 |
4 | ## Demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
16 |
17 | ## Using Horizontal Calendar View
18 | ### XML
19 |
20 | Add the followling code to your XML file
21 |
22 | ```xml
23 |
27 |
28 |
29 | ```
30 |
31 | ### Java
32 |
33 | Now you can get the referance of the HorizontalCalendarView in the kotlin
34 |
35 | ```kotlin
36 | val hcv = findViewById(R.id.horizontalcalendarview)
37 | hcv.setContext(this@MainActivity)
38 | ```
39 |
40 | To hide the left right contorls you can use the following method
41 |
42 | ```kotlin
43 | hcv.showControls(false)
44 | ```
45 |
46 | To turn on material style UI (third screenshot)
47 |
48 | ```kotlin
49 | hcv.setMaterialStyle(true)
50 | ```
51 |
52 | To change week days namming from M, T, W, T, F, S, S to Mon, Tue, Wed, Th, Fri, Sat, Sun
53 |
54 | ```kotlin
55 | hcv.setWeekNameMode(CalAdapter.WeekNameMode.MEDIUM)
56 | ```
57 |
58 | To change the color of the left and right control use the following
59 |
60 | ```kotlin
61 | hcv.setControlTint(R.color.colorAccent)
62 | ```
63 |
64 | To change the background color of the Horizontal Calendar View use the following
65 |
66 | ```kotlin
67 | hcv.setBackgroundColor(resources.getColor(R.color.colorPrimary))
68 | ```
69 |
70 | To change the Text color of the Horizontal Calendar View use the following
71 |
72 | ```kotlin
73 | hcv.changeAccent(R.color.white)
74 | ```
75 |
76 | ## Getting Swipe or Touch Feedback
77 | To get the feedback from the touches and swipes of Calender implement ` HorizontalCalendarListener ` activity or fragment
78 | ```kotlin
79 | class MainActivity : AppCompatActivity() , HorizontalCalendarListener {
80 |
81 | }
82 |
83 | ```
84 |
85 |
86 | Overide the following method
87 | - updateMonthOnScroll
88 | - newDateSelected
89 |
90 | ### updateMonthOnScroll
91 | ```kotlin
92 | override fun updateMonthOnScroll(selectedDate: DayDateMonthYearModel?) {
93 | currentMonthTextView.text = ""+ selectedDate?.month + " " + selectedDate?.year
94 | }
95 |
96 | ```
97 |
98 | ### newDateSelected
99 | ```kotlin
100 | override fun newDateSelected(selectedDate: DayDateMonthYearModel?) {
101 | Toast.makeText(CONTEXT ,selectedDate?.date +""+ selectedDate?.month + " " + selectedDate?.year , Toast.LENGTH_LONG).show()
102 | }
103 |
104 | ```
105 |
106 | ## DayDateMonthYearModel
107 |
108 | `DayDateMonthYearModel` is a custom data class that is used in the library and is returned as the parameter the override method
109 | ```java
110 | public class DayDateMonthYearModel {
111 | public String date;
112 | public String month;
113 | public String year;
114 | public String day;
115 | public String monthNumeric;
116 | public Boolean isToday;
117 | }
118 | ```
119 |
120 | ### Complete MainActivity.kt
121 |
122 | ```kotlin
123 | class MainActivity : AppCompatActivity() , HorizontalCalendarListener {
124 |
125 |
126 |
127 | lateinit var currentMonthTextView : TextView
128 | override fun onCreate(savedInstanceState: Bundle?) {
129 | super.onCreate(savedInstanceState)
130 | setContentView(R.layout.activity_main)
131 | currentMonthTextView = findViewById(R.id.month)
132 | val hcv = findViewById(R.id.horizontalcalendarview)
133 | hcv.setContext(this@MainActivity)
134 | hcv.setBackgroundColor(resources.getColor(R.color.colorPrimary))
135 | hcv.showControls(false)
136 | hcv.setControlTint(R.color.colorAccent)
137 | hcv.changeAccent(R.color.white)
138 | }
139 |
140 | override fun updateMonthOnScroll(selectedDate: DayDateMonthYearModel?) {
141 | currentMonthTextView.text = ""+ selectedDate?.month + " " + selectedDate?.year
142 |
143 | }
144 |
145 | override fun newDateSelected(selectedDate: DayDateMonthYearModel?) {
146 | Toast.makeText(this@MainActivity ,selectedDate?.date +""+ selectedDate?.month + " " + selectedDate?.year , Toast.LENGTH_LONG).show()
147 | }
148 |
149 | }
150 | ```
151 |
152 |
153 | ### Complete activity_main.xml
154 | ```xml
155 |
156 |
164 |
165 |
176 |
177 |
181 |
182 |
183 |
184 |
185 | ```
186 |
187 | ## License
188 | MIT - License
189 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 28
9 | defaultConfig {
10 | applicationId "com.view.calender.horizontal.umar"
11 | minSdkVersion 21
12 | targetSdkVersion 28
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
28 | implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
29 | implementation 'com.android.support.constraint:constraint-layout:1.1.2'
30 | implementation project(':horizontalcalendarview')
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
34 | }
35 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/view/calender/horizontal/umar/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.view.calender.horizontal.umar", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/view/calender/horizontal/umar/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import android.widget.Button
6 | import android.widget.TextView
7 | import android.widget.Toast
8 | import com.view.calender.horizontal.umar.horizontalcalendarview.CalAdapter
9 | import com.view.calender.horizontal.umar.horizontalcalendarview.DayDateMonthYearModel
10 | import com.view.calender.horizontal.umar.horizontalcalendarview.HorizontalCalendarListener
11 | import com.view.calender.horizontal.umar.horizontalcalendarview.HorizontalCalendarView
12 |
13 | class MainActivity : AppCompatActivity(), HorizontalCalendarListener {
14 |
15 | private lateinit var textView: TextView
16 | lateinit var button: Button
17 | private var controlsShown = true
18 |
19 | override fun onCreate(savedInstanceState: Bundle?) {
20 | super.onCreate(savedInstanceState)
21 | setContentView(R.layout.activity_main)
22 | textView = findViewById(R.id.month)
23 | button = findViewById(R.id.button)
24 | val hcv = findViewById(R.id.hcv)
25 | hcv.setContext(this@MainActivity)
26 | hcv.setBackgroundColor(resources.getColor(R.color.background))
27 | hcv.setMaterialStyle(true)
28 | hcv.setWeekNameMode(CalAdapter.WeekNameMode.MEDIUM)
29 | hcv.showControls(false)
30 | hcv.setControlTint(R.color.colorAccent)
31 | hcv.changeAccent(R.color.text_color)
32 |
33 | button.setOnClickListener {
34 | if (controlsShown) {
35 | hcv.showControls(false)
36 | button.text = "Show Controls"
37 | } else {
38 | hcv.showControls(true)
39 | button.text = "Hide Controls"
40 | }
41 | controlsShown = !controlsShown
42 | }
43 | }
44 |
45 | override fun updateMonthOnScroll(selectedDate: DayDateMonthYearModel?) {
46 | val value = "" + selectedDate?.month + " " + selectedDate?.year
47 | textView.text = value
48 |
49 | }
50 |
51 | override fun newDateSelected(selectedDate: DayDateMonthYearModel?) {
52 | Toast.makeText(this@MainActivity, selectedDate?.date + "" + selectedDate?.month + " " + selectedDate?.year, Toast.LENGTH_LONG).show()
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
22 |
23 |
27 |
28 |
29 |
30 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #ffffff
5 | #8b8b8b
6 | #303F9F
7 | #FF4081
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Horizontal Calender View
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/view/calender/horizontal/umar/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.51'
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.1.4'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jul 23 23:23:18 PDT 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/horizontalcalendarview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/horizontalcalendarview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 28
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(include: ['*.jar'], dir: 'libs')
29 | implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
30 | implementation 'com.android.support:design:28.0.0-alpha3'
31 | implementation 'com.android.support:support-v4:28.0.0-alpha3'
32 | testImplementation 'junit:junit:4.12'
33 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35 | implementation project(':horizontalcalendarviewlibrary')
36 | }
37 |
--------------------------------------------------------------------------------
/horizontalcalendarview/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/androidTest/java/com/view/calender/horizontal/umar/horizontalcalendarview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.view.calender.horizontal.umar.horizontalcalendarview.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/java/com/view/calender/horizontal/umar/horizontalcalendarview/CalAdapter.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.annotation.NonNull;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.TextView;
12 |
13 | import java.lang.reflect.InvocationTargetException;
14 | import java.util.ArrayList;
15 |
16 | /**
17 | * Created by UManzoor on 11/28/2017.
18 | */
19 |
20 | public class CalAdapter extends RecyclerView.Adapter {
21 | protected int itemWidthPx;
22 | protected DayDateMonthYearModel lastDaySelected;
23 | protected Context context;
24 | protected int color = R.color.black;
25 | private HorizontalCalendarListener toCallBack;
26 | private TextView clickedTextView = null;
27 | private ArrayList dateArrayList = new ArrayList<>();
28 | private ArrayList dayArrayList = new ArrayList<>();
29 | private ArrayList dividerArrayList = new ArrayList<>();
30 | private ArrayList dayModelList;
31 | private WeekNameMode weekMode = WeekNameMode.SHORT;
32 |
33 | public CalAdapter(Context context, ArrayList dayModelList) {
34 | this.context = context;
35 | this.dayModelList = dayModelList;
36 | }
37 |
38 | public void setCallback(HorizontalCalendarListener toCallBack) {
39 | this.toCallBack = toCallBack;
40 | }
41 |
42 | protected int getCustomLayout() {
43 | return R.layout.custom_day_layout;
44 | }
45 |
46 | public void setItemWidth(int widthPx) {
47 | this.itemWidthPx = widthPx;
48 | }
49 |
50 | @Override
51 | public T onCreateViewHolder(ViewGroup parent, int viewType) {
52 | View itemView = LayoutInflater.from(parent.getContext())
53 | .inflate(getCustomLayout(), parent, false);
54 | return getViewHolder(itemView);
55 | }
56 |
57 | @NonNull
58 | protected T getViewHolder(View itemView) {
59 | return (T) new MyViewHolder(itemView);
60 | }
61 |
62 | @Override
63 | public void onBindViewHolder(final T holder, int position) {
64 | String t = getWeekDayName(position);
65 | holder.day.setTextColor(context.getResources().getColor(color));
66 | holder.date.setTextColor(context.getResources().getColor(color));
67 | if (dayModelList.get(position).isToday) {
68 | updateSelectedItemUI(holder.itemView);
69 | lastDaySelected = dayModelList.get(position);
70 | try {
71 | CallBack cb = new CallBack(toCallBack, "newDateSelected");
72 | cb.invoke(dayModelList.get(position));
73 | } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
74 | //non
75 | }
76 | }
77 |
78 | holder.day.setText(t + " ");
79 | holder.date.setText(dayModelList.get(position).date);
80 | holder.itemView.setTag(position);
81 | dateArrayList.add(holder.date);
82 | dayArrayList.add(holder.day);
83 | dividerArrayList.add(holder.divider);
84 | holder.divider.setBackgroundColor(context.getResources().getColor(color));
85 | holder.itemView.setOnClickListener(new View.OnClickListener() {
86 | @Override
87 | public void onClick(View v) {
88 | int pos = Integer.valueOf(v.getTag().toString());
89 | updateSelectedItemUI(v);
90 |
91 | try {
92 | CallBack cb = new CallBack(toCallBack, "newDateSelected");
93 | cb.invoke(dayModelList.get(pos));
94 | } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
95 | //non
96 | }
97 | lastDaySelected = dayModelList.get(pos);
98 | }
99 | });
100 | }
101 |
102 | protected void updateSelectedItemUI(View root) {
103 | TextView date = root.findViewById(R.id.date);
104 | if (clickedTextView == null) {
105 | clickedTextView = date;
106 | clickedTextView.setBackground(context.getResources().getDrawable(R.drawable.background_selected_day));
107 | clickedTextView.setTextColor(context.getResources().getColor(R.color.white));
108 | clickedTextView.setTypeface(clickedTextView.getTypeface(), Typeface.NORMAL);
109 | } else {
110 | // if(!dayModelList.get(pos).isToday) {
111 | if (lastDaySelected != null && lastDaySelected.isToday) {
112 | clickedTextView.setBackground(context.getResources().getDrawable(R.drawable.currect_date_background));
113 | clickedTextView.setTextColor(context.getResources().getColor(R.color.white));
114 | clickedTextView.setTypeface(clickedTextView.getTypeface(), Typeface.NORMAL);
115 | } else {
116 | clickedTextView.setBackground(null);
117 | clickedTextView.setTextColor(context.getResources().getColor(R.color.grayTextColor));
118 | clickedTextView.setTypeface(clickedTextView.getTypeface(), Typeface.NORMAL);
119 | }
120 | clickedTextView = date;
121 | clickedTextView.setBackground(context.getResources().getDrawable(R.drawable.background_selected_day));
122 | clickedTextView.setTextColor(context.getResources().getColor(R.color.white));
123 | clickedTextView.setTypeface(clickedTextView.getTypeface(), Typeface.NORMAL);
124 | }
125 | }
126 |
127 | private String getWeekDayName(int position) {
128 | String day = dayModelList.get(position).day;
129 | switch (weekMode) {
130 | case SHORT:
131 | return day.substring(0, 1);
132 | case MEDIUM:
133 | return day;
134 | default:
135 | //never happens
136 | return null;
137 | }
138 | }
139 |
140 | @Override
141 | public int getItemCount() {
142 | return dayModelList.size();
143 | }
144 |
145 | public void add(DayDateMonthYearModel DDMYModel) {
146 | dayModelList.add(DDMYModel);
147 | notifyItemInserted(dayModelList.size() - 1);
148 | }
149 |
150 | @Override
151 | public void onViewAttachedToWindow(T holder) {
152 | holder.setIsRecyclable(false);
153 | super.onViewAttachedToWindow(holder);
154 | }
155 |
156 | @Override
157 | public void onViewDetachedFromWindow(T holder) {
158 | holder.setIsRecyclable(false);
159 | super.onViewDetachedFromWindow(holder);
160 | }
161 |
162 | public void changeAccent(int color) {
163 | this.color = color;
164 | for (int i = 0; i < dateArrayList.size(); i++) {
165 | dayArrayList.get(i).setTextColor(context.getResources().getColor(color));
166 | dateArrayList.get(i).setTextColor(context.getResources().getColor(color));
167 | dividerArrayList.get(i).setBackgroundColor(context.getResources().getColor(color));
168 | }
169 | }
170 |
171 | protected void reloadData(CalAdapter adapter) {
172 | if (adapter != null) {
173 | adapter.context = this.context;
174 | adapter.toCallBack = this.toCallBack;
175 | adapter.changeAccent(this.color);
176 | }
177 | }
178 |
179 | public void setWeekMode(WeekNameMode weekMode) {
180 | this.weekMode = weekMode;
181 | }
182 |
183 | public enum WeekNameMode {
184 | SHORT, MEDIUM
185 | }
186 |
187 | public class MyViewHolder extends RecyclerView.ViewHolder {
188 | public TextView day, date;
189 | public View background;
190 | public View divider;
191 | public View root;
192 |
193 | public MyViewHolder(View view) {
194 | super(view);
195 | day = view.findViewById(R.id.day);
196 | date = view.findViewById(R.id.date);
197 | divider = view.findViewById(R.id.divider);
198 | background = date;
199 | }
200 |
201 | protected void setBackgroundColor(Drawable drawable) {
202 | background.setBackground(drawable);
203 | }
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/java/com/view/calender/horizontal/umar/horizontalcalendarview/CallBack.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview;
2 |
3 | import java.lang.reflect.InvocationTargetException;
4 | import java.lang.reflect.Method;
5 |
6 | /**
7 | * Created by UManzoor on 2/8/2018.
8 | */
9 |
10 | public class CallBack {
11 | private String methodName;
12 | private HorizontalCalendarListener scope;
13 |
14 | /*
15 | Sending Third Parameter. For Internet Check.
16 | */
17 | public CallBack(HorizontalCalendarListener scope, String methodName) {
18 | this.methodName = methodName;
19 | this.scope = scope;
20 | }
21 |
22 | public Object invoke(Object... parameters) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
23 | Method method = scope.getClass().getMethod(methodName, getParameterClasses(parameters));
24 | return method.invoke(scope, parameters);
25 | }
26 |
27 | private Class[] getParameterClasses(Object... parameters) {
28 | Class[] classes = new Class[parameters.length];
29 | for (int i = 0; i < classes.length; i++) {
30 | classes[i] = parameters[i].getClass();
31 | }
32 | return classes;
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/java/com/view/calender/horizontal/umar/horizontalcalendarview/DayDateMonthYearModel.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview;
2 |
3 | /**
4 | * Created by UManzoor on 11/28/2017.
5 | */
6 |
7 | public class DayDateMonthYearModel {
8 | public String date;
9 | public String month;
10 | public String year;
11 | public String day;
12 | public String monthNumeric;
13 | public Boolean isToday;
14 | }
15 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/java/com/view/calender/horizontal/umar/horizontalcalendarview/HorizontalCalendarListener.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview;
2 |
3 | public interface HorizontalCalendarListener {
4 | void updateMonthOnScroll(DayDateMonthYearModel selectedDate);
5 | void newDateSelected(DayDateMonthYearModel selectedDate);
6 | }
7 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/java/com/view/calender/horizontal/umar/horizontalcalendarview/HorizontalCalendarView.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.content.ContextCompat;
7 | import android.support.v7.widget.DefaultItemAnimator;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 | import android.view.ViewTreeObserver;
13 | import android.widget.ImageView;
14 | import android.widget.LinearLayout;
15 |
16 | import com.view.calender.horizontal.umar.horizontalcalendarview.material.MaterialCalAdapter;
17 |
18 | import java.lang.reflect.InvocationTargetException;
19 | import java.text.DateFormat;
20 | import java.text.SimpleDateFormat;
21 | import java.util.ArrayList;
22 | import java.util.Calendar;
23 | import java.util.Date;
24 |
25 | public class HorizontalCalendarView extends LinearLayout {
26 |
27 |
28 | LinearLayout leftButton;
29 | LinearLayout rightButton;
30 | ImageView leftImage;
31 | ImageView rightImage;
32 | View rootView;
33 | Context context;
34 | RecyclerView recyclerView;
35 | CalAdapter calAdapter;
36 | ArrayList currentDayModelList;
37 | HorizontalPaginationScroller horizontalPaginationScroller;
38 | Calendar cal;
39 | Calendar calPrevious;
40 | DateFormat dateFormat;
41 | Date date;
42 | Date datePrevious;
43 | LinearLayoutManager linearLayoutManager;
44 | LinearLayout mainBackground;
45 | HorizontalCalendarListener toCallBack;
46 | private boolean isLoading;
47 | private Boolean changedToMaterial = null;
48 | private int singleItemWidth;
49 | private CalAdapter.WeekNameMode mode = CalAdapter.WeekNameMode.SHORT;
50 |
51 | public HorizontalCalendarView(Context context) {
52 | super(context);
53 | this.context = context;
54 | init();
55 | }
56 |
57 | public HorizontalCalendarView(Context context, @Nullable AttributeSet attrs) {
58 | super(context, attrs);
59 | this.context = context;
60 | init();
61 | }
62 |
63 | public void init() {
64 | rootView = inflate(context, R.layout.custom_calender_layout, this);
65 | leftButton = findViewById(R.id.swipe_left);
66 | rightButton = findViewById(R.id.swipe_right);
67 | recyclerView = findViewById(R.id.recycler_view);
68 | mainBackground = findViewById(R.id.main_background);
69 | leftImage = findViewById(R.id.left_image_view);
70 | rightImage = findViewById(R.id.right_image_view);
71 | loadNextPage();
72 | leftButton.setOnClickListener(new OnClickListener() {
73 | @Override
74 | public void onClick(View v) {
75 | // Toast.makeText(context, "left but", Toast.LENGTH_SHORT).show();
76 | // if (linearLayoutManager.findFirstVisibleItemPosition())
77 | recyclerView.smoothScrollToPosition(linearLayoutManager.findFirstVisibleItemPosition() - 3);
78 | }
79 | });
80 | rightButton.setOnClickListener(new OnClickListener() {
81 | @Override
82 | public void onClick(View v) {
83 | // Toast.makeText(context, "right but", Toast.LENGTH_SHORT).show();
84 | recyclerView.smoothScrollToPosition(linearLayoutManager.findLastVisibleItemPosition() + 3);
85 | }
86 | });
87 |
88 | recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
89 | @Override
90 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
91 | super.onScrolled(recyclerView, dx, dy);
92 | int lastVisibleIndex = linearLayoutManager.findLastVisibleItemPosition();
93 | int firstVisibleIndex = linearLayoutManager.findFirstVisibleItemPosition();
94 | if (dx > 0) {
95 | for (int i = firstVisibleIndex; i < lastVisibleIndex; i++) {
96 |
97 | if (currentDayModelList.get(i).month.compareTo(currentDayModelList.get(i + 1).month) != 0) {
98 | try {
99 | CallBack cb = new CallBack(toCallBack, "updateMonthOnScroll");
100 | cb.invoke(currentDayModelList.get(i + 1));
101 | } catch (InvocationTargetException e) {
102 | e.printStackTrace();
103 | } catch (IllegalAccessException e) {
104 | e.printStackTrace();
105 | } catch (NoSuchMethodException e) {
106 | e.printStackTrace();
107 | }
108 | }
109 | }
110 | } else if (dx < 0) {
111 | for (int i = lastVisibleIndex; i > firstVisibleIndex; i--) {
112 |
113 | if (currentDayModelList.get(i).month.compareTo(currentDayModelList.get(i + 1).month) != 0) {
114 | try {
115 | CallBack cb = new CallBack(toCallBack, "updateMonthOnScroll");
116 | cb.invoke(currentDayModelList.get(i));
117 | } catch (InvocationTargetException e) {
118 | e.printStackTrace();
119 | } catch (IllegalAccessException e) {
120 | e.printStackTrace();
121 | } catch (NoSuchMethodException e) {
122 | e.printStackTrace();
123 | }
124 | }
125 | }
126 | }
127 | }
128 | });
129 |
130 | linearLayoutManager.scrollToPosition(27);
131 | }
132 |
133 | public void loadNextPage() {
134 | if (changeCalAdapter()) {
135 | recyclerView.setAdapter(calAdapter);
136 | }
137 | if (calAdapter == null) {
138 | currentDayModelList = new ArrayList<>();
139 | dateFormat = new SimpleDateFormat("MMMM-EEE-yyyy-MM-dd");
140 | date = new Date();
141 | //System.out.println("Day 1"+" "+dateFormat.format(date));
142 | DayDateMonthYearModel currentDayModel = new DayDateMonthYearModel();
143 | String currentDate = dateFormat.format(date).toString();
144 | String[] partsDate = currentDate.split("-");
145 | currentDayModel.month = partsDate[0];
146 | currentDayModel.date = partsDate[4];
147 | currentDayModel.day = partsDate[1];
148 | currentDayModel.year = partsDate[2];
149 | currentDayModel.monthNumeric = partsDate[3];
150 | currentDayModel.isToday = true;
151 | calPrevious = Calendar.getInstance();
152 | cal = Calendar.getInstance();
153 | cal.setTime(date);
154 | calPrevious.setTime(date);
155 |
156 |
157 | for (int i = 0; i < 30; i++) {
158 | calPrevious.add(Calendar.DAY_OF_WEEK, -1);
159 | String nextDate = dateFormat.format(calPrevious.getTime());
160 | DayDateMonthYearModel previousDayMode = new DayDateMonthYearModel();
161 | String[] partsNextDate = nextDate.split("-");
162 | previousDayMode.month = partsNextDate[0];
163 | previousDayMode.date = partsNextDate[4];
164 | previousDayMode.day = partsNextDate[1];
165 | previousDayMode.year = partsNextDate[2];
166 | previousDayMode.monthNumeric = partsNextDate[3];
167 | previousDayMode.isToday = false;
168 | isLoading = false;
169 | // calAdapter.addPrevious(currentDayMode);
170 | currentDayModelList.add(0, previousDayMode);
171 | }
172 | currentDayModelList.add(currentDayModel);
173 |
174 | //SimpleDateFormat sdf = new SimpleDateFormat("MMM EEE yyyy-MM-dd");
175 | for (int i = 0; i < 30; i++) {
176 | cal.add(Calendar.DAY_OF_WEEK, 1);
177 | String nextDate = dateFormat.format(cal.getTime());
178 | DayDateMonthYearModel currentDayMode = new DayDateMonthYearModel();
179 | String[] partsNextDate = nextDate.split("-");
180 | currentDayMode.month = partsNextDate[0];
181 | currentDayMode.date = partsNextDate[4];
182 | currentDayMode.day = partsNextDate[1];
183 | currentDayMode.year = partsNextDate[2];
184 | currentDayMode.monthNumeric = partsNextDate[3];
185 | currentDayMode.isToday = false;
186 | currentDayModelList.add(currentDayMode);
187 | calAdapter = newCalAdapter();
188 | linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
189 | recyclerView.setLayoutManager(linearLayoutManager);
190 | recyclerView.setItemAnimator(new DefaultItemAnimator());
191 | recyclerView.setAdapter(calAdapter);
192 | horizontalPaginationScroller = new HorizontalPaginationScroller(linearLayoutManager) {
193 | @Override
194 | protected void loadMoreItems() {
195 | isLoading = true;
196 | loadNextPage();
197 | }
198 |
199 | @Override
200 | protected void loadMoreItemsOnLeft() {
201 | // isLoading = true;
202 | // Toast.makeText(context, "Reached Left", Toast.LENGTH_SHORT).show();
203 | // loadPreviousPage( );
204 | }
205 |
206 | @Override
207 | public boolean isLoading() {
208 | return isLoading;
209 | }
210 | };
211 | recyclerView.addOnScrollListener(horizontalPaginationScroller);
212 | }
213 | } else {
214 | for (int i = 0; i < 30; i++) {
215 | cal.add(Calendar.DAY_OF_WEEK, 1);
216 | String nextDate = dateFormat.format(cal.getTime());
217 | DayDateMonthYearModel currentDayMode = new DayDateMonthYearModel();
218 | String[] partsNextDate = nextDate.split("-");
219 | currentDayMode.month = partsNextDate[0];
220 | currentDayMode.date = partsNextDate[4];
221 | currentDayMode.day = partsNextDate[1];
222 | currentDayMode.year = partsNextDate[2];
223 | currentDayMode.isToday = false;
224 | isLoading = false;
225 | calAdapter.add(currentDayMode);
226 | }
227 | }
228 | }
229 |
230 | private boolean changeCalAdapter() {
231 | boolean res = false;
232 | if (calAdapter != null) {
233 | if (changedToMaterial != null) {
234 | calAdapter = newCalAdapter();
235 | res = true;
236 | }
237 | calAdapter.setWeekMode(mode);
238 | }
239 | return res;
240 | }
241 |
242 | @NonNull
243 | private CalAdapter newCalAdapter() {
244 | if (changedToMaterial == null) {
245 | changedToMaterial = false;
246 | }
247 | CalAdapter res = changedToMaterial ? new MaterialCalAdapter(context, currentDayModelList) : new CalAdapter(context, currentDayModelList);
248 | reinitCalAdapterData(res);
249 | changedToMaterial = null;
250 | return res;
251 | }
252 |
253 | private void reinitCalAdapterData(final CalAdapter res) {
254 | if (calAdapter != null) {
255 | calAdapter.reloadData(res);
256 | }
257 | setNewRecyclerItemWidth(res);
258 | }
259 |
260 | private void setNewRecyclerItemWidth(final CalAdapter res) {
261 | if (singleItemWidth == 0) {
262 | recyclerView.getViewTreeObserver().addOnGlobalLayoutListener(
263 | new ViewTreeObserver.OnGlobalLayoutListener() {
264 | @Override
265 | public void onGlobalLayout() {
266 | recyclerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
267 | singleItemWidth = recyclerView.getWidth() / 7;
268 | updateRecyclerItemWidth(res);
269 | res.notifyDataSetChanged();
270 | }
271 | }
272 | );
273 | } else {
274 | updateRecyclerItemWidth(res);
275 | }
276 | }
277 |
278 | private void updateRecyclerItemWidth(CalAdapter res) {
279 | res.setItemWidth(singleItemWidth);
280 | }
281 |
282 | public void setBackgroundColor(int color) {
283 | mainBackground.setBackgroundColor(color);
284 | }
285 |
286 | public void setControlTint(int color) {
287 | rightImage.setColorFilter(ContextCompat.getColor(context, color), android.graphics.PorterDuff.Mode.SRC_IN);
288 | leftImage.setColorFilter(ContextCompat.getColor(context, color), android.graphics.PorterDuff.Mode.SRC_IN);
289 | }
290 |
291 | public void showControls(boolean show) {
292 | if (show) {
293 | leftButton.setVisibility(VISIBLE);
294 | rightButton.setVisibility(VISIBLE);
295 | LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
296 | 0,
297 | LayoutParams.MATCH_PARENT,
298 | 7.0f
299 | );
300 | LinearLayout.LayoutParams paramTwo = new LinearLayout.LayoutParams(
301 | 0,
302 | LayoutParams.MATCH_PARENT,
303 | 1.5f
304 | );
305 | paramTwo.topMargin = 20;
306 | paramTwo.bottomMargin = 20;
307 | leftButton.setLayoutParams(paramTwo);
308 | rightButton.setLayoutParams(paramTwo);
309 | recyclerView.setLayoutParams(param);
310 |
311 | } else {
312 | leftButton.setVisibility(GONE);
313 | rightButton.setVisibility(GONE);
314 | LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
315 | LayoutParams.MATCH_PARENT,
316 | LayoutParams.WRAP_CONTENT);
317 | recyclerView.setLayoutParams(param);
318 | }
319 | askForRecalculateItemWidth();
320 | }
321 |
322 | private void askForRecalculateItemWidth() {
323 | singleItemWidth = 0;
324 | if (calAdapter != null) {
325 | setNewRecyclerItemWidth(calAdapter);
326 | }
327 | }
328 |
329 | public void setContext(HorizontalCalendarListener toCallBack) {
330 | this.toCallBack = toCallBack;
331 | calAdapter.setCallback(toCallBack);
332 | Date date = new Date();
333 | DayDateMonthYearModel currentDayModel = new DayDateMonthYearModel();
334 | String currentDate = dateFormat.format(date).toString();
335 | String[] partsDate = currentDate.split("-");
336 | currentDayModel.month = partsDate[0];
337 | currentDayModel.date = partsDate[4];
338 | currentDayModel.day = partsDate[1];
339 | currentDayModel.year = partsDate[2];
340 | currentDayModel.monthNumeric = partsDate[3];
341 | currentDayModel.isToday = true;
342 | try {
343 | CallBack cb = new CallBack(toCallBack, "updateMonthOnScroll");
344 | cb.invoke(currentDayModel);
345 | } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
346 | }
347 | }
348 |
349 | public void changeAccent(int color) {
350 | calAdapter.changeAccent(color);
351 | }
352 |
353 | public void setMaterialStyle(boolean isMaterial) {
354 | this.changedToMaterial = isMaterial;
355 | loadNextPage();
356 | }
357 |
358 | public void setWeekNameMode(CalAdapter.WeekNameMode mode) {
359 | this.mode = mode;
360 | if (calAdapter != null) {
361 | calAdapter.setWeekMode(mode);
362 | calAdapter.notifyDataSetChanged();
363 | }
364 | }
365 | }
366 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/java/com/view/calender/horizontal/umar/horizontalcalendarview/HorizontalPaginationScroller.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview;
2 |
3 |
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 |
7 | /**
8 | * Created by UManzoor on 11/28/2017.
9 | */
10 |
11 | public abstract class HorizontalPaginationScroller extends RecyclerView.OnScrollListener {
12 | LinearLayoutManager layoutManager;
13 |
14 | public HorizontalPaginationScroller(LinearLayoutManager layoutManager) {
15 | this.layoutManager = layoutManager;
16 | }
17 |
18 | @Override
19 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
20 | super.onScrolled(recyclerView, dx, dy);
21 |
22 | int visibleItemCount = layoutManager.getChildCount();
23 | int totalItemCount = layoutManager.getItemCount();
24 | int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
25 |
26 | if (!isLoading()) {
27 | if ((visibleItemCount + firstVisibleItemPosition) >= totalItemCount
28 | && firstVisibleItemPosition >= 0) {
29 | loadMoreItems();
30 | }
31 | if (layoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
32 | loadMoreItemsOnLeft();
33 | }
34 |
35 | }
36 | }
37 |
38 | protected abstract void loadMoreItems();
39 |
40 | protected abstract void loadMoreItemsOnLeft();
41 |
42 | public abstract boolean isLoading();
43 | }
44 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/java/com/view/calender/horizontal/umar/horizontalcalendarview/material/MaterialCalAdapter.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview.material;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.annotation.NonNull;
7 | import android.util.Pair;
8 | import android.view.View;
9 | import android.widget.FrameLayout;
10 | import android.widget.TextView;
11 |
12 | import com.view.calender.horizontal.umar.horizontalcalendarview.CalAdapter;
13 | import com.view.calender.horizontal.umar.horizontalcalendarview.DayDateMonthYearModel;
14 | import com.view.calender.horizontal.umar.horizontalcalendarview.R;
15 |
16 | import java.util.ArrayList;
17 |
18 | /**
19 | * Created by UManzoor on 11/28/2017.
20 | */
21 |
22 | public class MaterialCalAdapter extends CalAdapter {
23 | private Pair> clickedView = null;
24 |
25 | public MaterialCalAdapter(Context context, ArrayList dayModelList) {
26 | super(context, dayModelList);
27 | }
28 |
29 | @Override
30 | protected int getCustomLayout() {
31 | return R.layout.material_custom_day_layout;
32 | }
33 |
34 | @Override
35 | public void onBindViewHolder(MaterialViewHolder holder, int position) {
36 | super.onBindViewHolder(holder, position);
37 | holder.updateWidth();
38 | }
39 |
40 | @Override
41 | protected void updateSelectedItemUI(View root) {
42 | View clicked = root.findViewById(R.id.background);
43 | TextView day = root.findViewById(R.id.day);
44 | TextView date = root.findViewById(R.id.date);
45 | if (clickedView == null) {
46 | clickedView = new Pair(clicked, new Pair(date, day));
47 | clickedView.first.setAlpha(1f);
48 | clickedView.first.setVisibility(View.VISIBLE);
49 | clickedView.second.first.setTextSize(24);
50 | clickedView.second.first.setTextColor(Color.WHITE);
51 | clickedView.second.second.setTextColor(Color.WHITE);
52 | } else {
53 | if (lastDaySelected != null && lastDaySelected.isToday) {
54 | clickedView.first.setAlpha(0.3f);
55 | clickedView.first.setVisibility(View.VISIBLE);
56 | clickedView.second.first.setTextSize(24);
57 | clickedView.second.first.setTextColor(context.getResources().getColor(color));
58 | clickedView.second.second.setTextColor(context.getResources().getColor(color));
59 | } else {
60 | clickedView.first.setVisibility(View.INVISIBLE);
61 | clickedView.second.first.setTextSize(18);
62 | clickedView.second.first.setTextColor(context.getResources().getColor(color));
63 | clickedView.second.second.setTextColor(context.getResources().getColor(color));
64 | }
65 | clickedView = new Pair(clicked, new Pair(date, day));
66 | clickedView.first.setAlpha(1f);
67 | clickedView.second.first.setTextSize(24);
68 | clickedView.second.first.setTextColor(Color.WHITE);
69 | clickedView.second.second.setTextColor(Color.WHITE);
70 | clickedView.first.setVisibility(View.VISIBLE);
71 | }
72 | }
73 |
74 | @NonNull
75 | @Override
76 | protected MaterialViewHolder getViewHolder(View itemView) {
77 | return new MaterialViewHolder(itemView);
78 | }
79 |
80 |
81 | class MaterialViewHolder extends CalAdapter.MyViewHolder {
82 | MaterialViewHolder(View view) {
83 | super(view);
84 | background = view.findViewById(R.id.background);
85 | }
86 |
87 | @Override
88 | protected void setBackgroundColor(Drawable drawable) {
89 | this.background.setVisibility(View.VISIBLE);
90 | }
91 |
92 | void updateWidth() {
93 | //to show only 7 days on screen at single time
94 | setNewWidth(day);
95 | setNewWidth(date);
96 | setNewWidth(background);
97 | }
98 |
99 | private void setNewWidth(View v) {
100 | if (v.getMeasuredWidth() != itemWidthPx) {
101 | v.setLayoutParams(getNewParams(v));
102 | }
103 | }
104 |
105 | private FrameLayout.LayoutParams getNewParams(View root) {
106 | return new FrameLayout.LayoutParams(itemWidthPx, root.getLayoutParams().height);
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/drawable/background_selected_day.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
8 |
9 |
10 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/drawable/currect_date_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
8 |
9 |
10 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/drawable/date_picker_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
8 |
9 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/drawable/ic_appointment_back.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/drawable/ic_appointment_next.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/drawable/ic_three_dots.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/drawable/selected_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/layout/custom_calender_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
24 |
25 |
26 |
27 |
32 |
33 |
34 |
35 |
42 |
43 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/layout/custom_day_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
14 |
22 |
23 |
29 |
36 |
44 |
45 |
52 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/layout/material_custom_day_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
22 |
23 |
24 |
28 |
29 |
32 |
33 |
40 |
41 |
42 |
47 |
48 |
51 |
52 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ececec
4 | #95989A
5 | #000000
6 | #ffffff
7 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Horizontal Calendar View
3 |
4 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/horizontalcalendarview/src/test/java/com/view/calender/horizontal/umar/horizontalcalendarview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/horizontalcalendarviewlibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/horizontalcalendarviewlibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 28
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 |
30 | implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
34 | }
35 |
--------------------------------------------------------------------------------
/horizontalcalendarviewlibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/horizontalcalendarviewlibrary/src/androidTest/java/com/view/calender/horizontal/umar/horizontalcalendarlibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarlibrary;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.view.calender.horizontal.umar.horizontalcalendarlibrary.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/horizontalcalendarviewlibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/horizontalcalendarviewlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Horizontal Calendar View
3 |
4 |
--------------------------------------------------------------------------------
/horizontalcalendarviewlibrary/src/test/java/com/view/calender/horizontal/umar/horizontalcalendarlibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.view.calender.horizontal.umar.horizontalcalendarlibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':horizontalcalendarview', ':horizontalcalendarviewlibrary'
2 |
--------------------------------------------------------------------------------
/ss/DemoGif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/ss/DemoGif.gif
--------------------------------------------------------------------------------
/ss/DemoGifTwo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/ss/DemoGifTwo.gif
--------------------------------------------------------------------------------
/ss/material_ui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybringback22/HorizontalCalendarView-Android-/69b8b95af50e5b3cf3d8c38d5ffe105274a08f39/ss/material_ui.png
--------------------------------------------------------------------------------