Skip to content

Commit c5ab81d

Browse files
committed
fix item view size
1 parent 0ad647f commit c5ab81d

File tree

13 files changed

+100
-39
lines changed

13 files changed

+100
-39
lines changed

app/app.iml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@
102102
<orderEntry type="library" exported="" scope="TEST" name="javax.inject:javax.inject:1@jar" level="project" />
103103
<orderEntry type="library" exported="" scope="TEST" name="com.squareup:javawriter:2.1.1@jar" level="project" />
104104
<orderEntry type="library" exported="" name="com.android.support:recyclerview-v7-27.0.2" level="project" />
105-
<orderEntry type="library" exported="" name="com.github.VRGsoftUA:VRCalendarView-1.0.1" level="project" />
105+
<orderEntry type="library" exported="" name="com.github.bumptech.glide:disklrucache:4.5.0@jar" level="project" />
106+
<orderEntry type="library" exported="" name="com.github.bumptech.glide:glide-4.5.0" level="project" />
106107
<orderEntry type="library" exported="" name="com.android.support.constraint:constraint-layout-solver:1.0.2@jar" level="project" />
107108
<orderEntry type="library" exported="" name="com.android.support.constraint:constraint-layout-1.0.2" level="project" />
108109
<orderEntry type="library" exported="" name="android.arch.lifecycle:runtime-1.0.3" level="project" />
@@ -120,9 +121,12 @@
120121
<orderEntry type="library" exported="" scope="TEST" name="com.android.support.test:runner-0.5" level="project" />
121122
<orderEntry type="library" exported="" name="com.android.support:support-core-utils-27.0.2" level="project" />
122123
<orderEntry type="library" exported="" scope="TEST" name="com.android.support.test.espresso:espresso-idling-resource-2.2.2" level="project" />
124+
<orderEntry type="library" exported="" name="com.github.bumptech.glide:gifdecoder-4.5.0" level="project" />
123125
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation:javax.annotation-api:1.2@jar" level="project" />
124126
<orderEntry type="library" exported="" name="com.android.support:support-fragment-27.0.2" level="project" />
127+
<orderEntry type="library" exported="" name="com.github.bumptech.glide:annotations:4.5.0@jar" level="project" />
125128
<orderEntry type="library" exported="" name="com.android.support:support-media-compat-27.0.2" level="project" />
126129
<orderEntry type="library" exported="" name="com.android.support:support-v4-27.0.2" level="project" />
130+
<orderEntry type="module" module-name="calendar" exported="" />
127131
</component>
128132
</module>

app/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ dependencies {
2727
compile 'com.android.support:appcompat-v7:27.0.2'
2828
compile 'com.android.support.constraint:constraint-layout:1.0.2'
2929
testCompile 'junit:junit:4.12'
30-
compile 'com.github.VRGsoftUA:VRCalendarView:1.0.1'
31-
// compile project(path: ':calendar')
30+
// compile 'com.github.VRGsoftUA:VRCalendarView:1.0.1'
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')
3234

3335
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.vrgsoft.calendarview">
44

5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
7+
58
<application
69
android:allowBackup="true"
710
android:icon="@mipmap/ic_launcher"

app/src/main/java/com/vrgsoft/calendarview/CustomDayUtils.java

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public List<VrCalendarDay> getCustomizeDayView(final Context context) {
2323

2424
vrCalendarDays.add(getToday(context));
2525
vrCalendarDays.add(getSomeDay(context));
26-
vrCalendarDays.add(getAnotherDay(context));
26+
vrCalendarDays.add(getSomeDayAgain(context));
2727
vrCalendarDays.add(getOneMoreDay(context));
2828
vrCalendarDays.add(getDay0(context));
2929
vrCalendarDays.add(getDay1(context));
@@ -33,21 +33,6 @@ public List<VrCalendarDay> getCustomizeDayView(final Context context) {
3333
return vrCalendarDays;
3434
}
3535

36-
private VrCalendarDay getAnotherDay(final Context context) {
37-
VrCalendarDay tomorrow = new VrCalendarDay();
38-
Calendar cal = Calendar.getInstance();
39-
cal.add(Calendar.DAY_OF_MONTH, 2);
40-
Date d = cal.getTime();
41-
tomorrow.setDate(d);
42-
VrCalendarDaySettings vrtomorCalendarDaySettings = new VrCalendarDaySettings();
43-
vrtomorCalendarDaySettings.setDayTextStyle(VRCalendarView.BOLD);
44-
vrtomorCalendarDaySettings.setDayBackgroundColor(ContextCompat.getColor(context, R.color.colorAccent));
45-
vrtomorCalendarDaySettings.setDayTextColor(ContextCompat.getColor(context, R.color.colorYellow));
46-
tomorrow.setVrCalendarDaySettings(vrtomorCalendarDaySettings);
47-
48-
return tomorrow;
49-
}
50-
5136
private VrCalendarDay getOneMoreDay(final Context context) {
5237
VrCalendarDay tomorrow = new VrCalendarDay();
5338
Calendar cal = Calendar.getInstance();
@@ -87,7 +72,37 @@ public View getNewCustomiseView() {
8772
});
8873

8974
Calendar cal = Calendar.getInstance();
90-
cal.add(Calendar.DAY_OF_MONTH, -2);
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);
91106
someDay.setDate(cal.getTime());
92107
someDay.setVrCalendarDaySettings(someDaySettings);
93108
return someDay;
@@ -98,7 +113,7 @@ private VrCalendarDay getToday(final Context context) {
98113
today.setDate(new Date());
99114

100115
VrCalendarDaySettings todaySettings = new VrCalendarDaySettings();
101-
todaySettings.setDayTextColor(Color.TRANSPARENT);
116+
todaySettings.setDayTextColor(ContextCompat.getColor(context, R.color.colorTransparent));
102117
today.setVrCalendarDaySettings(todaySettings);
103118
today.setVRCalendarCustomViewCallback(new VRCalendarCustomViewCallback() {
104119
@Override
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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<GifDrawable> requestBuilder) {
16+
// requestBuilder
17+
// .transition(new DrawableTransitionOptions())
18+
// .apply(DECODE_TYPE_GIF);
19+
// }
20+
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
}

app/src/main/java/com/vrgsoft/calendarview/MainActivity.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package com.vrgsoft.calendarview;
22

33
import android.graphics.Color;
4+
import android.os.Bundle;
45
import android.support.v4.content.ContextCompat;
56
import android.support.v7.app.AppCompatActivity;
6-
import android.os.Bundle;
77
import android.view.View;
88
import android.widget.ImageView;
99
import android.widget.Toast;
1010

1111
import com.vrgsoft.calendar.VRCalendarCustomViewCallback;
12-
import com.vrgsoft.calendar.calendar_listeners.OnCalendarClickListener;
13-
import com.vrgsoft.calendar.calendar_listeners.OnCalendarLongClickListener;
1412
import com.vrgsoft.calendar.VRCalendarView;
15-
import com.vrgsoft.calendar.calendar_listeners.VRCalendarMonthCallback;
1613
import com.vrgsoft.calendar.VrCalendarDay;
1714
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;
1818

1919
import java.text.DateFormat;
2020
import java.text.SimpleDateFormat;
@@ -71,13 +71,12 @@ public void onClick(View v) {
7171
});
7272

7373
vrCalendarView.setDateFormat(df);
74-
vrCalendarView.getDayOfWeekTextView(VRCalendarView.TUESDAY).setTextColor(Color.CYAN);
75-
vrCalendarView.getDayOfWeekTextView(VRCalendarView.WEDNESDAY).setTextSize(20);
76-
vrCalendarView.getDayOfWeekTextView(VRCalendarView.FRIDAY).setTextColor(Color.GREEN);
74+
vrCalendarView.getDayOfWeekTextView(VRCalendarView.SATURDAY).setTextSize(20);
75+
vrCalendarView.getDayOfWeekTextView(VRCalendarView.SUNDAY).setTextSize(20);
76+
vrCalendarView.getDayOfWeekTextView(VRCalendarView.SATURDAY).setTextColor(Color.RED);
7777
vrCalendarView.getDayOfWeekTextView(VRCalendarView.SUNDAY).setTextColor(Color.RED);
78-
vrCalendarView.getNextMonthImageButton().setImageResource(R.drawable.ic_next_button_example);
79-
vrCalendarView.weekContainer().setBackgroundColor(Color.LTGRAY);
80-
vrCalendarView.titleContainer().setBackgroundColor(Color.GRAY);
78+
vrCalendarView.weekContainer().setBackgroundColor(ContextCompat.getColor(this, R.color.colorToday));
79+
vrCalendarView.titleContainer().setBackgroundColor(ContextCompat.getColor(this, R.color.colorTitle));
8180
}
8281

8382
@Override
1.11 MB
Loading

app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
android:id="@+id/calendar"
1111
android:layout_width="match_parent"
1212
android:layout_height="wrap_content"
13-
app:vr_background_color="@color/colorDark"
13+
app:vr_background_color="@color/colorTitle"
1414
app:vr_calendar_day_text_size="15sp"
1515
app:vr_chosen_day_background_color="@color/colorGreen"
1616
app:vr_chosen_day_background_drawable="@drawable/background"
@@ -21,7 +21,7 @@
2121
app:vr_next_button="@drawable/ic_next"
2222
app:vr_other_month_text_color="@color/colorPrimary"
2323
app:vr_previous_button="@drawable/ic_previous"
24-
app:vr_title_text_color="@color/colorGreen"
24+
app:vr_title_text_color="@color/colorToday"
2525
app:vr_week_days_color="@android:color/darker_gray" />
2626

2727

app/src/main/res/layout/custom_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5-
android:background="@android:color/holo_blue_bright">
5+
android:background="@color/colorTitle">
66

77
<View
88
android:layout_width="16dp"
@@ -13,7 +13,7 @@
1313
android:layout_marginEnd="-8dp"
1414
android:layout_marginRight="-8dp"
1515
android:layout_marginTop="-8dp"
16-
android:background="#ff0004"
16+
android:background="#6bcf7f"
1717
android:rotation="45" />
1818

1919
</RelativeLayout>

app/src/main/res/values/colors.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<color name="colorAccent">#FF4081</color>
66
<color name="colorGreen">#00f234</color>
77
<color name="colorToday">#0ea8ae</color>
8+
<color name="colorTitle">#016b70</color>
89
<color name="colorYellow">#ffff00</color>
910
<color name="colorDark">#000000</color>
11+
<color name="colorTransparent">#02000000</color>
1012
</resources>

calendar/src/main/java/com/vrgsoft/calendar/VrCalendarUtils.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.vrgsoft.calendar;
22

33
import android.graphics.drawable.Drawable;
4+
import android.view.View;
45

56
import java.util.Calendar;
67
import java.util.Date;
@@ -61,13 +62,19 @@ VrCalendarDaySettings getDaySettings(Calendar calendarMonth, Date date, Calendar
6162
return vrCalendarDaySettings;
6263
}
6364

64-
VrCalendarDay transfer(VrCalendarDay day, CalendarSettingWrapper calendarSettingWrapper, int position) {
65+
VrCalendarDay transfer(final VrCalendarDay day, CalendarSettingWrapper calendarSettingWrapper, int position) {
6566
Calendar currentDate = Calendar.getInstance();
6667
currentDate.add(Calendar.MONTH, position);
6768
VrCalendarDay vrCalendarDay = new VrCalendarDay();
6869
vrCalendarDay.setChoosen(day.isChoosen());
6970
vrCalendarDay.setDate(day.getDate());
70-
vrCalendarDay.setVRCalendarCustomViewCallback(day.getVRCalendarCustomViewCallback());
71+
VRCalendarCustomViewCallback calendarCustomViewCallback = new VRCalendarCustomViewCallback() {
72+
@Override
73+
public View getNewCustomiseView() {
74+
return day.getVRCalendarCustomViewCallback().getNewCustomiseView();
75+
}
76+
};
77+
vrCalendarDay.setVRCalendarCustomViewCallback(calendarCustomViewCallback);
7178
vrCalendarDay.setVrCalendarDaySettings(getDaySettings(currentDate
7279
, vrCalendarDay.getDate(), calendarSettingWrapper, day.getVrCalendarDaySettings()));
7380
return vrCalendarDay;

calendar/src/main/res/layout/item_calendar_day.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
<FrameLayout
1515
android:id="@+id/vCustomBack"
16-
android:layout_width="wrap_content"
17-
android:layout_height="wrap_content"
16+
android:layout_width="match_parent"
17+
android:layout_height="match_parent"
1818
android:layout_gravity="center"
1919
android:gravity="center" />
2020

0 commit comments

Comments
 (0)