├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── vrgsoft
│ │ └── calendarview
│ │ ├── CustomDayUtils.java
│ │ ├── CustomView.java
│ │ ├── GlideCalendarExtension.java
│ │ ├── GlideCalendarModule.java
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-hdpi
│ ├── ic_next.png
│ ├── ic_next_button_example.png
│ ├── ic_previous.png
│ └── ic_stat_name.png
│ ├── drawable-mdpi
│ ├── ic_next.png
│ ├── ic_next_button_example.png
│ ├── ic_previous.png
│ └── ic_stat_name.png
│ ├── drawable-xhdpi
│ ├── ic_next.png
│ ├── ic_next_button_example.png
│ ├── ic_previous.png
│ └── ic_stat_name.png
│ ├── drawable-xxhdpi
│ ├── giphy.gif
│ ├── ic_next.png
│ ├── ic_next_button_example.png
│ ├── ic_previous.png
│ ├── ic_stat_name.png
│ └── simple_ex.jpg
│ ├── drawable
│ ├── background.xml
│ └── background_sample.xml
│ ├── layout
│ ├── activity_main.xml
│ └── custom_view.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
├── build.gradle
├── calendar.jpg
├── calendar
├── .gitignore
├── build.gradle
├── calendar.iml
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── vrgsoft
│ │ └── calendar
│ │ ├── CalendarAdapter.java
│ │ ├── CalendarPagerAdapter.java
│ │ ├── CalendarRecyclerView.java
│ │ ├── CalendarSettingWrapper.java
│ │ ├── DensityUtils.java
│ │ ├── Settings.java
│ │ ├── VRCalendarCustomViewCallback.java
│ │ ├── VRCalendarHolder.java
│ │ ├── VRCalendarView.java
│ │ ├── VrCalendarDay.java
│ │ ├── VrCalendarDaySettings.java
│ │ ├── VrCalendarUtils.java
│ │ ├── WrapContentHeightViewPager.java
│ │ └── calendar_listeners
│ │ ├── OnCalendarClickListener.java
│ │ ├── OnCalendarLongClickListener.java
│ │ ├── VRCalendarCustomViewCallback.java
│ │ ├── VRCalendarMonthCallback.java
│ │ └── VRCalendarUpdateListener.java
│ └── res
│ ├── drawable-hdpi
│ ├── ic_keyboard_arrow_left_black_24dp.png
│ └── ic_keyboard_arrow_right_black_24dp.png
│ ├── drawable-mdpi
│ ├── ic_keyboard_arrow_left_black_24dp.png
│ └── ic_keyboard_arrow_right_black_24dp.png
│ ├── drawable-xhdpi
│ ├── ic_keyboard_arrow_left_black_24dp.png
│ └── ic_keyboard_arrow_right_black_24dp.png
│ ├── drawable-xxhdpi
│ ├── ic_keyboard_arrow_left_black_24dp.png
│ └── ic_keyboard_arrow_right_black_24dp.png
│ ├── drawable-xxxhdpi
│ ├── ic_keyboard_arrow_left_black_24dp.png
│ └── ic_keyboard_arrow_right_black_24dp.png
│ ├── layout
│ ├── calendar_view.xml
│ ├── item_calendar_day.xml
│ └── recycler_calendar.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ └── strings.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── image.jpg
├── local.properties
└── settings.gradle
/README.md:
--------------------------------------------------------------------------------
1 | # VRCalendarView
2 |
3 |
4 |
5 | # Usage
6 |
7 | *For a working implementation, Have a look at the Sample Project - app*
8 |
9 | 1. Include the library as local library project.
10 | ```gradle
11 | allprojects {
12 | repositories {
13 | maven { url 'https://jitpack.io' }
14 | }
15 | }
16 |
17 | dependencies {
18 |
19 | compile 'com.github.VRGsoftUA:VRCalendarView:1.0.3'
20 |
21 | }
22 | ```
23 | 2. Include the VRCalendarView widget in your layout.
24 |
25 | ```xml
26 |
43 | ```
44 | 3. You can do same with java
45 | ```java
46 | vrCalendarView.getSettings()
47 | .setOtherMonthTextStyle(VRCalendarView.BOLD)
48 | .setCurrentMonthBackgroundColor(Color.CYAN)
49 | .updateCalendar();
50 | ```
51 |
52 | or
53 |
54 | ```java
55 | vrCalendarView.getSettings()
56 | .setOnCalendarClickListener(this)
57 | .setOnCalendarLongClickListener(this)
58 | .setVRCalendarMonthCallback(this);
59 | ```
60 |
61 | 4. You can update all days by calling VRCalendarView.getSettings().updateCalendar();
62 |
63 | ```java
64 | vrCalendarView.getSettings()
65 | .setOtherMonthTextStyle(VRCalendarView.BOLD)
66 | .setCurrentMonthBackgroundColor(Color.CYAN)
67 | .updateCalendar();
68 | ```
69 |
70 | if VRCalendarView.getSettings().updateCalendar() is called and you want to save some custom day
71 | List getCustomizeDayView(Calendar calendar) method should be overridden
72 | getCustomizeDayView(Calendar calendar) is return all days you need to make custom.
73 | With parameter calendar you can get the year and the month to return customised days from specific month
74 | ```java
75 | @Override
76 | public List getCustomizeDayView(Calendar calendar) {
77 | List vrCalendarDays = new ArrayList<>();
78 | VrCalendarDay today = new VrCalendarDay();
79 | today.setDate(new Date());
80 |
81 | VrCalendarDaySettings todaySettings = new VrCalendarDaySettings();
82 | todaySettings.setDayTextColor(Color.CYAN);
83 | today.setVrCalendarDaySettings(todaySettings);
84 | today.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
85 | @Override
86 | public View getNewCustomiseView() {
87 | ImageView imageView = new ImageView(MainActivity.this);
88 | imageView.setImageResource(R.drawable.ic_stat_name);
89 | return imageView;
90 | }
91 | });
92 |
93 | vrCalendarDays.add(today);
94 |
95 | VrCalendarDay tomorrow = new VrCalendarDay();
96 | Date d = new Date(1513435110633L); // December 16, 2017
97 | tomorrow.setDate(d);
98 | VrCalendarDaySettings vrtomorCalendarDaySettings = new VrCalendarDaySettings();
99 | vrtomorCalendarDaySettings.setDayTextStyle(VRCalendarView.BOLD);
100 | vrtomorCalendarDaySettings.setDayBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent));
101 | vrtomorCalendarDaySettings.setDayTextColor(ContextCompat.getColor(this, R.color.colorYellow));
102 | tomorrow.setVrCalendarDaySettings(vrtomorCalendarDaySettings);
103 |
104 | vrCalendarDays.add(tomorrow);
105 |
106 | return vrCalendarDays;
107 | }
108 | ```
109 | You can set set whatever view you want and customise it like you want if standard customisation does not fit
110 |
111 | Attention!!!
112 |
113 | View getNewCustomiseView() should always return new View. other wise it doesn't work properly
114 | ```java
115 | today.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
116 | @Override
117 | public View getNewCustomiseView() {
118 | ImageView imageView = new ImageView(MainActivity.this);
119 | imageView.setImageResource(R.drawable.ic_stat_name);
120 | return imageView;
121 | }
122 | });
123 | ```
124 |
125 | but if you need to update specific day it is better to call
126 |
127 | ```java
128 | vrCalendarView.getSettings().updateCalendarDay(VrCalendarDay today, boolean hasToSelect);
129 | ```
130 | where VrCalendarDay has settings to customise specific day - hasToSelect should be false than
131 | and hasToSelect is boolean that sets specific customisation
132 | not from VrCalendarDay settings but from default settings that has attribute "chosen". Like below
133 | ```xml
134 | app:vr_chosen_day_background_color="@color/colorGreen"
135 | app:vr_chosen_day_background_drawable="@drawable/background"
136 | ```
137 | to update specific day you have to set VRCalendarDay.setDate(Date date); - it is required
138 | ```java
139 | VrCalendarDay today = new VrCalendarDay();
140 | today.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
141 | @Override
142 | public View getNewCustomiseView() {
143 | ImageView imageView = new ImageView(MainActivity.this);
144 | imageView.setImageResource(R.drawable.ic_stat_name);
145 | return imageView;
146 | }
147 | });
148 | today.setDate(day.getDate());
149 | ```
150 |
151 | Move to date with
152 |
153 | VrCalendarView.moveToDate(Date date);
154 |
155 | 5. There is onClick listener and onLongClick
156 | ```java
157 |
158 | public interface OnCalendarLongClickListener {
159 | void onCalendarDayLongClick(VrCalendarDay day);
160 | }
161 | ```
162 |
163 | and
164 |
165 | ```java
166 | public interface OnCalendarClickListener {
167 | void onCalendarDayClick(VrCalendarDay day);
168 | }
169 |
170 | that returns VrCalendarDay you click on
171 |
172 | #### Customisation
173 | You can add fields via xml or VrCalendarView or VrCalendarView.getSettings().
174 |
175 | # Supported fields:
176 |
177 | | Method | Type |
178 | | ------------- | ------------- |
179 | | vr_current_day_text_color | color |
180 | | vr_current_month_text_color | color |
181 | | vr_other_month_text_color | color |
182 | | vr_current_month_other_days_text_color | color |
183 | | vr_chosen_day_text_color |color |
184 | | vr_current_day_background_color | color |
185 | | vr_current_month_background_color | color |
186 | | vr_other_month_background_color | color |
187 | | vr_current_month_other_days_background_color |color |
188 | | vr_chosen_day_background_color | color |
189 | | vr_current_day_background_drawable | integer |
190 | | vr_current_month_background_drawable | integer |
191 | | vr_other_month_background_drawable" | integer |
192 | | vr_current_month_other_days_background_drawable | integer |
193 | | vr_chosen_day_background_drawable | integer |
194 | | vr_calendar_day_text_size | dimension |
195 | | vr_calendar_title_text_size | dimension |
196 | | vr_next_button | integer |
197 | | vr_previous_button | integer |
198 | | vr_title_text_color | color |
199 | | vr_background_color | color |
200 | | vr_week_days_color | color |
201 | | vr_current_day_text_style | normal,bold,italic |
202 | | vr_current_month_text_style | normal,bold,italic |
203 | | vr_other_month_text_style | normal,bold,italic |
204 | | vr_current_month_other_days_text_style | normal,bold,italic |
205 | | vr_chosen_day_text_style | normal,bold,italic |
206 |
207 | #### Contributing
208 |
209 | * Contributions are always welcome
210 | * If you want a feature and can code, feel free to fork and add the change yourself and make a pull request
211 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | buildToolsVersion "27.0.2"
6 | defaultConfig {
7 | applicationId "com.vrgsoft.calendarview"
8 | minSdkVersion 16
9 | targetSdkVersion 27
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:27.0.2'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | compile 'com.github.VRGsoftUA:VRCalendarView:1.0.3'
31 | compile 'com.github.bumptech.glide:glide:4.5.0'
32 | annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
33 | // compile project(path: ':calendar')
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/vrgsoft/calendarview/CustomDayUtils.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendarview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.support.v4.content.ContextCompat;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 |
9 | import com.vrgsoft.calendar.VRCalendarCustomViewCallback;
10 | import com.vrgsoft.calendar.VRCalendarView;
11 | import com.vrgsoft.calendar.VrCalendarDay;
12 | import com.vrgsoft.calendar.VrCalendarDaySettings;
13 |
14 | import java.util.ArrayList;
15 | import java.util.Calendar;
16 | import java.util.Date;
17 | import java.util.List;
18 |
19 | public class CustomDayUtils {
20 |
21 | public List getCustomizeDayView(final Context context) {
22 | List vrCalendarDays = new ArrayList<>();
23 |
24 | vrCalendarDays.add(getToday(context));
25 | vrCalendarDays.add(getSomeDay(context));
26 | vrCalendarDays.add(getSomeDayAgain(context));
27 | vrCalendarDays.add(getOneMoreDay(context));
28 | vrCalendarDays.add(getDay0(context));
29 | vrCalendarDays.add(getDay1(context));
30 | vrCalendarDays.add(getDay2(context));
31 | vrCalendarDays.add(getDay3(context));
32 |
33 | return vrCalendarDays;
34 | }
35 |
36 | private VrCalendarDay getOneMoreDay(final Context context) {
37 | VrCalendarDay tomorrow = new VrCalendarDay();
38 | Calendar cal = Calendar.getInstance();
39 | cal.add(Calendar.DAY_OF_MONTH, 1);
40 | Date d = cal.getTime();
41 | tomorrow.setDate(d);
42 | tomorrow.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
43 | @Override
44 | public View getNewCustomiseView() {
45 | CustomView customView = new CustomView(context);
46 | return customView;
47 | }
48 | });
49 | VrCalendarDaySettings vrtomorCalendarDaySettings = new VrCalendarDaySettings();
50 | vrtomorCalendarDaySettings.setDayTextStyle(VRCalendarView.BOLD);
51 | vrtomorCalendarDaySettings.setDayTextSize(21);
52 | vrtomorCalendarDaySettings.setDayTextColor(ContextCompat.getColor(context, R.color.colorDark));
53 | tomorrow.setVrCalendarDaySettings(vrtomorCalendarDaySettings);
54 |
55 | return tomorrow;
56 | }
57 |
58 | private VrCalendarDay getSomeDay(final Context context) {
59 |
60 | VrCalendarDay someDay = new VrCalendarDay();
61 |
62 | VrCalendarDaySettings someDaySettings = new VrCalendarDaySettings();
63 | someDaySettings.setDayTextColor(Color.CYAN);
64 | someDay.setVrCalendarDaySettings(someDaySettings);
65 | someDay.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
66 | @Override
67 | public View getNewCustomiseView() {
68 | ImageView imageView = new ImageView(context);
69 | imageView.setImageResource(R.drawable.simple_ex);
70 | return imageView;
71 | }
72 | });
73 |
74 | Calendar cal = Calendar.getInstance();
75 | cal.add(Calendar.DAY_OF_MONTH, -5);
76 | someDay.setDate(cal.getTime());
77 | someDay.setVrCalendarDaySettings(someDaySettings);
78 | return someDay;
79 | }
80 |
81 | private VrCalendarDay getSomeDayAgain(final Context context) {
82 |
83 | VrCalendarDay someDay = new VrCalendarDay();
84 |
85 | VrCalendarDaySettings someDaySettings = new VrCalendarDaySettings();
86 | someDaySettings.setDayTextColor(Color.TRANSPARENT);
87 | someDaySettings.setDayBackgroundColor(Color.TRANSPARENT);
88 | someDay.setVrCalendarDaySettings(someDaySettings);
89 | someDay.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
90 | @Override
91 | public View getNewCustomiseView() {
92 |
93 | ImageView imageView = new ImageView(context);
94 | imageView.setImageResource(R.drawable.simple_ex);
95 | GlideApp.with(context)
96 | .asGif()
97 | .load(R.drawable.giphy)
98 | .into(imageView)
99 | .clearOnDetach();
100 | return imageView;
101 | }
102 | });
103 |
104 | Calendar cal = Calendar.getInstance();
105 | cal.add(Calendar.DAY_OF_MONTH, -6);
106 | someDay.setDate(cal.getTime());
107 | someDay.setVrCalendarDaySettings(someDaySettings);
108 | return someDay;
109 | }
110 |
111 | private VrCalendarDay getToday(final Context context) {
112 | VrCalendarDay today = new VrCalendarDay();
113 | today.setDate(new Date());
114 |
115 | VrCalendarDaySettings todaySettings = new VrCalendarDaySettings();
116 | todaySettings.setDayTextColor(ContextCompat.getColor(context, R.color.colorTransparent));
117 | today.setVrCalendarDaySettings(todaySettings);
118 | today.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
119 | @Override
120 | public View getNewCustomiseView() {
121 | ImageView imageView = new ImageView(context);
122 | imageView.setImageResource(R.drawable.ic_stat_name);
123 | return imageView;
124 | }
125 | });
126 | return today;
127 | }
128 |
129 | private VrCalendarDay getDay1(final Context context) {
130 | VrCalendarDay today = new VrCalendarDay();
131 | Calendar cal = Calendar.getInstance();
132 | cal.add(Calendar.DAY_OF_MONTH, 5);
133 | today.setDate(cal.getTime());
134 | VrCalendarDaySettings todaySettings = new VrCalendarDaySettings();
135 | todaySettings.setDayTextColor(Color.RED);
136 | today.setVrCalendarDaySettings(todaySettings);
137 | return today;
138 | }
139 |
140 | private VrCalendarDay getDay0(final Context context) {
141 | VrCalendarDay today = new VrCalendarDay();
142 | Calendar cal = Calendar.getInstance();
143 | cal.add(Calendar.DAY_OF_MONTH, 8);
144 | today.setDate(cal.getTime());
145 | VrCalendarDaySettings todaySettings = new VrCalendarDaySettings();
146 | todaySettings.setDayTextColor(Color.WHITE);
147 | todaySettings.setDayTextSize(10);
148 | today.setVrCalendarDaySettings(todaySettings);
149 | return today;
150 | }
151 |
152 | private VrCalendarDay getDay2(final Context context) {
153 | VrCalendarDay today = new VrCalendarDay();
154 |
155 | Calendar cal = Calendar.getInstance();
156 | cal.add(Calendar.DAY_OF_MONTH, 6);
157 | today.setDate(cal.getTime());
158 | VrCalendarDaySettings todaySettings = new VrCalendarDaySettings();
159 | todaySettings.setDayTextColor(Color.GREEN);
160 | todaySettings.setDayBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.background_sample));
161 | today.setVrCalendarDaySettings(todaySettings);
162 | return today;
163 | }
164 |
165 | private VrCalendarDay getDay3(final Context context) {
166 | VrCalendarDay today = new VrCalendarDay();
167 |
168 | Calendar cal = Calendar.getInstance();
169 | cal.add(Calendar.DAY_OF_MONTH, 4);
170 | today.setDate(cal.getTime());
171 | VrCalendarDaySettings todaySettings = new VrCalendarDaySettings();
172 | todaySettings.setDayTextColor(Color.BLUE);
173 | today.setVrCalendarDaySettings(todaySettings);
174 | return today;
175 | }
176 |
177 |
178 | }
179 |
--------------------------------------------------------------------------------
/app/src/main/java/com/vrgsoft/calendarview/CustomView.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendarview;
2 |
3 | import android.content.Context;
4 | import android.widget.RelativeLayout;
5 |
6 | public class CustomView extends RelativeLayout {
7 |
8 | public CustomView(Context context) {
9 | super(context);
10 | init();
11 | }
12 |
13 | private void init() {
14 |
15 | inflate(getContext(), R.layout.custom_view, this);
16 |
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/vrgsoft/calendarview/GlideCalendarExtension.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendarview;
2 |
3 | import com.bumptech.glide.annotation.GlideExtension;
4 | import com.bumptech.glide.load.resource.gif.GifDrawable;
5 | import com.bumptech.glide.request.RequestOptions;
6 |
7 | import static com.bumptech.glide.request.RequestOptions.decodeTypeOf;
8 |
9 | @GlideExtension
10 | public class GlideCalendarExtension {
11 | private GlideCalendarExtension() { }
12 | private static final RequestOptions DECODE_TYPE_GIF = decodeTypeOf(GifDrawable.class).lock();
13 |
14 | // @GlideType(GifDrawable.class)
15 | // public static void asGif(RequestBuilder requestBuilder) {
16 | // requestBuilder
17 | // .transition(new DrawableTransitionOptions())
18 | // .apply(DECODE_TYPE_GIF);
19 | // }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/vrgsoft/calendarview/GlideCalendarModule.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendarview;
2 |
3 | import com.bumptech.glide.annotation.GlideModule;
4 | import com.bumptech.glide.module.AppGlideModule;
5 |
6 | @GlideModule
7 | public class GlideCalendarModule extends AppGlideModule {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/vrgsoft/calendarview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendarview;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.support.v4.content.ContextCompat;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.Toast;
10 |
11 | import com.vrgsoft.calendar.VRCalendarCustomViewCallback;
12 | import com.vrgsoft.calendar.VRCalendarView;
13 | import com.vrgsoft.calendar.VrCalendarDay;
14 | import com.vrgsoft.calendar.VrCalendarDaySettings;
15 | import com.vrgsoft.calendar.calendar_listeners.OnCalendarClickListener;
16 | import com.vrgsoft.calendar.calendar_listeners.OnCalendarLongClickListener;
17 | import com.vrgsoft.calendar.calendar_listeners.VRCalendarMonthCallback;
18 |
19 | import java.text.DateFormat;
20 | import java.text.SimpleDateFormat;
21 | import java.util.Calendar;
22 | import java.util.Date;
23 | import java.util.List;
24 | import java.util.Locale;
25 |
26 | public class MainActivity extends AppCompatActivity implements OnCalendarClickListener, OnCalendarLongClickListener, VRCalendarMonthCallback {
27 |
28 | private VRCalendarView vrCalendarView;
29 | private DateFormat df = new SimpleDateFormat("yyyy-MMMM-dd", Locale.getDefault());
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_main);
35 |
36 | vrCalendarView = findViewById(R.id.calendar);
37 | vrCalendarView.getSettings()
38 | .setOnCalendarClickListener(this)
39 | .setOnCalendarLongClickListener(this)
40 | .setVRCalendarMonthCallback(this);
41 |
42 | findViewById(R.id.prev).setOnClickListener(new View.OnClickListener() {
43 | @Override
44 | public void onClick(View v) {
45 | Calendar calendar = Calendar.getInstance();
46 | calendar.set(Calendar.YEAR, 2019);
47 | calendar.set(Calendar.MONTH, 6);
48 | calendar.set(Calendar.DAY_OF_MONTH, 27);
49 | vrCalendarView.moveToDate(new Date(calendar.getTimeInMillis()));
50 | }
51 | });
52 | findViewById(R.id.next).setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | Calendar calendar = Calendar.getInstance();
56 | calendar.set(Calendar.YEAR, 2015);
57 | calendar.set(Calendar.MONTH, 6);
58 | calendar.set(Calendar.DAY_OF_MONTH, 27);
59 | vrCalendarView.moveToDate(new Date(calendar.getTimeInMillis()));
60 | }
61 | });
62 |
63 | findViewById(R.id.update).setOnClickListener(new View.OnClickListener() {
64 | @Override
65 | public void onClick(View v) {
66 | vrCalendarView.getSettings()
67 | .setOtherMonthTextStyle(VRCalendarView.BOLD)
68 | .setCurrentMonthBackgroundColor(Color.CYAN)
69 | .updateCalendar();
70 | }
71 | });
72 |
73 | vrCalendarView.setDateFormat(df);
74 | vrCalendarView.getDayOfWeekTextView(VRCalendarView.SATURDAY).setTextSize(20);
75 | vrCalendarView.getDayOfWeekTextView(VRCalendarView.SUNDAY).setTextSize(20);
76 | vrCalendarView.getDayOfWeekTextView(VRCalendarView.SATURDAY).setTextColor(Color.RED);
77 | vrCalendarView.getDayOfWeekTextView(VRCalendarView.SUNDAY).setTextColor(Color.RED);
78 | vrCalendarView.weekContainer().setBackgroundColor(ContextCompat.getColor(this, R.color.colorToday));
79 | vrCalendarView.titleContainer().setBackgroundColor(ContextCompat.getColor(this, R.color.colorTitle));
80 | }
81 |
82 | @Override
83 | public void onCalendarDayClick(VrCalendarDay day) {
84 | Toast.makeText(MainActivity.this, " " + df.format(day.getDate()), Toast.LENGTH_SHORT).show();
85 |
86 | VrCalendarDay today = new VrCalendarDay();
87 | today.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
88 | @Override
89 | public View getNewCustomiseView() {
90 | ImageView imageView = new ImageView(MainActivity.this);
91 | imageView.setImageResource(R.drawable.ic_stat_name);
92 | return imageView;
93 | }
94 | });
95 | today.setDate(day.getDate());
96 |
97 | vrCalendarView.getSettings().updateCalendarDay(today, true);
98 |
99 | }
100 |
101 | @Override
102 | public void onCalendarDayLongClick(VrCalendarDay day) {
103 | Toast.makeText(MainActivity.this, "Long " + df.format(day.getDate()), Toast.LENGTH_SHORT).show();
104 |
105 | VrCalendarDay today = new VrCalendarDay();
106 | today.setDate(day.getDate());
107 | VrCalendarDaySettings vrCalendarDaySettings = new VrCalendarDaySettings();
108 | vrCalendarDaySettings.setDayTextStyle(VRCalendarView.BOLD);
109 | vrCalendarDaySettings.setDayTextSize(13);
110 | vrCalendarDaySettings.setDayBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));
111 | vrCalendarDaySettings.setDayTextColor(ContextCompat.getColor(this, R.color.colorToday));
112 | today.setVrCalendarDaySettings(vrCalendarDaySettings);
113 |
114 | vrCalendarView.getSettings().updateCalendarDay(today, false);
115 | }
116 |
117 | @Override
118 | public List getCustomizeDayView(Calendar calendar) {
119 |
120 | CustomDayUtils customDayUtils = new CustomDayUtils();
121 |
122 | return customDayUtils.getCustomizeDayView(this);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-hdpi/ic_next.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_next_button_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-hdpi/ic_next_button_example.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_previous.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-hdpi/ic_previous.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_stat_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-hdpi/ic_stat_name.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-mdpi/ic_next.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_next_button_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-mdpi/ic_next_button_example.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_previous.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-mdpi/ic_previous.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_stat_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-mdpi/ic_stat_name.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xhdpi/ic_next.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_next_button_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xhdpi/ic_next_button_example.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_previous.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xhdpi/ic_previous.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_stat_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xhdpi/ic_stat_name.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/giphy.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xxhdpi/giphy.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xxhdpi/ic_next.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_next_button_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xxhdpi/ic_next_button_example.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_previous.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xxhdpi/ic_previous.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_stat_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xxhdpi/ic_stat_name.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/simple_ex.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/drawable-xxhdpi/simple_ex.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
26 |
27 |
28 |
38 |
39 |
49 |
50 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #00f234
7 | #0ea8ae
8 | #016b70
9 | #ffff00
10 | #000000
11 | #02000000
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CalendarView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | maven {
7 | url 'https://maven.google.com/'
8 | name 'Google'
9 | }
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:2.3.3'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | jcenter()
22 | maven { url 'https://jitpack.io' }
23 | maven {
24 | url 'https://maven.google.com/'
25 | name 'Google'
26 | }
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/calendar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar.jpg
--------------------------------------------------------------------------------
/calendar/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/calendar/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 27
5 | buildToolsVersion "27.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 27
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | compile 'com.android.support:recyclerview-v7:27.0.2'
27 | compile 'com.android.support:support-v4:27.0.2'
28 | compile 'com.android.support:appcompat-v7:27.0.2'
29 | }
30 |
--------------------------------------------------------------------------------
/calendar/calendar.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/calendar/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/calendar/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/CalendarAdapter.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import java.util.List;
9 |
10 | class CalendarAdapter extends RecyclerView.Adapter {
11 |
12 | private List mCells;
13 | private CalendarSettingWrapper mCalendarSettingWrapper;
14 | private VrCalendarDay chosen;
15 |
16 | CalendarAdapter(List mCells, CalendarSettingWrapper calendarSettingWrapper) {
17 | this.mCells = mCells;
18 | mCalendarSettingWrapper = calendarSettingWrapper;
19 | }
20 |
21 | @Override
22 | public VRCalendarHolder onCreateViewHolder(ViewGroup parent, int viewType) {
23 | return new VRCalendarHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_calendar_day, parent, false));
24 | }
25 |
26 | @Override
27 | public void onBindViewHolder(final VRCalendarHolder holder, int position) {
28 | final VrCalendarDay vrCalendarDay = mCells.get(position);
29 |
30 | if (vrCalendarDay.getVRCalendarCustomViewCallback() != null) {
31 | VRCalendarCustomViewCallback vrCalendarCustomViewCallback = vrCalendarDay.getVRCalendarCustomViewCallback();
32 | holder.addCustomView(vrCalendarCustomViewCallback.getNewCustomiseView());
33 | } else {
34 | holder.addCustomView(null);
35 | }
36 | vrCalendarDay.setVRCalendarCustomViewCallback(null);
37 | if (vrCalendarDay.isChoosen()) {
38 | holder.setBackgroundToView(mCalendarSettingWrapper.getChosenBackgroundColor(), mCalendarSettingWrapper.getChosenBackgroundDrawable());
39 | holder.setTextToTextView(mCalendarSettingWrapper.getChosenTextStyle(), mCalendarSettingWrapper.getChosenTextColor(), mCalendarSettingWrapper.getDayTextSize());
40 | } else {
41 | holder.setBackgroundToView(vrCalendarDay.getVrCalendarDaySettings().getDayBackgroundColor(), vrCalendarDay.getVrCalendarDaySettings().getDayBackgroundDrawable());
42 | holder.setTextToTextView(vrCalendarDay.getVrCalendarDaySettings().getDayTextStyle(), vrCalendarDay.getVrCalendarDaySettings().getDayTextColor(), vrCalendarDay.getVrCalendarDaySettings().getDayTextSize());
43 | }
44 | holder.tvDay.setText(String.valueOf(vrCalendarDay.getVrCalendarDaySettings().getDay()));
45 |
46 |
47 | holder.itemView.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | if (mCalendarSettingWrapper.getOnCalendarClickListener() != null) {
51 | mCalendarSettingWrapper.getOnCalendarClickListener().onCalendarDayClick(vrCalendarDay);
52 | }
53 | }
54 | });
55 |
56 | holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
57 | @Override
58 | public boolean onLongClick(View v) {
59 | if (mCalendarSettingWrapper.getOnCalendarLongClickListener() != null) {
60 | mCalendarSettingWrapper.getOnCalendarLongClickListener().onCalendarDayLongClick(vrCalendarDay);
61 | }
62 | return true;
63 | }
64 | });
65 | }
66 |
67 | @Override
68 | public int getItemCount() {
69 | return mCells == null ? 0 : mCells.size();
70 | }
71 |
72 | void updateAll(List cells) {
73 | mCells = cells;
74 | notifyDataSetChanged();
75 | }
76 |
77 | void updateDay(VrCalendarDay day, boolean hasToSelect) {
78 | for (int i = 0; i < mCells.size(); i++) {
79 |
80 | if (chosen != null && VrCalendarUtils.isSameDay(mCells.get(i).getDate(), chosen.getDate())) {
81 | if (hasToSelect) {
82 | mCells.get(i).setChoosen(false);
83 | notifyItemChanged(i);
84 | }
85 | break;
86 | }
87 | }
88 | for (int i = 0; i < mCells.size(); i++) {
89 | if (VrCalendarUtils.isSameDay(mCells.get(i).getDate(), day.getDate())) {
90 | mCells.set(i, day);
91 | if (hasToSelect) {
92 | mCells.get(i).setChoosen(true);
93 | chosen = mCells.get(i);
94 | }
95 | notifyItemChanged(i);
96 | break;
97 | }
98 | }
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/CalendarPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.PagerAdapter;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.LinearLayout;
8 |
9 | import com.vrgsoft.calendar.calendar_listeners.VRCalendarUpdateListener;
10 |
11 | class CalendarPagerAdapter extends PagerAdapter {
12 |
13 | static int MONTH_QUANTITY = 2400;
14 | private Context context;
15 | private int pos = MONTH_QUANTITY / 2;
16 | private CalendarRecyclerView calendarRecyclerView;
17 | private CalendarSettingWrapper mCalendarSettingWrapper;
18 |
19 | CalendarPagerAdapter(Context context, CalendarSettingWrapper calendarSettingWrapper) {
20 | this.context = context;
21 | mCalendarSettingWrapper = calendarSettingWrapper;
22 | }
23 |
24 | @Override
25 | public Object instantiateItem(ViewGroup collection, int position) {
26 | calendarRecyclerView = new CalendarRecyclerView(context, -(pos - position), mCalendarSettingWrapper);
27 | LinearLayout view = calendarRecyclerView;
28 | mCalendarSettingWrapper.addVrCalendarUpdateListener(calendarRecyclerView);
29 | collection.addView(view);
30 | return view;
31 | }
32 |
33 | @Override
34 | public void destroyItem(ViewGroup collection, int position, Object view) {
35 | mCalendarSettingWrapper.removeVrCalendarUpdateListener((VRCalendarUpdateListener) view);
36 | collection.removeView((LinearLayout) view);
37 | }
38 |
39 | @Override
40 | public int getCount() {
41 | return MONTH_QUANTITY;
42 | }
43 |
44 | @Override
45 | public boolean isViewFromObject(View view, Object object) {
46 | return view == object;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/CalendarRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.support.v7.widget.GridLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.LinearLayout;
10 |
11 | import com.vrgsoft.calendar.calendar_listeners.VRCalendarUpdateListener;
12 |
13 | import java.util.ArrayList;
14 | import java.util.Calendar;
15 | import java.util.List;
16 |
17 | @SuppressLint("ViewConstructor")
18 | public class CalendarRecyclerView extends LinearLayout implements VRCalendarUpdateListener {
19 |
20 | private static final int DAYS_COUNT = 42;
21 | private CalendarSettingWrapper mCalendarSettingWrapper;
22 | private CalendarAdapter mAdapter;
23 | private VrCalendarUtils vrCalendarUtils;
24 | private int mPosition;
25 |
26 | public CalendarRecyclerView(Context context, int position, CalendarSettingWrapper calendarSettingWrapper) {
27 | super(context);
28 | mCalendarSettingWrapper = calendarSettingWrapper;
29 | setupViews(position);
30 | }
31 |
32 | private void setupViews(int position) {
33 | vrCalendarUtils = new VrCalendarUtils();
34 | mPosition = position;
35 |
36 | View view = LayoutInflater.from(getContext()).inflate(R.layout.recycler_calendar, this);
37 | RecyclerView calendarRv = view.findViewById(R.id.calendar_recycler);
38 |
39 | mAdapter = new CalendarAdapter(getDays(), mCalendarSettingWrapper);
40 |
41 | calendarRv.setLayoutManager(new GridLayoutManager(getContext(), 7));
42 | calendarRv.setItemAnimator(null);
43 | calendarRv.setAdapter(mAdapter);
44 |
45 | }
46 |
47 | @Override
48 | public void updateItem(VrCalendarDay day, boolean hasToSelect) {
49 | if (mAdapter != null) {
50 | mAdapter.updateDay(vrCalendarUtils.transfer(day, mCalendarSettingWrapper, mPosition), hasToSelect);
51 | }
52 | }
53 |
54 | @Override
55 | public void updateAll() {
56 | if (mAdapter != null) {
57 | mAdapter.updateAll(getDays());
58 | }
59 | }
60 |
61 | private List getDays() {
62 | List cells = new ArrayList<>();
63 | Calendar currentDate = Calendar.getInstance();
64 | currentDate.add(Calendar.MONTH, mPosition);
65 | Calendar calendar = (Calendar) currentDate.clone();
66 |
67 | List customDays = null;
68 | if (mCalendarSettingWrapper.getVRCalendarMonthCallback() != null) {
69 | customDays = mCalendarSettingWrapper.getVRCalendarMonthCallback().getCustomizeDayView(calendar);
70 | }
71 |
72 | // determine the cell for current month's beginning
73 | calendar.set(Calendar.DAY_OF_MONTH, 1);
74 | int monthBeginningCell = calendar.get(Calendar.DAY_OF_WEEK) - 2;
75 | if (monthBeginningCell < 0) {
76 | monthBeginningCell = 6;
77 | }
78 | // move calendar backwards to the beginning of the week
79 | calendar.add(Calendar.DAY_OF_MONTH, -monthBeginningCell);
80 |
81 | // fill cells
82 | while (cells.size() < DAYS_COUNT) {
83 | VrCalendarDay vrCalendarDay = new VrCalendarDay();
84 | vrCalendarDay.setDate(calendar.getTime());
85 | if (customDays != null) {
86 | for (int i = 0; i < customDays.size(); i++) {
87 | if (VrCalendarUtils.isSameDay(customDays.get(i).getDate(), vrCalendarDay.getDate())) {
88 | vrCalendarDay.setVRCalendarCustomViewCallback(customDays.get(i).getVRCalendarCustomViewCallback());
89 | vrCalendarDay.setVrCalendarDaySettings(vrCalendarUtils.getDaySettings(currentDate
90 | , vrCalendarDay.getDate(), mCalendarSettingWrapper, customDays.get(i).getVrCalendarDaySettings()));
91 | break;
92 | }
93 | }
94 | }
95 | if (vrCalendarDay.getVrCalendarDaySettings() == null) {
96 | vrCalendarDay.setVrCalendarDaySettings(vrCalendarUtils.getDaySettings(currentDate
97 | , vrCalendarDay.getDate(), mCalendarSettingWrapper, null));
98 | }
99 |
100 | cells.add(vrCalendarDay);
101 | calendar.add(Calendar.DAY_OF_MONTH, 1);
102 | }
103 | return cells;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/CalendarSettingWrapper.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | import com.vrgsoft.calendar.calendar_listeners.OnCalendarClickListener;
6 | import com.vrgsoft.calendar.calendar_listeners.OnCalendarLongClickListener;
7 | import com.vrgsoft.calendar.calendar_listeners.VRCalendarCustomViewCallback;
8 | import com.vrgsoft.calendar.calendar_listeners.VRCalendarMonthCallback;
9 | import com.vrgsoft.calendar.calendar_listeners.VRCalendarUpdateListener;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class CalendarSettingWrapper {
15 |
16 | private OnCalendarClickListener mOnCalendarClickListener;
17 | private OnCalendarLongClickListener mOnCalendarLongClickListener;
18 | private VRCalendarMonthCallback mVRCalendarMonthCallback;
19 | private VRCalendarCustomViewCallback mVRCalendarCustomViewCallback;
20 | private List mVrCalendarUpdateListeners;
21 |
22 | private int mCurrentDayTextColor;
23 | private int mCurrentMonthTextColor;
24 | private int mOtherMonthTextColor;
25 | private int mCurrentMonthOtherDayTextColor;
26 | private int mCurrentDayBackgroundColor;
27 | private int mCurrentMonthBackgroundColor;
28 | private int mOtherMonthBackgroundColor;
29 | private int mCurrentMonthOtherDayBackgroundColor;
30 | private int mCurrentDayTextStyle;
31 | private int mCurrentMonthTextStyle;
32 | private int mOtherMonthTextStyle;
33 | private int mCurrentMonthOtherDayTextStyle;
34 | private int mChosenTextStyle;
35 | private int mChosenBackgroundColor;
36 | private int mChosenTextColor;
37 | private int mDayTextSize;
38 |
39 | private Drawable mCurrentDayBackgroundDrawable;
40 | private Drawable mCurrentMonthBackgroundDrawable;
41 | private Drawable mOtherMonthBackgroundDrawable;
42 | private Drawable mCurrentMonthOtherDayBackgroundDrawable;
43 | private Drawable mChosenBackgroundDrawable;
44 |
45 | CalendarSettingWrapper(Settings builder) {
46 | mOnCalendarClickListener = builder.getOnCalendarClickListener();
47 | mOnCalendarLongClickListener = builder.getOnCalendarLongClickListener();
48 | mCurrentDayTextColor = builder.getCurrentDayTextColor();
49 | mCurrentMonthTextColor = builder.getCurrentMonthTextColor();
50 | mOtherMonthTextColor = builder.getOtherMonthTextColor();
51 | mCurrentMonthOtherDayTextColor = builder.getCurrentMonthOtherDayTextColor();
52 | mCurrentDayBackgroundColor = builder.getCurrentDayBackgroundColor();
53 | mCurrentMonthBackgroundColor = builder.getCurrentMonthBackgroundColor();
54 | mOtherMonthBackgroundColor = builder.getOtherMonthBackgroundColor();
55 | mCurrentMonthOtherDayBackgroundColor = builder.getCurrentMonthOtherDayBackgroundColor();
56 | mCurrentDayTextStyle = builder.getmCurrentDayTextStyle();
57 | mCurrentMonthTextStyle = builder.getmCurrentMonthTextStyle();
58 | mOtherMonthTextStyle = builder.getmOtherMonthTextStyle();
59 | mCurrentMonthOtherDayTextStyle = builder.getmCurrentMonthOtherDayTextStyle();
60 | mVRCalendarMonthCallback = builder.getmVRCalendarMonthCallback();
61 | mChosenBackgroundColor = builder.getChosenBackgroundColor();
62 | mChosenTextStyle = builder.getChosenTextStyle();
63 | mChosenTextColor = builder.getChosenTextColor();
64 | mCurrentDayBackgroundDrawable = builder.getCurrentDayBackgroundDrawable();
65 | mCurrentMonthBackgroundDrawable = builder.getCurrentMonthBackgroundDrawable();
66 | mOtherMonthBackgroundDrawable = builder.getOtherMonthBackgroundDrawable();
67 | mCurrentMonthOtherDayBackgroundDrawable = builder.getCurrentMonthOtherDayBackgroundDrawable();
68 | mChosenBackgroundDrawable = builder.getChosenBackgroundDrawable();
69 | mDayTextSize = builder.getDayTextSize();
70 | }
71 |
72 | public CalendarSettingWrapper setDayTextSize(int dayTextSize) {
73 | this.mDayTextSize = dayTextSize;
74 | return this;
75 | }
76 |
77 | public VRCalendarCustomViewCallback getVRCalendarCustomViewCallback() {
78 | return mVRCalendarCustomViewCallback;
79 | }
80 |
81 | public CalendarSettingWrapper setVRCalendarCustomViewCallback(VRCalendarCustomViewCallback vrCalendarCustomViewCallback) {
82 | this.mVRCalendarCustomViewCallback = vrCalendarCustomViewCallback;
83 | return this;
84 | }
85 |
86 | public CalendarSettingWrapper setOnCalendarClickListener(OnCalendarClickListener mOnCalendarClickListener) {
87 | this.mOnCalendarClickListener = mOnCalendarClickListener;
88 | return this;
89 | }
90 |
91 | public CalendarSettingWrapper setOnCalendarLongClickListener(OnCalendarLongClickListener mOnCalendarLongClickListener) {
92 | this.mOnCalendarLongClickListener = mOnCalendarLongClickListener;
93 | return this;
94 | }
95 |
96 | void setVrCalendarUpdateListeners(List mVrCalendarUpdateListeners) {
97 | this.mVrCalendarUpdateListeners = mVrCalendarUpdateListeners;
98 | }
99 |
100 | public CalendarSettingWrapper setCurrentDayTextColor(int mCurrentDayTextColor) {
101 | this.mCurrentDayTextColor = mCurrentDayTextColor;
102 | return this;
103 | }
104 |
105 | public CalendarSettingWrapper setCurrentMonthTextColor(int mCurrentMonthTextColor) {
106 | this.mCurrentMonthTextColor = mCurrentMonthTextColor;
107 | return this;
108 | }
109 |
110 | public CalendarSettingWrapper setOtherMonthTextColor(int mOtherMonthTextColor) {
111 | this.mOtherMonthTextColor = mOtherMonthTextColor;
112 | return this;
113 | }
114 |
115 | public CalendarSettingWrapper setCurrentMonthOtherDayTextColor(int mCurrentMonthOtherDayTextColor) {
116 | this.mCurrentMonthOtherDayTextColor = mCurrentMonthOtherDayTextColor;
117 | return this;
118 | }
119 |
120 | public CalendarSettingWrapper setCurrentDayBackgroundColor(int mCurrentDayBackgroundColor) {
121 | this.mCurrentDayBackgroundColor = mCurrentDayBackgroundColor;
122 | return this;
123 | }
124 |
125 | public CalendarSettingWrapper setCurrentMonthBackgroundColor(int mCurrentMonthBackgroundColor) {
126 | this.mCurrentMonthBackgroundColor = mCurrentMonthBackgroundColor;
127 | return this;
128 | }
129 |
130 | public CalendarSettingWrapper setOtherMonthBackgroundColor(int mOtherMonthBackgroundColor) {
131 | this.mOtherMonthBackgroundColor = mOtherMonthBackgroundColor;
132 | return this;
133 | }
134 |
135 | public CalendarSettingWrapper setCurrentMonthOtherDayBackgroundColor(int mCurrentMonthOtherDayBackgroundColor) {
136 | this.mCurrentMonthOtherDayBackgroundColor = mCurrentMonthOtherDayBackgroundColor;
137 | return this;
138 | }
139 |
140 | public CalendarSettingWrapper setCurrentDayTextStyle(int mCurrentDayTextStyle) {
141 |
142 | if (mCurrentDayTextStyle > 2 || mCurrentDayTextStyle < 0)
143 | throw new IllegalArgumentException("CurrentDayTextStyle can be >= 0 or <=2");
144 |
145 | this.mCurrentDayTextStyle = mCurrentDayTextStyle;
146 | return this;
147 | }
148 |
149 | public CalendarSettingWrapper setCurrentMonthTextStyle(int mCurrentMonthTextStyle) {
150 |
151 | if (mCurrentMonthTextStyle > 2 || mCurrentMonthTextStyle < 0)
152 | throw new IllegalArgumentException("CurrentMonthTextStyle can be >= 0 or <=2");
153 |
154 | this.mCurrentMonthTextStyle = mCurrentMonthTextStyle;
155 | return this;
156 | }
157 |
158 | public CalendarSettingWrapper setOtherMonthTextStyle(int mOtherMonthTextStyle) {
159 |
160 | if (mOtherMonthTextStyle > 2 || mOtherMonthTextStyle < 0)
161 | throw new IllegalArgumentException("OtherMonthTextStyle can be >= 0 or <=2");
162 |
163 | this.mOtherMonthTextStyle = mOtherMonthTextStyle;
164 | return this;
165 | }
166 |
167 | public CalendarSettingWrapper setCurrentMonthOtherDayTextStyle(int mCurrentMonthOtherDayTextStyle) {
168 |
169 | if (mCurrentMonthOtherDayTextStyle > 2 || mCurrentMonthOtherDayTextStyle < 0)
170 | throw new IllegalArgumentException("CurrentMonthOtherDayTextStyle can be >= 0 or <=2");
171 |
172 | this.mCurrentMonthOtherDayTextStyle = mCurrentMonthOtherDayTextStyle;
173 | return this;
174 | }
175 |
176 | public CalendarSettingWrapper setChosenBackgroundColor(int mChosenBackgroundColor) {
177 |
178 | this.mChosenBackgroundColor = mChosenBackgroundColor;
179 | return this;
180 | }
181 |
182 | public CalendarSettingWrapper setChosenTextStyle(int mChosenTextStyle) {
183 |
184 | if (mChosenTextStyle > 2 || mChosenTextStyle < 0)
185 | throw new IllegalArgumentException("ChosenTextStyle can be >= 0 or <=2");
186 |
187 | this.mChosenTextStyle = mChosenTextStyle;
188 | return this;
189 | }
190 |
191 | public CalendarSettingWrapper setChosenTextColor(int mChosenTextColor) {
192 | this.mChosenTextColor = mChosenTextColor;
193 | return this;
194 | }
195 |
196 | public CalendarSettingWrapper setCurrentDayBackgroundDrawable(Drawable mCurrentDayBackgroundDrawable) {
197 | this.mCurrentDayBackgroundDrawable = mCurrentDayBackgroundDrawable;
198 | return this;
199 | }
200 |
201 | public CalendarSettingWrapper setCurrentMonthBackgroundDrawable(Drawable mCurrentMonthBackgroundDrawable) {
202 | this.mCurrentMonthBackgroundDrawable = mCurrentMonthBackgroundDrawable;
203 | return this;
204 | }
205 |
206 | public CalendarSettingWrapper setOtherMonthBackgroundDrawable(Drawable mOtherMonthBackgroundDrawable) {
207 | this.mOtherMonthBackgroundDrawable = mOtherMonthBackgroundDrawable;
208 | return this;
209 | }
210 |
211 | public CalendarSettingWrapper setCurrentMonthOtherDayBackgroundDrawable(Drawable mCurrentMonthOtherDayBackgroundDrawable) {
212 | this.mCurrentMonthOtherDayBackgroundDrawable = mCurrentMonthOtherDayBackgroundDrawable;
213 | return this;
214 | }
215 |
216 | public CalendarSettingWrapper setChosenBackgroundDrawable(Drawable mChosenBackgroundDrawable) {
217 | this.mChosenBackgroundDrawable = mChosenBackgroundDrawable;
218 | return this;
219 | }
220 | public int getDayTextSize() {
221 | return mDayTextSize;
222 | }
223 | public Drawable getCurrentDayBackgroundDrawable() {
224 | return mCurrentDayBackgroundDrawable;
225 | }
226 |
227 | public Drawable getCurrentMonthBackgroundDrawable() {
228 | return mCurrentMonthBackgroundDrawable;
229 | }
230 |
231 | public Drawable getOtherMonthBackgroundDrawable() {
232 | return mOtherMonthBackgroundDrawable;
233 | }
234 |
235 | public Drawable getCurrentMonthOtherDayBackgroundDrawable() {
236 | return mCurrentMonthOtherDayBackgroundDrawable;
237 | }
238 |
239 | public Drawable getChosenBackgroundDrawable() {
240 | return mChosenBackgroundDrawable;
241 | }
242 |
243 | public int getChosenBackgroundColor() {
244 | return mChosenBackgroundColor;
245 | }
246 |
247 | public int getChosenTextStyle() {
248 | return mChosenTextStyle;
249 | }
250 |
251 | public int getChosenTextColor() {
252 | return mChosenTextColor;
253 | }
254 |
255 | List getVrCalendarUpdateListener() {
256 | return mVrCalendarUpdateListeners;
257 | }
258 |
259 | void addVrCalendarUpdateListener(VRCalendarUpdateListener mVrCalendarUpdateListener) {
260 | if (mVrCalendarUpdateListeners == null) {
261 | mVrCalendarUpdateListeners = new ArrayList<>();
262 | }
263 | mVrCalendarUpdateListeners.add(mVrCalendarUpdateListener);
264 | }
265 |
266 | void removeVrCalendarUpdateListener(VRCalendarUpdateListener mVrCalendarUpdateListener) {
267 | if (mVrCalendarUpdateListeners != null) {
268 | mVrCalendarUpdateListeners.remove(mVrCalendarUpdateListener);
269 | }
270 | }
271 |
272 | public VRCalendarMonthCallback getVRCalendarMonthCallback() {
273 | return mVRCalendarMonthCallback;
274 | }
275 |
276 | public CalendarSettingWrapper setVRCalendarMonthCallback(VRCalendarMonthCallback callback) {
277 | this.mVRCalendarMonthCallback = callback;
278 | return this;
279 | }
280 |
281 | public void updateCalendarDay(VrCalendarDay day, boolean hasToSelect) {
282 | List listeners = getVrCalendarUpdateListener();
283 | if (listeners != null) {
284 | for (VRCalendarUpdateListener listener : listeners) {
285 | listener.updateItem(day, hasToSelect);
286 | }
287 | }
288 | }
289 |
290 | public void updateCalendar() {
291 | List listeners = getVrCalendarUpdateListener();
292 | if (listeners != null) {
293 | for (VRCalendarUpdateListener listener : listeners) {
294 | listener.updateAll();
295 | }
296 | }
297 | }
298 |
299 |
300 | public int getCurrentDayTextStyle() {
301 | return mCurrentDayTextStyle;
302 | }
303 |
304 |
305 | public int getCurrentMonthTextStyle() {
306 | return mCurrentMonthTextStyle;
307 | }
308 |
309 |
310 | public int getOtherMonthTextStyle() {
311 | return mOtherMonthTextStyle;
312 | }
313 |
314 |
315 | public int getCurrentMonthOtherDayTextStyle() {
316 | return mCurrentMonthOtherDayTextStyle;
317 | }
318 |
319 |
320 | public int getCurrentDayBackgroundColor() {
321 | return mCurrentDayBackgroundColor;
322 | }
323 |
324 |
325 | public int getCurrentMonthBackgroundColor() {
326 | return mCurrentMonthBackgroundColor;
327 | }
328 |
329 |
330 | public int getOtherMonthBackgroundColor() {
331 | return mOtherMonthBackgroundColor;
332 | }
333 |
334 |
335 | public int getCurrentMonthOtherDayBackgroundColor() {
336 | return mCurrentMonthOtherDayBackgroundColor;
337 | }
338 |
339 |
340 | public OnCalendarClickListener getOnCalendarClickListener() {
341 | return mOnCalendarClickListener;
342 | }
343 |
344 |
345 | public OnCalendarLongClickListener getOnCalendarLongClickListener() {
346 | return mOnCalendarLongClickListener;
347 | }
348 |
349 |
350 | public int getCurrentDayTextColor() {
351 | return mCurrentDayTextColor;
352 | }
353 |
354 |
355 | public int getCurrentMonthTextColor() {
356 | return mCurrentMonthTextColor;
357 | }
358 |
359 |
360 | public int getOtherMonthTextColor() {
361 | return mOtherMonthTextColor;
362 | }
363 |
364 |
365 | public int getCurrentMonthOtherDayTextColor() {
366 | return mCurrentMonthOtherDayTextColor;
367 | }
368 |
369 |
370 | }
371 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/DensityUtils.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.util.DisplayMetrics;
6 |
7 | public class DensityUtils {
8 |
9 |
10 | public static float convertDpToPixel(float dp, Context context) {
11 | Resources resources = context.getResources();
12 | DisplayMetrics metrics = resources.getDisplayMetrics();
13 | return dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
14 | }
15 |
16 | public static float convertPixelsToDp(float px, Context context) {
17 | Resources resources = context.getResources();
18 | DisplayMetrics metrics = resources.getDisplayMetrics();
19 | return px / ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/Settings.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | import com.vrgsoft.calendar.calendar_listeners.OnCalendarClickListener;
6 | import com.vrgsoft.calendar.calendar_listeners.OnCalendarLongClickListener;
7 | import com.vrgsoft.calendar.calendar_listeners.VRCalendarMonthCallback;
8 |
9 | import java.text.DateFormat;
10 | import java.text.SimpleDateFormat;
11 | import java.util.Locale;
12 |
13 | public class Settings {
14 | private OnCalendarClickListener mOnCalendarClickListener;
15 | private OnCalendarLongClickListener mOnCalendarLongClickListener;
16 | private VRCalendarMonthCallback mVRCalendarMonthCallback;
17 | private DateFormat mDateFormat = new SimpleDateFormat("yyyy-MMMM", Locale.getDefault());
18 |
19 | private int mCurrentDayTextColor;
20 | private int mCurrentMonthTextColor;
21 | private int mOtherMonthTextColor;
22 | private int mCurrentMonthOtherDayTextColor;
23 | private int mChosenTextColor;
24 |
25 | private int mCurrentDayBackgroundColor;
26 | private int mCurrentMonthBackgroundColor;
27 | private int mOtherMonthBackgroundColor;
28 | private int mCurrentMonthOtherDayBackgroundColor;
29 | private int mChosenBackgroundColor;
30 |
31 | private int mCurrentDayTextStyle;
32 | private int mCurrentMonthTextStyle;
33 | private int mOtherMonthTextStyle;
34 | private int mCurrentMonthOtherDayTextStyle;
35 | private int mChosenTextStyle;
36 |
37 | private Drawable mCurrentDayBackgroundDrawable;
38 | private Drawable mCurrentMonthBackgroundDrawable;
39 | private Drawable mOtherMonthBackgroundDrawable;
40 | private Drawable mCurrentMonthOtherDayBackgroundDrawable;
41 | private Drawable mChosenBackgroundDrawable;
42 |
43 | private int mNextMonthButton;
44 | private int mPreviousMonthButton;
45 |
46 | private int mDayTextSize;
47 | private int mTitleTextSize;
48 |
49 | private int mBackgroundColor;
50 | private int mTitleTextColor;
51 |
52 | private int mDayOfWeeksColor;
53 |
54 | public int getDayOfWeeksColor() {
55 | return mDayOfWeeksColor;
56 | }
57 |
58 | public void setDayOfWeeksColor(int dayOfWeeksColor) {
59 | this.mDayOfWeeksColor = dayOfWeeksColor;
60 | }
61 |
62 | public void setNextMonthButton(int nextMonthButton) {
63 | mNextMonthButton = nextMonthButton;
64 | }
65 |
66 | public void setPreviousMonthButton(int previousMonthButton) {
67 | mPreviousMonthButton = previousMonthButton;
68 | }
69 |
70 | public void setDayTextSize(int dayTextSize) {
71 | mDayTextSize = dayTextSize;
72 | }
73 |
74 | public void setTitleTextSize(int titleTextSize) {
75 | mTitleTextSize = titleTextSize;
76 | }
77 |
78 | public void setBackgroundColor(int backgroundColor) {
79 | mBackgroundColor = backgroundColor;
80 | }
81 |
82 | public void setTitleTextColor(int titleTextColor) {
83 | mTitleTextColor = titleTextColor;
84 | }
85 |
86 | public void setCurrentDayBackgroundDrawable(Drawable currentDayBackgroundDrawable) {
87 | mCurrentDayBackgroundDrawable = currentDayBackgroundDrawable;
88 | }
89 |
90 | public void setCurrentMonthBackgroundDrawable(Drawable currentMonthBackgroundDrawable) {
91 | mCurrentMonthBackgroundDrawable = currentMonthBackgroundDrawable;
92 | }
93 |
94 | public void setOtherMonthBackgroundDrawable(Drawable otherMonthBackgroundDrawable) {
95 | mOtherMonthBackgroundDrawable = otherMonthBackgroundDrawable;
96 | }
97 |
98 | public void setCurrentMonthOtherDayBackgroundDrawable(Drawable currentMonthOtherDayBackgroundDrawable) {
99 | mCurrentMonthOtherDayBackgroundDrawable = currentMonthOtherDayBackgroundDrawable;
100 | }
101 |
102 | public void setChosenBackgroundDrawable(Drawable chosenBackgroundDrawable) {
103 | mChosenBackgroundDrawable = chosenBackgroundDrawable;
104 | }
105 |
106 | public void setChosenBackgroundColor(int chosenBackgroundColor) {
107 | mChosenBackgroundColor = chosenBackgroundColor;
108 | }
109 |
110 | public void setChosenTextStyle(int chosenTextStyle) {
111 | mChosenTextStyle = chosenTextStyle;
112 | }
113 |
114 | public void setChosenTextColor(int chosenTextColor) {
115 | mChosenTextColor = chosenTextColor;
116 | }
117 |
118 | public void setVRCalendarMonthCallback(VRCalendarMonthCallback vrCalendarMonthCallback) {
119 | mVRCalendarMonthCallback = vrCalendarMonthCallback;
120 | }
121 |
122 | public void setCurrentDayTextStyle(int currentDayTextStyle) {
123 | mCurrentDayTextStyle = currentDayTextStyle;
124 | }
125 |
126 | public void setCurrentMonthTextStyle(int currentMonthTextStyle) {
127 | mCurrentMonthTextStyle = currentMonthTextStyle;
128 | }
129 |
130 | public void setOtherMonthTextStyle(int otherMonthTextStyle) {
131 | mOtherMonthTextStyle = otherMonthTextStyle;
132 | }
133 |
134 | public void setCurrentMonthOtherDayTextStyle(int currentMonthOtherDayTextStyle) {
135 | mCurrentMonthOtherDayTextStyle = currentMonthOtherDayTextStyle;
136 | }
137 |
138 | public void setCurrentDayBackgroundColor(int currentDayBackgroundColor) {
139 | mCurrentDayBackgroundColor = currentDayBackgroundColor;
140 | }
141 |
142 | public void setCurrentMonthBackgroundColor(int currentMonthBackgroundColor) {
143 | mCurrentMonthBackgroundColor = currentMonthBackgroundColor;
144 | }
145 |
146 | public void setOtherMonthBackgroundColor(int otherMonthBackgroundColor) {
147 | mOtherMonthBackgroundColor = otherMonthBackgroundColor;
148 | }
149 |
150 | public void setCurrentMonthOtherDayBackgroundColor(int currentMonthOtherDayBackgroundColor) {
151 | mCurrentMonthOtherDayBackgroundColor = currentMonthOtherDayBackgroundColor;
152 | }
153 |
154 | public void setOnCalendarClickListener(OnCalendarClickListener onCalendarClickListener) {
155 | this.mOnCalendarClickListener = onCalendarClickListener;
156 | }
157 |
158 | public void setOnCalendarLongClickListener(OnCalendarLongClickListener onCalendarLongClickListener) {
159 | this.mOnCalendarLongClickListener = onCalendarLongClickListener;
160 | }
161 |
162 | public void setDateFormat(DateFormat dateFormat) {
163 | this.mDateFormat = dateFormat;
164 | }
165 |
166 | public void setCurrentDayTextColor(int currentDayTextColor) {
167 | mCurrentDayTextColor = currentDayTextColor;
168 | }
169 |
170 | public void setCurrentMonthTextColor(int currentMonthTextColor) {
171 | mCurrentMonthTextColor = currentMonthTextColor;
172 | }
173 |
174 | public void setOtherMonthTextColor(int otherMonthTextColor) {
175 | mOtherMonthTextColor = otherMonthTextColor;
176 | }
177 |
178 | public void setCurrentMonthOtherDayTextColor(int currentMonthOtherDayTextColor) {
179 | mCurrentMonthOtherDayTextColor = currentMonthOtherDayTextColor;
180 | }
181 |
182 | int getNextMonthButton() {
183 | return mNextMonthButton;
184 | }
185 |
186 | int getPreviousMonthButton() {
187 | return mPreviousMonthButton;
188 | }
189 |
190 | int getDayTextSize() {
191 | return mDayTextSize;
192 | }
193 |
194 | int getTitleTextSize() {
195 | return mTitleTextSize;
196 | }
197 |
198 | int getBackgroundColor() {
199 | return mBackgroundColor;
200 | }
201 |
202 | int getTitleTextColor() {
203 | return mTitleTextColor;
204 | }
205 |
206 | Drawable getCurrentDayBackgroundDrawable() {
207 | return mCurrentDayBackgroundDrawable;
208 | }
209 |
210 | Drawable getCurrentMonthBackgroundDrawable() {
211 | return mCurrentMonthBackgroundDrawable;
212 | }
213 |
214 | Drawable getOtherMonthBackgroundDrawable() {
215 | return mOtherMonthBackgroundDrawable;
216 | }
217 |
218 | Drawable getCurrentMonthOtherDayBackgroundDrawable() {
219 | return mCurrentMonthOtherDayBackgroundDrawable;
220 | }
221 |
222 | Drawable getChosenBackgroundDrawable() {
223 | return mChosenBackgroundDrawable;
224 | }
225 |
226 | int getChosenBackgroundColor() {
227 | return mChosenBackgroundColor;
228 | }
229 |
230 | int getChosenTextStyle() {
231 | return mChosenTextStyle;
232 | }
233 |
234 | int getChosenTextColor() {
235 | return mChosenTextColor;
236 | }
237 |
238 | VRCalendarMonthCallback getmVRCalendarMonthCallback() {
239 | return mVRCalendarMonthCallback;
240 | }
241 |
242 | int getmCurrentDayTextStyle() {
243 | return mCurrentDayTextStyle;
244 | }
245 |
246 | int getmCurrentMonthTextStyle() {
247 | return mCurrentMonthTextStyle;
248 | }
249 |
250 | int getmOtherMonthTextStyle() {
251 | return mOtherMonthTextStyle;
252 | }
253 |
254 | int getmCurrentMonthOtherDayTextStyle() {
255 | return mCurrentMonthOtherDayTextStyle;
256 | }
257 |
258 | int getCurrentDayBackgroundColor() {
259 | return mCurrentDayBackgroundColor;
260 | }
261 |
262 | int getCurrentMonthBackgroundColor() {
263 | return mCurrentMonthBackgroundColor;
264 | }
265 |
266 | int getOtherMonthBackgroundColor() {
267 | return mOtherMonthBackgroundColor;
268 | }
269 |
270 | int getCurrentMonthOtherDayBackgroundColor() {
271 | return mCurrentMonthOtherDayBackgroundColor;
272 | }
273 |
274 | OnCalendarClickListener getOnCalendarClickListener() {
275 | return mOnCalendarClickListener;
276 | }
277 |
278 | OnCalendarLongClickListener getOnCalendarLongClickListener() {
279 | return mOnCalendarLongClickListener;
280 | }
281 |
282 | DateFormat getDateFormat() {
283 | return mDateFormat;
284 | }
285 |
286 | int getCurrentDayTextColor() {
287 | return mCurrentDayTextColor;
288 | }
289 |
290 | int getCurrentMonthTextColor() {
291 | return mCurrentMonthTextColor;
292 | }
293 |
294 | int getOtherMonthTextColor() {
295 | return mOtherMonthTextColor;
296 | }
297 |
298 | int getCurrentMonthOtherDayTextColor() {
299 | return mCurrentMonthOtherDayTextColor;
300 | }
301 | }
302 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/VRCalendarCustomViewCallback.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.view.View;
4 |
5 | public interface VRCalendarCustomViewCallback {
6 |
7 | View getNewCustomiseView();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/VRCalendarHolder.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.graphics.drawable.Drawable;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.FrameLayout;
8 | import android.widget.TextView;
9 |
10 | class VRCalendarHolder extends RecyclerView.ViewHolder {
11 |
12 | TextView tvDay;
13 | View vBackground;
14 | FrameLayout vCustomBack;
15 |
16 | VRCalendarHolder(View itemView) {
17 | super(itemView);
18 | tvDay = itemView.findViewById(R.id.tv_day);
19 | vBackground = itemView.findViewById(R.id.vBackground);
20 | vCustomBack = itemView.findViewById(R.id.vCustomBack);
21 |
22 | }
23 |
24 | void setTextToTextView(int style, int color, int textSize) {
25 | tvDay.setTypeface(null, style);
26 | tvDay.setTextColor(color);
27 | tvDay.setTextSize(textSize);
28 | }
29 |
30 | void setBackgroundToView(int color, Drawable drawable) {
31 | itemView.setBackgroundColor(color);
32 | vBackground.setBackground(drawable);
33 | }
34 |
35 |
36 | void addCustomView(View newCustomiseView) {
37 | if (newCustomiseView != null) {
38 | ViewGroup viewGroup = (ViewGroup) newCustomiseView.getParent();
39 | if (viewGroup != null) {
40 | viewGroup.removeView(newCustomiseView);
41 | }
42 | vCustomBack.addView(newCustomiseView);
43 | } else {
44 | vCustomBack.removeAllViews();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/VRCalendarView.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.content.ContextCompat;
8 | import android.support.v4.view.ViewPager;
9 | import android.util.AttributeSet;
10 | import android.view.View;
11 | import android.widget.ImageButton;
12 | import android.widget.LinearLayout;
13 | import android.widget.TextView;
14 |
15 | import java.text.DateFormat;
16 | import java.text.SimpleDateFormat;
17 | import java.util.Calendar;
18 | import java.util.Date;
19 | import java.util.Locale;
20 |
21 | public class VRCalendarView extends LinearLayout {
22 |
23 | public static final int NORMAL = 0;
24 | public static final int BOLD = 1;
25 | public static final int ITALIC = 2;
26 |
27 | public static final int MONDAY = 0;
28 | public static final int TUESDAY = 1;
29 | public static final int WEDNESDAY = 2;
30 | public static final int THURSDAY = 3;
31 | public static final int FRIDAY = 4;
32 | public static final int SATURDAY = 5;
33 | public static final int SUNDAY = 6;
34 |
35 | private CalendarPagerAdapter mCalendarPagerAdapter;
36 | private ViewPager viewPager;
37 | private DateFormat df = new SimpleDateFormat("yyyy-MMMM", Locale.getDefault());
38 | private TextView tvCalendarDate;
39 | private Context mContext;
40 | private ImageButton mPrevious;
41 | private ImageButton mNext;
42 | private CalendarSettingWrapper mCalendarSettingWrapper;
43 | private TextView[] mTvWeekDays;
44 |
45 | public VRCalendarView(Context context) {
46 | super(context);
47 | mContext = context;
48 | }
49 |
50 | public VRCalendarView(Context context, @Nullable AttributeSet attrs) {
51 | super(context, attrs);
52 | mContext = context;
53 | initAttributes(attrs);
54 | }
55 |
56 | public VRCalendarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
57 | super(context, attrs, defStyleAttr);
58 | mContext = context;
59 | initAttributes(attrs);
60 | }
61 |
62 | private void initAttributes(AttributeSet attributeSet) {
63 | TypedArray typedArray = mContext.getTheme().obtainStyledAttributes(attributeSet
64 | , R.styleable.VRCalendarView, 0, 0);
65 | Settings settings;
66 | try {
67 | int color = ContextCompat.getColor(mContext, R.color.colorText);
68 | settings = new com.vrgsoft.calendar.Settings();
69 | settings.setCurrentDayTextColor(typedArray.getColor(R.styleable.VRCalendarView_vr_current_day_text_color, color));
70 | settings.setCurrentMonthOtherDayTextColor(typedArray.getColor(R.styleable.VRCalendarView_vr_current_month_other_days_text_color, color));
71 | settings.setCurrentMonthTextColor(typedArray.getColor(R.styleable.VRCalendarView_vr_current_month_text_color, color));
72 | settings.setOtherMonthTextColor(typedArray.getColor(R.styleable.VRCalendarView_vr_other_month_text_color, color));
73 | settings.setChosenTextColor(typedArray.getColor(R.styleable.VRCalendarView_vr_chosen_day_text_color, Color.WHITE));
74 |
75 | color = ContextCompat.getColor(mContext, R.color.colorBackGround);
76 | settings.setCurrentDayBackgroundColor(typedArray.getColor(R.styleable.VRCalendarView_vr_current_day_background_color, color));
77 | settings.setCurrentMonthOtherDayBackgroundColor(typedArray.getColor(R.styleable.VRCalendarView_vr_current_month_other_days_background_color, color));
78 | settings.setCurrentMonthBackgroundColor(typedArray.getColor(R.styleable.VRCalendarView_vr_current_month_background_color, color));
79 | settings.setOtherMonthBackgroundColor(typedArray.getColor(R.styleable.VRCalendarView_vr_other_month_background_color, color));
80 | settings.setChosenBackgroundColor(typedArray.getColor(R.styleable.VRCalendarView_vr_chosen_day_background_color, ContextCompat.getColor(mContext, R.color.colorText)));
81 |
82 | settings.setCurrentDayTextStyle(typedArray.getInt(R.styleable.VRCalendarView_vr_current_day_text_style, BOLD));
83 | settings.setCurrentMonthOtherDayTextStyle(typedArray.getInt(R.styleable.VRCalendarView_vr_current_month_other_days_text_style, NORMAL));
84 | settings.setCurrentMonthTextStyle(typedArray.getInt(R.styleable.VRCalendarView_vr_current_month_text_style, NORMAL));
85 | settings.setOtherMonthTextStyle(typedArray.getInt(R.styleable.VRCalendarView_vr_other_month_text_style, NORMAL));
86 | settings.setChosenTextStyle(typedArray.getInt(R.styleable.VRCalendarView_vr_chosen_day_text_style, NORMAL));
87 |
88 | int currentDayBackgroundDrawable = typedArray.getResourceId(R.styleable.VRCalendarView_vr_current_day_background_drawable, -1);
89 | if (currentDayBackgroundDrawable > 0) {
90 | settings.setCurrentDayBackgroundDrawable(ContextCompat.getDrawable(getContext(), currentDayBackgroundDrawable));
91 | }
92 | int currentMonthBackgroundDrawable = typedArray.getResourceId(R.styleable.VRCalendarView_vr_current_month_background_drawable, -1);
93 | if (currentMonthBackgroundDrawable > 0) {
94 | settings.setCurrentMonthBackgroundDrawable(ContextCompat.getDrawable(getContext(), currentMonthBackgroundDrawable));
95 | }
96 | int otherMonthBackgroundDrawable = typedArray.getResourceId(R.styleable.VRCalendarView_vr_other_month_background_drawable, -1);
97 | if (otherMonthBackgroundDrawable > 0) {
98 | settings.setOtherMonthBackgroundDrawable(ContextCompat.getDrawable(getContext(), otherMonthBackgroundDrawable));
99 | }
100 | int currentMonthOtherDayBackgroundDrawable = typedArray.getResourceId(R.styleable.VRCalendarView_vr_current_month_other_days_background_drawable, -1);
101 | if (currentMonthOtherDayBackgroundDrawable > 0) {
102 | settings.setCurrentMonthOtherDayBackgroundDrawable(ContextCompat.getDrawable(getContext(), currentMonthOtherDayBackgroundDrawable));
103 | }
104 | int chosenBackgroundDrawable = typedArray.getResourceId(R.styleable.VRCalendarView_vr_chosen_day_background_drawable, -1);
105 | if (chosenBackgroundDrawable > 0) {
106 | settings.setChosenBackgroundDrawable(ContextCompat.getDrawable(getContext(), chosenBackgroundDrawable));
107 | }
108 | settings.setNextMonthButton(typedArray.getResourceId(R.styleable.VRCalendarView_vr_next_button, -1));
109 | settings.setPreviousMonthButton(typedArray.getResourceId(R.styleable.VRCalendarView_vr_previous_button, -1));
110 |
111 | int dayTextSize = typedArray.getDimensionPixelSize(R.styleable.VRCalendarView_vr_calendar_day_text_size, -1);
112 | settings.setDayTextSize(dayTextSize != -1 ? (int) DensityUtils.convertPixelsToDp(dayTextSize, getContext()) : 14);
113 | settings.setTitleTextSize(typedArray.getDimensionPixelSize(R.styleable.VRCalendarView_vr_calendar_title_text_size, 14));
114 |
115 | settings.setBackgroundColor(typedArray.getColor(R.styleable.VRCalendarView_vr_background_color, Color.BLACK));
116 | settings.setTitleTextColor(typedArray.getColor(R.styleable.VRCalendarView_vr_title_text_color, Color.BLACK));
117 | settings.setDayOfWeeksColor(typedArray.getColor(R.styleable.VRCalendarView_vr_week_days_color, Color.BLACK));
118 |
119 | } finally {
120 | typedArray.recycle();
121 | }
122 | setupViews(settings);
123 | }
124 |
125 | public void moveToDate(Date date) {
126 | Calendar currentDate = Calendar.getInstance();
127 | Calendar moveTo = Calendar.getInstance();
128 | moveTo.setTimeInMillis(date.getTime());
129 | int scrollTo = 0;
130 | if (currentDate.getTimeInMillis() > moveTo.getTimeInMillis()) {
131 | while (true) {
132 | scrollTo--;
133 | currentDate.add(Calendar.MONTH, -1);
134 | if (currentDate.get(Calendar.YEAR) == moveTo.get(Calendar.YEAR) && currentDate.get(Calendar.MONTH) == moveTo.get(Calendar.MONTH)) {
135 | break;
136 | }
137 | }
138 | } else if (currentDate.getTimeInMillis() < moveTo.getTimeInMillis()) {
139 | while (true) {
140 | scrollTo++;
141 | currentDate.add(Calendar.MONTH, 1);
142 | if (currentDate.get(Calendar.YEAR) == moveTo.get(Calendar.YEAR) && currentDate.get(Calendar.MONTH) == moveTo.get(Calendar.MONTH)) {
143 | break;
144 | }
145 | }
146 | }
147 | int pos = (CalendarPagerAdapter.MONTH_QUANTITY / 2 + scrollTo);
148 | viewPager.setCurrentItem(pos);
149 | }
150 |
151 | public void setDateFormat(DateFormat dateFormat) {
152 | df = dateFormat;
153 | handleDateFormate();
154 | }
155 |
156 | public CalendarSettingWrapper getSettings() {
157 | return mCalendarSettingWrapper;
158 | }
159 |
160 | public ImageButton getNextMonthImageButton() {
161 | return mNext;
162 | }
163 |
164 | public ImageButton getPreviousMonthImageButton() {
165 | return mPrevious;
166 | }
167 |
168 | public TextView getTitleCalendarDate() {
169 | return tvCalendarDate;
170 | }
171 |
172 | public View titleContainer() {
173 | return findViewById(R.id.rBarTitle);
174 | }
175 |
176 | public View weekContainer() {
177 | return findViewById(R.id.calendar_days);
178 | }
179 |
180 | public TextView getDayOfWeekTextView(int dayOfWeek) {
181 | return mTvWeekDays[dayOfWeek];
182 | }
183 |
184 | public View getCalendarContainerView() {
185 | return findViewById(R.id.container);
186 | }
187 |
188 | private void setupViews(Settings settings) {
189 | setClickable(true);
190 | inflate(mContext, R.layout.calendar_view, this);
191 | tvCalendarDate = findViewById(R.id.tv_calendar_date);
192 | viewPager = findViewById(R.id.view_pager);
193 | mPrevious = findViewById(R.id.calendar_prev_month);
194 | mTvWeekDays = new TextView[]{findViewById(R.id.tvMonday)
195 | , findViewById(R.id.tvTuesday)
196 | , findViewById(R.id.tvWednesday)
197 | , findViewById(R.id.tvThursday)
198 | , findViewById(R.id.tvFriday)
199 | , findViewById(R.id.tvSaturday)
200 | , findViewById(R.id.tvSunday)};
201 | for (TextView textView : mTvWeekDays) {
202 | textView.setTextColor(settings.getDayOfWeeksColor());
203 | }
204 | findViewById(R.id.container).setBackgroundColor(settings.getBackgroundColor());
205 | mPrevious.setOnClickListener(new OnClickListener() {
206 | @Override
207 | public void onClick(View v) {
208 | viewPager.setCurrentItem(viewPager.getCurrentItem() - 1);
209 | }
210 | });
211 | mNext = findViewById(R.id.calendar_next_month);
212 | mNext.setOnClickListener(new OnClickListener() {
213 | @Override
214 | public void onClick(View v) {
215 | viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
216 | }
217 | });
218 | if (settings.getNextMonthButton() != -1) {
219 | mNext.setImageResource(settings.getNextMonthButton());
220 | }
221 | if (settings.getPreviousMonthButton() != -1) {
222 | mPrevious.setImageResource(settings.getPreviousMonthButton());
223 | }
224 |
225 | tvCalendarDate.setTextColor(settings.getTitleTextColor());
226 | tvCalendarDate.setTextSize(settings.getTitleTextSize());
227 | Date date = new Date();
228 |
229 | tvCalendarDate.setText(df.format(date.getTime()));
230 |
231 | mCalendarSettingWrapper = new CalendarSettingWrapper(settings);
232 |
233 | mCalendarPagerAdapter = new CalendarPagerAdapter(mContext, mCalendarSettingWrapper);
234 | viewPager.setAdapter(mCalendarPagerAdapter);
235 | viewPager.setCurrentItem(CalendarPagerAdapter.MONTH_QUANTITY / 2);
236 | viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
237 | @Override
238 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
239 | }
240 |
241 | @Override
242 | public void onPageSelected(int position) {
243 | handleDateFormate();
244 | }
245 |
246 | @Override
247 | public void onPageScrollStateChanged(int state) {
248 | }
249 | });
250 | df = settings.getDateFormat();
251 | }
252 |
253 | private void handleDateFormate() {
254 | Calendar currentDate = Calendar.getInstance();
255 | currentDate.add(Calendar.MONTH, -(CalendarPagerAdapter.MONTH_QUANTITY / 2 - viewPager.getCurrentItem()));
256 | tvCalendarDate.setText(df.format(currentDate.getTimeInMillis()));
257 | }
258 |
259 | }
260 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/VrCalendarDay.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import java.util.Date;
4 |
5 | public class VrCalendarDay {
6 |
7 | private VRCalendarCustomViewCallback customViewCallback;
8 | private Date date;
9 | private VrCalendarDaySettings vrCalendarDaySettings;
10 | private boolean isChoosen;
11 |
12 | boolean isChoosen() {
13 | return isChoosen;
14 | }
15 |
16 | void setChoosen(boolean choosen) {
17 | isChoosen = choosen;
18 | }
19 |
20 | public VrCalendarDaySettings getVrCalendarDaySettings() {
21 | return vrCalendarDaySettings;
22 | }
23 |
24 | public void setVrCalendarDaySettings(VrCalendarDaySettings vrCalendarDaySettings) {
25 | this.vrCalendarDaySettings = vrCalendarDaySettings;
26 | }
27 |
28 | public VRCalendarCustomViewCallback getVRCalendarCustomViewCallback() {
29 | return customViewCallback;
30 | }
31 |
32 | public void setVRCalendarCustomViewCallback(VRCalendarCustomViewCallback callback) {
33 | this.customViewCallback = callback;
34 | }
35 |
36 | public Date getDate() {
37 | return date;
38 | }
39 |
40 | public void setDate(Date date) {
41 | this.date = date;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/VrCalendarDaySettings.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | public class VrCalendarDaySettings {
6 |
7 | private int mDayTextColor;
8 | private int mDayBackgroundColor;
9 | private Drawable mDayBackgroundDrawable;
10 | private int mDayTextStyle;
11 | private int mDayTextSize;
12 | private int day;
13 |
14 | public VrCalendarDaySettings() {
15 | }
16 |
17 | public int getDayTextSize() {
18 | return mDayTextSize;
19 | }
20 |
21 | public void setDayTextSize(int mDayTextSize) {
22 | this.mDayTextSize = mDayTextSize;
23 | }
24 |
25 | public Drawable getDayBackgroundDrawable() {
26 | return mDayBackgroundDrawable;
27 | }
28 |
29 | public void setDayBackgroundDrawable(Drawable mDayBackgroundDrawable) {
30 | this.mDayBackgroundDrawable = mDayBackgroundDrawable;
31 | }
32 |
33 | public int getDay() {
34 | return day;
35 | }
36 |
37 | public void setDay(int day) {
38 | this.day = day;
39 | }
40 |
41 | public int getDayTextColor() {
42 | return mDayTextColor;
43 | }
44 |
45 | public void setDayTextColor(int mDayTextColor) {
46 | this.mDayTextColor = mDayTextColor;
47 | }
48 |
49 | public int getDayBackgroundColor() {
50 | return mDayBackgroundColor;
51 | }
52 |
53 | public void setDayBackgroundColor(int mDayBackgroundColor) {
54 | this.mDayBackgroundColor = mDayBackgroundColor;
55 | }
56 |
57 | public int getDayTextStyle() {
58 | return mDayTextStyle;
59 | }
60 |
61 | public void setDayTextStyle(int mDayTextStyle) {
62 | this.mDayTextStyle = mDayTextStyle;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/VrCalendarUtils.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | import java.util.Calendar;
6 | import java.util.Date;
7 |
8 | class VrCalendarUtils {
9 |
10 | private Calendar calendar = Calendar.getInstance();
11 | private Calendar calendarToday = Calendar.getInstance();
12 |
13 | VrCalendarDaySettings getDaySettings(Calendar calendarMonth, Date date, CalendarSettingWrapper mCalendarSettingWrapper, VrCalendarDaySettings customSettings) {
14 | VrCalendarDaySettings vrCalendarDaySettings = new VrCalendarDaySettings();
15 | Date today = new Date();
16 |
17 | calendar.setTimeInMillis(date.getTime());
18 | calendarToday.setTimeInMillis(today.getTime());
19 |
20 | if (customSettings == null) {
21 | customSettings = new VrCalendarDaySettings();
22 | }
23 |
24 | if (calendar.get(Calendar.MONTH) == calendarToday.get(Calendar.MONTH) &&
25 | calendar.get(Calendar.YEAR) == calendarToday.get(Calendar.YEAR) &&
26 | calendar.get(Calendar.DAY_OF_MONTH) != calendarToday.get(Calendar.DAY_OF_MONTH)) {
27 | setSettings(vrCalendarDaySettings, customSettings
28 | , mCalendarSettingWrapper.getCurrentMonthTextStyle()
29 | , mCalendarSettingWrapper.getCurrentMonthBackgroundColor()
30 | , mCalendarSettingWrapper.getCurrentMonthTextColor()
31 | , mCalendarSettingWrapper.getCurrentMonthBackgroundDrawable());
32 | } else if (calendar.get(Calendar.MONTH) == calendarToday.get(Calendar.MONTH) &&
33 | calendar.get(Calendar.YEAR) == calendarToday.get(Calendar.YEAR) &&
34 | calendar.get(Calendar.DAY_OF_MONTH) == calendarToday.get(Calendar.DAY_OF_MONTH)) {
35 | setSettings(vrCalendarDaySettings, customSettings
36 | , mCalendarSettingWrapper.getCurrentDayTextStyle()
37 | , mCalendarSettingWrapper.getCurrentDayBackgroundColor()
38 | , mCalendarSettingWrapper.getCurrentDayTextColor()
39 | , mCalendarSettingWrapper.getCurrentDayBackgroundDrawable());
40 | } else if (calendar.get(Calendar.MONTH) != calendarToday.get(Calendar.MONTH) ||
41 | calendar.get(Calendar.YEAR) != calendarToday.get(Calendar.YEAR)) {
42 |
43 | if (calendarMonth != null && calendarMonth.get(Calendar.MONTH) == calendar.get(Calendar.MONTH)) {
44 | setSettings(vrCalendarDaySettings, customSettings
45 | , mCalendarSettingWrapper.getOtherMonthTextStyle()
46 | , mCalendarSettingWrapper.getOtherMonthBackgroundColor()
47 | , mCalendarSettingWrapper.getOtherMonthTextColor()
48 | , mCalendarSettingWrapper.getOtherMonthBackgroundDrawable());
49 | } else {
50 | setSettings(vrCalendarDaySettings, customSettings
51 | , mCalendarSettingWrapper.getCurrentMonthOtherDayTextStyle()
52 | , mCalendarSettingWrapper.getCurrentMonthOtherDayBackgroundColor()
53 | , mCalendarSettingWrapper.getCurrentMonthOtherDayTextColor()
54 | , mCalendarSettingWrapper.getCurrentMonthOtherDayBackgroundDrawable());
55 | }
56 | }
57 |
58 | vrCalendarDaySettings.setDay(calendar.get(Calendar.DAY_OF_MONTH));
59 | vrCalendarDaySettings.setDayTextSize(customSettings.getDayTextSize() == 0 ? mCalendarSettingWrapper.getDayTextSize() : customSettings.getDayTextSize());
60 |
61 | return vrCalendarDaySettings;
62 | }
63 |
64 | VrCalendarDay transfer(final VrCalendarDay day, CalendarSettingWrapper calendarSettingWrapper, int position) {
65 | Calendar currentDate = Calendar.getInstance();
66 | currentDate.add(Calendar.MONTH, position);
67 | VrCalendarDay vrCalendarDay = new VrCalendarDay();
68 | vrCalendarDay.setChoosen(day.isChoosen());
69 | vrCalendarDay.setDate(day.getDate());
70 | // VRCalendarCustomViewCallback calendarCustomViewCallback = new VRCalendarCustomViewCallback() {
71 | // @Override
72 | // public View getNewCustomiseView() {
73 | // return day.getVRCalendarCustomViewCallback().getNewCustomiseView();
74 | // }
75 | // };
76 | vrCalendarDay.setVRCalendarCustomViewCallback(day.getVRCalendarCustomViewCallback());
77 | vrCalendarDay.setVrCalendarDaySettings(getDaySettings(currentDate
78 | , vrCalendarDay.getDate(), calendarSettingWrapper, day.getVrCalendarDaySettings()));
79 | return vrCalendarDay;
80 | }
81 |
82 | private void setSettings(VrCalendarDaySettings settings, VrCalendarDaySettings customSettings, int style, int background, int text, Drawable backgroundDrawable) {
83 | settings.setDayBackgroundColor(customSettings.getDayBackgroundColor() == 0
84 | ? background : customSettings.getDayBackgroundColor());
85 | settings.setDayTextColor(customSettings.getDayTextColor() == 0
86 | ? text : customSettings.getDayTextColor());
87 | settings.setDayTextStyle(customSettings.getDayTextStyle() == 0
88 | ? style : customSettings.getDayTextStyle());
89 | settings.setDayBackgroundDrawable(customSettings.getDayBackgroundDrawable() == null
90 | ? backgroundDrawable : customSettings.getDayBackgroundDrawable());
91 | }
92 |
93 | static boolean isSameDay(Date myDate1, Date myDate2) {
94 | Calendar calendar1 = Calendar.getInstance();
95 | Calendar calendar2 = Calendar.getInstance();
96 | calendar1.setTime(myDate1);
97 | calendar2.setTime(myDate2);
98 |
99 | return (calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) &&
100 | calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) &&
101 | calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH));
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/WrapContentHeightViewPager.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 |
8 | public class WrapContentHeightViewPager extends ViewPager {
9 |
10 | public WrapContentHeightViewPager(Context context) {
11 | super(context);
12 | }
13 |
14 | public WrapContentHeightViewPager(Context context, AttributeSet attrs) {
15 | super(context, attrs);
16 | }
17 |
18 | @Override
19 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
20 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
21 |
22 | // find the first child view
23 | View view = getChildAt(0);
24 | if (view != null) {
25 | // measure the first child view with the specified measure spec
26 | view.measure(widthMeasureSpec, heightMeasureSpec);
27 | }
28 |
29 | setMeasuredDimension(getMeasuredWidth(), measureHeight(heightMeasureSpec, view));
30 | }
31 |
32 | private int measureHeight(int measureSpec, View view) {
33 | int result = 0;
34 | int specMode = MeasureSpec.getMode(measureSpec);
35 | int specSize = MeasureSpec.getSize(measureSpec);
36 |
37 | if (specMode == MeasureSpec.EXACTLY) {
38 | result = specSize;
39 | } else {
40 | // set the height from the base view if available
41 | if (view != null) {
42 | result = view.getMeasuredHeight();
43 | }
44 | if (specMode == MeasureSpec.AT_MOST) {
45 | result = Math.min(result, specSize);
46 | }
47 | }
48 | return result;
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/calendar_listeners/OnCalendarClickListener.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar.calendar_listeners;
2 |
3 | import com.vrgsoft.calendar.VrCalendarDay;
4 |
5 | public interface OnCalendarClickListener {
6 | void onCalendarDayClick(VrCalendarDay day);
7 | }
8 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/calendar_listeners/OnCalendarLongClickListener.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar.calendar_listeners;
2 |
3 | import com.vrgsoft.calendar.VrCalendarDay;
4 |
5 | public interface OnCalendarLongClickListener {
6 | void onCalendarDayLongClick(VrCalendarDay day);
7 | }
8 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/calendar_listeners/VRCalendarCustomViewCallback.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar.calendar_listeners;
2 |
3 | import android.view.View;
4 |
5 | import com.vrgsoft.calendar.VrCalendarDay;
6 |
7 | public interface VRCalendarCustomViewCallback {
8 |
9 | View getCustomView(VrCalendarDay day);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/calendar_listeners/VRCalendarMonthCallback.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar.calendar_listeners;
2 |
3 | import com.vrgsoft.calendar.VrCalendarDay;
4 |
5 | import java.util.Calendar;
6 | import java.util.List;
7 |
8 | public interface VRCalendarMonthCallback {
9 |
10 | List getCustomizeDayView(Calendar calendar);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/calendar/src/main/java/com/vrgsoft/calendar/calendar_listeners/VRCalendarUpdateListener.java:
--------------------------------------------------------------------------------
1 | package com.vrgsoft.calendar.calendar_listeners;
2 |
3 | import com.vrgsoft.calendar.VrCalendarDay;
4 |
5 | public interface VRCalendarUpdateListener {
6 |
7 | void updateItem(VrCalendarDay day, boolean hasToSelect);
8 | void updateAll();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-hdpi/ic_keyboard_arrow_left_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-hdpi/ic_keyboard_arrow_left_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-hdpi/ic_keyboard_arrow_right_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-hdpi/ic_keyboard_arrow_right_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-mdpi/ic_keyboard_arrow_left_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-mdpi/ic_keyboard_arrow_left_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-mdpi/ic_keyboard_arrow_right_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-mdpi/ic_keyboard_arrow_right_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-xhdpi/ic_keyboard_arrow_left_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-xhdpi/ic_keyboard_arrow_left_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-xhdpi/ic_keyboard_arrow_right_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-xhdpi/ic_keyboard_arrow_right_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_left_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_left_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_right_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_right_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_left_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_left_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_right_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/calendar/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_right_black_24dp.png
--------------------------------------------------------------------------------
/calendar/src/main/res/layout/calendar_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
15 |
16 |
28 |
29 |
41 |
42 |
54 |
55 |
56 |
57 |
63 |
64 |
72 |
73 |
81 |
82 |
90 |
91 |
99 |
100 |
108 |
109 |
117 |
118 |
126 |
127 |
128 |
129 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/calendar/src/main/res/layout/item_calendar_day.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/calendar/src/main/res/layout/recycler_calendar.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/calendar/src/main/res/values/attrs.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 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/calendar/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #000000
4 | #00000000
5 |
6 |
--------------------------------------------------------------------------------
/calendar/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 | Mon
4 | Tue
5 | Wed
6 | Thu
7 | Fri
8 | Sat
9 | Sun
10 |
11 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jun 08 14:43:09 EEST 2017
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VRGsoftUA/VRCalendarView/562847df5b08cc81519727665baef2996fda7925/image.jpg
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Wed Dec 27 15:46:24 EET 2017
11 | ndk.dir=/Users/MacMini/Library/Android/sdk/ndk-bundle
12 | sdk.dir=/Users/MacMini/Library/Android/sdk
13 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':calendar'
2 |
--------------------------------------------------------------------------------