diff --git a/app/src/main/java/devs/mulham/raee/sample/MainActivity.java b/app/src/main/java/devs/mulham/raee/sample/MainActivity.java index ddce860..bb30974 100644 --- a/app/src/main/java/devs/mulham/raee/sample/MainActivity.java +++ b/app/src/main/java/devs/mulham/raee/sample/MainActivity.java @@ -45,13 +45,16 @@ protected void onCreate(Bundle savedInstanceState) { .startDate(startDate.getTime()) .endDate(endDate.getTime()) .datesNumberOnScreen(5) - .dayNameFormat("EEE") - .dayNumberFormat("dd") - .monthFormat("MMM") - .showDayName(true) - .showMonthName(true) + .configure() + .formatTopText("MMM") + .formatMiddleText("dd") + .formatBottomText("EEE") + .showTopText(true) + .showBottomText(true) + .textColor(Color.LTGRAY, Color.WHITE) + .colorTextMiddle(Color.LTGRAY, Color.parseColor("#ffd54f")) + .end() .defaultSelectedDate(defaultDate) - .textColor(Color.LTGRAY, Color.WHITE) .build(); Log.i("Default Date", DateFormat.getDateInstance().format(defaultDate)); diff --git a/app/src/main/java/devs/mulham/raee/sample/SampleFragment.java b/app/src/main/java/devs/mulham/raee/sample/SampleFragment.java index 1fb9047..28f2d62 100644 --- a/app/src/main/java/devs/mulham/raee/sample/SampleFragment.java +++ b/app/src/main/java/devs/mulham/raee/sample/SampleFragment.java @@ -26,11 +26,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_sample, container, false); - /** end after 1 month from now */ + /* end after 1 month from now */ Calendar endDate = Calendar.getInstance(); endDate.add(Calendar.MONTH, 1); - /** start before 1 month from now */ + /* start before 1 month from now */ Calendar startDate = Calendar.getInstance(); startDate.add(Calendar.MONTH, -1); @@ -38,13 +38,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, .startDate(startDate.getTime()) .endDate(endDate.getTime()) .datesNumberOnScreen(5) - .dayNameFormat("EEE") - .dayNumberFormat("dd") - .monthFormat("MMM") - .textSize(14f, 24f, 14f) - .showDayName(true) - .showMonthName(true) - .textColor(Color.LTGRAY, Color.WHITE) + .configure() + .formatTopText("MMM") + .formatMiddleText("dd") + .formatBottomText("EEE") + .textSize(14f, 24f, 14f) + .showTopText(true) + .showBottomText(true) + .textColor(Color.LTGRAY, Color.WHITE) + .end() .build(); horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3e79fe5..8c0798e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -27,8 +27,8 @@ android:layout_height="wrap_content" android:background="@color/colorPrimary" app:textColorSelected="#FFFF" - app:textSizeDayName="14sp" - app:textSizeDayNumber="20sp"/> + app:sizeBottomText="14sp" + app:sizeMiddleText="20sp"/> diff --git a/horizontalcalendar/build.gradle b/horizontalcalendar/build.gradle index b36b077..429b85a 100644 --- a/horizontalcalendar/build.gradle +++ b/horizontalcalendar/build.gradle @@ -14,7 +14,7 @@ ext { siteUrl = 'https://github.com/Mulham-Raee/Horizontal-Calendar' gitUrl = 'https://github.com/Mulham-Raee/Horizontal-Calendar.git' - libraryVersion = '1.2.2' + libraryVersion = '1.2.5' developerId = 'mulham-raee' developerName = 'Mulham Raee' diff --git a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/CalendarItemStyle.java b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/CalendarItemStyle.java new file mode 100644 index 0000000..07bff4f --- /dev/null +++ b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/CalendarItemStyle.java @@ -0,0 +1,81 @@ +package devs.mulham.horizontalcalendar; + +import android.graphics.drawable.Drawable; + +import java.util.Calendar; + +/** + * @author Mulham-Raee + * @since v1.2.5 + */ +public class CalendarItemStyle { + + private int colorTopText; + private int colorMiddleText; + private int colorBottomText; + private Drawable background; + + public CalendarItemStyle(){ + } + + public CalendarItemStyle(int textColor, Drawable background) { + this(textColor, textColor, textColor, background); + } + + public CalendarItemStyle(int colorTopText, int colorMiddleText, int colorBottomText, Drawable background) { + this.colorTopText = colorTopText; + this.colorMiddleText = colorMiddleText; + this.colorBottomText = colorBottomText; + this.background = background; + } + + public int getColorTopText() { + return colorTopText; + } + + public void setColorTopText(int colorTopText) { + this.colorTopText = colorTopText; + } + + public int getColorMiddleText() { + return colorMiddleText; + } + + public void setColorMiddleText(int colorMiddleText) { + this.colorMiddleText = colorMiddleText; + } + + public int getColorBottomText() { + return colorBottomText; + } + + public void setColorBottomText(int colorBottomText) { + this.colorBottomText = colorBottomText; + } + + public Drawable getBackground() { + return background; + } + + public void setBackground(Drawable background) { + this.background = background; + } + + public void setupDefaultValues(CalendarItemStyle defaultValues) { + if (defaultValues == null) { + return; + } + if (colorTopText == 0) { + colorTopText = defaultValues.colorTopText; + } + if (colorMiddleText == 0) { + colorMiddleText = defaultValues.colorMiddleText; + } + if (colorBottomText == 0) { + colorBottomText = defaultValues.colorBottomText; + } + if (background == null) { + background = defaultValues.background; + } + } +} diff --git a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/ConfigBuilder.java b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/ConfigBuilder.java new file mode 100644 index 0000000..5db8047 --- /dev/null +++ b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/ConfigBuilder.java @@ -0,0 +1,174 @@ +package devs.mulham.horizontalcalendar; + +import android.graphics.drawable.Drawable; + +/** + * @author Mulham-Raee + * @since v1.2.5 + */ +public class ConfigBuilder { + + /* Format & Font Sizes*/ + private float sizeTopText; + private float sizeMiddleText; + private float sizeBottomText; + private Integer selectorColor; + private String formatTopText; + private String formatMiddleText; + private String formatBottomText; + private boolean showTopText = true; + private boolean showBottomText = true; + + /* Colors and Background*/ + private int colorTextTop, colorTextTopSelected; + private int colorTextMiddle, colorTextMiddleSelected; + private int colorTextBottom, colorTextBottomSelected; + private Drawable selectedItemBackground; + + private final HorizontalCalendar.Builder calendarBuilder; + + public ConfigBuilder(HorizontalCalendar.Builder calendarBuilder) { + this.calendarBuilder = calendarBuilder; + } + + /** + * Set the text size of the labels in scale-independent pixels + * + * @param sizeTopText the Top text size, in SP + * @param sizeMiddleText the Middle text size, in SP + * @param sizeBottomText the Bottom text size, in SP + */ + public ConfigBuilder textSize(float sizeTopText, float sizeMiddleText, + float sizeBottomText) { + this.sizeTopText = sizeTopText; + this.sizeMiddleText = sizeMiddleText; + this.sizeBottomText = sizeBottomText; + return this; + } + + /** + * Set the text size of the top label in scale-independent pixels + * + * @param size the Top text size, in SP + */ + public ConfigBuilder sizeTopText(float size) { + this.sizeTopText = size; + return this; + } + + /** + * Set the text size of the middle label in scale-independent pixels + * + * @param size the Middle text size, in SP + */ + public ConfigBuilder sizeMiddleText(float size) { + this.sizeMiddleText = size; + return this; + } + + /** + * Set the text size of the bottom label in scale-independent pixels + * + * @param size the Bottom text size, in SP + */ + public ConfigBuilder sizeBottomText(float size) { + this.sizeBottomText = size; + return this; + } + + public ConfigBuilder selectorColor(Integer selectorColor) { + this.selectorColor = selectorColor; + return this; + } + + public ConfigBuilder formatTopText(String format) { + this.formatTopText = format; + return this; + } + + public ConfigBuilder formatMiddleText(String format) { + this.formatMiddleText = format; + return this; + } + + public ConfigBuilder formatBottomText(String format) { + this.formatBottomText = format; + return this; + } + + public ConfigBuilder showTopText(boolean value) { + this.showTopText = value; + return this; + } + + public ConfigBuilder showBottomText(boolean value) { + this.showBottomText = value; + return this; + } + + public ConfigBuilder textColor(int textColorNormal, int textColorSelected) { + colorTextTop = textColorNormal; + colorTextMiddle = textColorNormal; + colorTextBottom = textColorNormal; + + colorTextTopSelected = textColorSelected; + colorTextMiddleSelected = textColorSelected; + colorTextBottomSelected = textColorSelected; + return this; + } + + public ConfigBuilder colorTextTop(int textColorNormal, int textColorSelected) { + colorTextTop = textColorNormal; + colorTextTopSelected = textColorSelected; + return this; + } + + public ConfigBuilder colorTextMiddle(int textColorNormal, int textColorSelected) { + colorTextMiddle = textColorNormal; + colorTextMiddleSelected = textColorSelected; + return this; + } + + public ConfigBuilder colorTextBottom(int textColorNormal, int textColorSelected) { + colorTextBottom = textColorNormal; + colorTextBottomSelected = textColorSelected; + return this; + } + + public ConfigBuilder selectedDateBackground(Drawable background) { + this.selectedItemBackground = background; + return this; + } + + public HorizontalCalendar.Builder end() { + if (formatMiddleText == null) { + formatMiddleText = HorizontalCalendarConfig.DEFAULT_FORMAT_TEXT_MIDDLE; + } + if ((formatTopText == null) && showTopText) { + formatTopText = HorizontalCalendarConfig.DEFAULT_FORMAT_TEXT_TOP; + } + if ((formatBottomText == null) && showBottomText) { + formatBottomText = HorizontalCalendarConfig.DEFAULT_FORMAT_TEXT_BOTTOM; + } + return calendarBuilder; + } + + HorizontalCalendarConfig createConfig() { + HorizontalCalendarConfig config = new HorizontalCalendarConfig(sizeTopText, sizeMiddleText, sizeBottomText, selectorColor); + config.setFormatTopText(formatTopText); + config.setFormatMiddleText(formatMiddleText); + config.setFormatBottomText(formatBottomText); + config.setShowTopText(showTopText); + config.setShowBottomText(showBottomText); + + return config; + } + + CalendarItemStyle createDefaultStyle() { + return new CalendarItemStyle(colorTextTop, colorTextMiddle, colorTextBottom, null); + } + + CalendarItemStyle createSelectedItemStyle() { + return new CalendarItemStyle(colorTextTopSelected, colorTextMiddleSelected, colorTextBottomSelected, selectedItemBackground); + } +} diff --git a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendar.java b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendar.java index 1ffaaad..c4d17fb 100644 --- a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendar.java +++ b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendar.java @@ -2,12 +2,12 @@ import android.annotation.TargetApi; import android.app.Activity; -import android.graphics.drawable.Drawable; +import android.graphics.Color; import android.support.v7.widget.RecyclerView; import android.view.View; + import java.text.SimpleDateFormat; -import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.concurrent.TimeUnit; @@ -30,52 +30,37 @@ public final class HorizontalCalendar { private final Date dateStartCalendar; private final Date dateEndCalendar; + //Number of Dates to Show on Screen + private final int numberOfDatesOnScreen; + //Interface events HorizontalCalendarListener calendarListener; final private RecyclerView.OnScrollListener onScrollListener = new HorizontalCalendarScrollListener(); private final int calendarId; - //Number of Dates to Show on Screen - private final int numberOfDatesOnScreen; /* Format, Colors & Font Sizes*/ private SimpleDateFormat dateFormat; - private final String formatDayName; - private final String formatDayNumber; - private final String formatMonth; - private int textColorNormal, textColorSelected; - private Drawable selectedDateBackground; - private Integer selectorColor; - private float textSizeMonthName, textSizeDayNumber, textSizeDayName; - - private final boolean showMonthName; - private final boolean showDayName; + private final CalendarItemStyle defaultStyle; + private final CalendarItemStyle selectedItemStyle; + private final HorizontalCalendarConfig config; //endregion /** * Private Constructor to insure HorizontalCalendar can't be initiated the default way */ - HorizontalCalendar(Builder builder) { - this.calendarId = builder.viewId; - this.textColorNormal = builder.textColorNormal; - this.textColorSelected = builder.textColorSelected; - this.selectedDateBackground = builder.selectedDateBackground; - this.selectorColor = builder.selectorColor; - this.formatDayName = builder.formatDayName; - this.formatDayNumber = builder.formatDayNumber; - this.formatMonth = builder.formatMonth; - this.textSizeMonthName = builder.textSizeMonthName; - this.textSizeDayNumber = builder.textSizeDayNumber; - this.textSizeDayName = builder.textSizeDayName; + HorizontalCalendar(Builder builder, HorizontalCalendarConfig config, CalendarItemStyle defaultStyle, CalendarItemStyle selectedItemStyle) { this.numberOfDatesOnScreen = builder.numberOfDatesOnScreen; + this.calendarId = builder.viewId; this.dateStartCalendar = builder.dateStartCalendar; this.dateEndCalendar = builder.dateEndCalendar; - this.showDayName = builder.showDayName; - this.showMonthName = builder.showMonthName; + this.config = config; + this.defaultStyle = defaultStyle; + this.selectedItemStyle = selectedItemStyle; } /* Init Calendar View */ - void loadHorizontalCalendar(View rootView, final Date defaultSelectedDate) { + void loadHorizontalCalendar(View rootView, final Date defaultSelectedDate, final HorizontalCalendarPredicate disablePredicate) { dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault()); @@ -87,7 +72,7 @@ void loadHorizontalCalendar(View rootView, final Date defaultSelectedDate) { HorizontalSnapHelper snapHelper = new HorizontalSnapHelper(); snapHelper.attachToHorizontalCalendar(this); - mCalendarAdapter = new HorizontalCalendarAdapter(calendarView, dateStartCalendar, dateEndCalendar); + mCalendarAdapter = new HorizontalCalendarAdapter(this, dateStartCalendar, dateEndCalendar, disablePredicate); calendarView.setAdapter(mCalendarAdapter); calendarView.setLayoutManager(new HorizontalLayoutManager(calendarView.getContext(), false)); calendarView.addOnScrollListener(onScrollListener); @@ -147,7 +132,7 @@ public void selectDate(Date date, boolean immediate) { void centerCalendarToPosition(final int position) { if (position != -1) { int relativeCenterPosition = calculateRelativeCenterPosition(position); - if (relativeCenterPosition == position){ + if (relativeCenterPosition == position) { return; } @@ -163,7 +148,7 @@ void centerCalendarToPosition(final int position) { void centerToPositionWithNoAnimation(final int position) { if (position != -1) { int relativeCenterPosition = calculateRelativeCenterPosition(position); - if (relativeCenterPosition == position){ + if (relativeCenterPosition == position) { return; } @@ -211,6 +196,10 @@ void refreshItemsSelector(int position1, int... positions) { } } + public boolean isItemDisabled(int position) { + return mCalendarAdapter.isDisabled(position); + } + public void show() { calendarView.setVisibility(View.VISIBLE); } @@ -259,96 +248,22 @@ public boolean contains(Date date) { return positionOfDate(date) != -1; } - //region Getters & Setters - public Date getDateStartCalendar() { - return dateStartCalendar; - } - - public Date getDateEndCalendar() { - return dateEndCalendar; + public CalendarItemStyle getDefaultStyle() { + return defaultStyle; } - public String getFormatDayName() { - return formatDayName; + public CalendarItemStyle getSelectedItemStyle() { + return selectedItemStyle; } - public String getFormatDayNumber() { - return formatDayNumber; - } - - public String getFormatMonth() { - return formatMonth; - } - - public boolean isShowDayName() { - return showDayName; - } - - public boolean isShowMonthName() { - return showMonthName; + public HorizontalCalendarConfig getConfig() { + return config; } public int getNumberOfDatesOnScreen() { return numberOfDatesOnScreen; } - public Drawable getSelectedDateBackground() { - return selectedDateBackground; - } - - public void setSelectedDateBackground(Drawable selectedDateBackground) { - this.selectedDateBackground = selectedDateBackground; - } - - public int getTextColorNormal() { - return textColorNormal; - } - - public void setTextColorNormal(int textColorNormal) { - this.textColorNormal = textColorNormal; - } - - public int getTextColorSelected() { - return textColorSelected; - } - - public void setTextColorSelected(int textColorSelected) { - this.textColorSelected = textColorSelected; - } - - public Integer getSelectorColor() { - return selectorColor; - } - - public void setSelectorColor(int selectorColor) { - this.selectorColor = selectorColor; - } - - public float getTextSizeMonthName() { - return textSizeMonthName; - } - - public void setTextSizeMonthName(float textSizeMonthName) { - this.textSizeMonthName = textSizeMonthName; - } - - public float getTextSizeDayNumber() { - return textSizeDayNumber; - } - - public void setTextSizeDayNumber(float textSizeDayNumber) { - this.textSizeDayNumber = textSizeDayNumber; - } - - public float getTextSizeDayName() { - return textSizeDayName; - } - - public void setTextSizeDayName(float textSizeDayName) { - this.textSizeDayName = textSizeDayName; - } - //endregion - /** * @return position of date in Calendar, or -1 if date does not exist */ @@ -383,25 +298,17 @@ public static class Builder { final int viewId; final View rootView; - //Start & End Dates + // Start & End Dates Date dateStartCalendar; Date dateEndCalendar; + Date defaultSelectedDate; - //Number of Days to Show on Screen + // Number of Days to Show on Screen int numberOfDatesOnScreen; + // Specified which dates should be disabled + private HorizontalCalendarPredicate disablePredicate; - /* Format, Colors & Font Sizes*/ - String formatDayName; - String formatDayNumber; - String formatMonth; - int textColorNormal, textColorSelected; - Drawable selectedDateBackground; - Integer selectorColor; - float textSizeMonthName, textSizeDayNumber, textSizeDayName; - - boolean showMonthName = true; - boolean showDayName = true; - Date defaultSelectedDate; + private ConfigBuilder configBuilder; /** * @param rootView pass the rootView for the Fragment where HorizontalCalendar is attached @@ -421,11 +328,6 @@ public Builder(Activity activity, int viewId) { this.viewId = viewId; } - public Builder defaultSelectedDate(Date date) { - defaultSelectedDate = date; - return this; - } - public Builder startDate(Date dateStartCalendar) { this.dateStartCalendar = dateStartCalendar; return this; @@ -441,130 +343,81 @@ public Builder datesNumberOnScreen(int numberOfItemsOnScreen) { return this; } - public Builder dayNameFormat(String format) { - this.formatDayName = format; - return this; - } - - public Builder dayNumberFormat(String format) { - this.formatDayNumber = format; + public Builder defaultSelectedDate(Date date) { + defaultSelectedDate = date; return this; } - public Builder monthFormat(String format) { - this.formatMonth = format; + public Builder disableDates(HorizontalCalendarPredicate predicate) { + disablePredicate = predicate; return this; } - public Builder textColor(int textColorNormal, int textColorSelected) { - this.textColorNormal = textColorNormal; - this.textColorSelected = textColorSelected; - return this; - } + public ConfigBuilder configure(){ + if (configBuilder == null){ + configBuilder = new ConfigBuilder(this); + } - public Builder selectedDateBackground(Drawable background) { - this.selectedDateBackground = background; - return this; + return configBuilder; } - public Builder selectorColor(int selectorColor) { - this.selectorColor = selectorColor; - return this; + private void initDefaultValues() throws IllegalStateException{ + /* Defaults variables */ + if ((dateStartCalendar == null) || (dateEndCalendar == null)) { + throw new IllegalStateException("HorizontalCalendar range was not specified, either startDate or endDate is null!"); + } + HorizontalCalendarPredicate defaultDisablePredicate = new DefaultDisablePredicate(dateStartCalendar, dateEndCalendar); + if (disablePredicate == null) { + disablePredicate = defaultDisablePredicate; + } else { + disablePredicate = new HorizontalCalendarPredicate.Or(disablePredicate, defaultDisablePredicate); + } + if (numberOfDatesOnScreen <= 0) { + numberOfDatesOnScreen = 5; + } + if (defaultSelectedDate == null) { + defaultSelectedDate = new Date(); + } } /** - * Set the text size of the labels in scale-independent pixels - * - * @param textSizeMonthName the month name text size, in SP - * @param textSizeDayNumber the day number text size, in SP - * @param textSizeDayName the day name text size, in SP + * @return Instance of {@link HorizontalCalendar} initiated with builder settings */ - public Builder textSize(float textSizeMonthName, float textSizeDayNumber, - float textSizeDayName) { - this.textSizeMonthName = textSizeMonthName; - this.textSizeDayNumber = textSizeDayNumber; - this.textSizeDayName = textSizeDayName; - return this; - } + public HorizontalCalendar build() throws IllegalStateException{ + initDefaultValues(); - /** - * Set the text size of the month name label in scale-independent pixels - * - * @param textSizeMonthName the month name text size, in SP - */ - public Builder textSizeMonthName(float textSizeMonthName) { - this.textSizeMonthName = textSizeMonthName; - return this; - } + if (configBuilder == null){ + configBuilder = new ConfigBuilder(this); + configBuilder.end(); + } + CalendarItemStyle defaultStyle = configBuilder.createDefaultStyle(); + CalendarItemStyle selectedItemStyle = configBuilder.createSelectedItemStyle(); + HorizontalCalendarConfig config = configBuilder.createConfig(); - /** - * Set the text size of the day number label in scale-independent pixels - * - * @param textSizeDayNumber the day number text size, in SP - */ - public Builder textSizeDayNumber(float textSizeDayNumber) { - this.textSizeDayNumber = textSizeDayNumber; - return this; + HorizontalCalendar horizontalCalendar = new HorizontalCalendar(this, config, defaultStyle, selectedItemStyle); + horizontalCalendar.loadHorizontalCalendar(rootView, defaultSelectedDate, disablePredicate); + return horizontalCalendar; } + } - /** - * Set the text size of the day name label in scale-independent pixels - * - * @param textSizeDayName the day name text size, in SP - */ - public Builder textSizeDayName(float textSizeDayName) { - this.textSizeDayName = textSizeDayName; - return this; - } + private static class DefaultDisablePredicate implements HorizontalCalendarPredicate { - public Builder showDayName(boolean value) { - showDayName = value; - return this; - } + private final Date startDate; + private final Date endDate; - public Builder showMonthName(boolean value) { - showMonthName = value; - return this; + DefaultDisablePredicate(Date startDate, Date endDate) { + this.startDate = startDate; + this.endDate = endDate; } - /** - * @return Instance of {@link HorizontalCalendar} initiated with builder settings - */ - public HorizontalCalendar build() { - initDefaultValues(); - HorizontalCalendar horizontalCalendar = new HorizontalCalendar(this); - horizontalCalendar.loadHorizontalCalendar(rootView, defaultSelectedDate); - return horizontalCalendar; + @Override + public boolean test(Date date) { + return date.before(startDate) || date.after(endDate); } - private void initDefaultValues() { - /* Defaults variables */ - if (numberOfDatesOnScreen <= 0) { - numberOfDatesOnScreen = 5; - } - - if ((formatDayName == null) && showDayName) { - formatDayName = "EEE"; - } - if (formatDayNumber == null) { - formatDayNumber = "dd"; - } - if ((formatMonth == null) && showMonthName) { - formatMonth = "MMM"; - } - if (dateStartCalendar == null) { - Calendar c = Calendar.getInstance(); - c.add(Calendar.MONTH, -1); - dateStartCalendar = c.getTime(); - } - if (dateEndCalendar == null) { - Calendar c2 = Calendar.getInstance(); - c2.add(Calendar.MONTH, 1); - dateEndCalendar = c2.getTime(); - } - if (defaultSelectedDate == null) { - defaultSelectedDate = new Date(); - } + @Override + public CalendarItemStyle style() { + return new CalendarItemStyle(Color.GRAY, null); } } @@ -596,7 +449,6 @@ public void run() { final int positionOfCenterItem = calendarView.getPositionOfCenterItem(); if ((lastSelectedItem == -1) || (lastSelectedItem != positionOfCenterItem)) { //On Scroll, agenda is refresh to update background colors - //mCalendarAdapter.notifyItemRangeChanged(getSelectedDatePosition() - 2, 5, "UPDATE_SELECTOR"); refreshItemSelector(positionOfCenterItem); if (lastSelectedItem != -1) { refreshItemSelector(lastSelectedItem); diff --git a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarAdapter.java b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarAdapter.java index 7c200df..e746ca6 100644 --- a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarAdapter.java +++ b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarAdapter.java @@ -30,35 +30,35 @@ */ class HorizontalCalendarAdapter extends RecyclerView.Adapter { - private final Context context; - final Date dateStart; - final Date dateEnd; + private final Date dateStart; + private final HorizontalCalendarPredicate disablePredicate; private int cellWidth; private final int itemsCount; - final HorizontalCalendar horizontalCalendar; + private final CalendarItemStyle disabledItemStyle; - HorizontalCalendarAdapter(HorizontalCalendarView horizontalCalendarView, Date dateStart, Date dateEnd) { - this.context = horizontalCalendarView.getContext(); - this.dateStart = dateStart; - this.dateEnd = dateEnd; - this.horizontalCalendar = horizontalCalendarView.getHorizontalCalendar(); + HorizontalCalendar horizontalCalendar; + HorizontalCalendarAdapter(HorizontalCalendar horizontalCalendar, Date dateStart, Date dateEnd, HorizontalCalendarPredicate disablePredicate) { + this.horizontalCalendar = horizontalCalendar; + this.dateStart = dateStart; + this.disablePredicate = disablePredicate; + this.disabledItemStyle = disablePredicate.style(); long diff = dateEnd.getTime() - dateStart.getTime(); //result in millis itemsCount = (int) TimeUnit.MILLISECONDS.toDays(diff) + 1; - calculateCellWidth(); + calculateCellWidth(horizontalCalendar.calendarView.getContext()); } @Override public DayViewHolder onCreateViewHolder(ViewGroup viewGroup, int position) { - View convertView = LayoutInflater.from(context).inflate(R.layout.item_calendar, viewGroup, false); + View convertView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_calendar, viewGroup, false); convertView.setMinimumWidth(cellWidth); final DayViewHolder holder = new DayViewHolder(convertView); - final Integer selectorColor = horizontalCalendar.getSelectorColor(); + final Integer selectorColor = horizontalCalendar.getConfig().getSelectorColor(); if (selectorColor != null) { holder.selectionView.setBackgroundColor(selectorColor); } @@ -72,52 +72,27 @@ public DayViewHolder onCreateViewHolder(ViewGroup viewGroup, int position) { @Override public void onBindViewHolder(DayViewHolder holder, int position) { Date day = getItem(position); - int selectedItemPosition = horizontalCalendar.getSelectedDatePosition(); + HorizontalCalendarConfig config = horizontalCalendar.getConfig(); - // Selected Day - if (position == selectedItemPosition) { - holder.txtDayNumber.setTextColor(horizontalCalendar.getTextColorSelected()); - holder.txtMonthName.setTextColor(horizontalCalendar.getTextColorSelected()); - holder.txtDayName.setTextColor(horizontalCalendar.getTextColorSelected()); - if (Build.VERSION.SDK_INT >= 16) { - holder.layoutBackground.setBackground(horizontalCalendar.getSelectedDateBackground()); - } else { - holder.layoutBackground.setBackgroundDrawable(horizontalCalendar.getSelectedDateBackground()); - } - holder.selectionView.setVisibility(View.VISIBLE); - } - // Unselected Days - else { - holder.txtDayNumber.setTextColor(horizontalCalendar.getTextColorNormal()); - holder.txtMonthName.setTextColor(horizontalCalendar.getTextColorNormal()); - holder.txtDayName.setTextColor(horizontalCalendar.getTextColorNormal()); - if (Build.VERSION.SDK_INT >= 16) { - holder.layoutBackground.setBackground(null); - } else { - holder.layoutBackground.setBackgroundDrawable(null); - } - holder.selectionView.setVisibility(View.INVISIBLE); - } + holder.textMiddle.setText(DateFormat.format(config.getFormatMiddleText(), day).toString()); + holder.textMiddle.setTextSize(TypedValue.COMPLEX_UNIT_SP, config.getSizeMiddleText()); - holder.txtDayNumber.setText(DateFormat.format(horizontalCalendar.getFormatDayNumber(), day).toString()); - holder.txtDayNumber.setTextSize(TypedValue.COMPLEX_UNIT_SP, - horizontalCalendar.getTextSizeDayNumber()); - - if (horizontalCalendar.isShowDayName()) { - holder.txtDayName.setText(DateFormat.format(horizontalCalendar.getFormatDayName(), day).toString()); - holder.txtDayName.setTextSize(TypedValue.COMPLEX_UNIT_SP, - horizontalCalendar.getTextSizeDayName()); + if (config.isShowTopText()) { + holder.textTop.setText(DateFormat.format(config.getFormatTopText(), day).toString()); + holder.textTop.setTextSize(TypedValue.COMPLEX_UNIT_SP, config.getSizeTopText()); } else { - holder.txtDayName.setVisibility(View.GONE); + holder.textTop.setVisibility(View.GONE); } - if (horizontalCalendar.isShowMonthName()) { - holder.txtMonthName.setText(DateFormat.format(horizontalCalendar.getFormatMonth(), day).toString()); - holder.txtMonthName.setTextSize(TypedValue.COMPLEX_UNIT_SP, - horizontalCalendar.getTextSizeMonthName()); + if (config.isShowBottomText()) { + holder.textBottom.setText(DateFormat.format(config.getFormatBottomText(), day).toString()); + holder.textBottom.setTextSize(TypedValue.COMPLEX_UNIT_SP, config.getSizeBottomText()); } else { - holder.txtMonthName.setVisibility(View.GONE); + holder.textBottom.setVisibility(View.GONE); } + + applyStyle(holder, day, position); + } @Override @@ -127,33 +102,43 @@ public void onBindViewHolder(DayViewHolder holder, int position, List pa return; } + Date day = getItem(position); + applyStyle(holder, day, position); + } + + private void applyStyle(DayViewHolder holder, Date day, int position) { int selectedItemPosition = horizontalCalendar.getSelectedDatePosition(); + boolean isDisabled = disablePredicate.test(day); + holder.rootView.setEnabled(!isDisabled); + if (isDisabled && (disabledItemStyle != null)) { + applyStyle(holder, disabledItemStyle); + holder.selectionView.setVisibility(View.INVISIBLE); + return; + } + // Selected Day if (position == selectedItemPosition) { - holder.txtDayNumber.setTextColor(horizontalCalendar.getTextColorSelected()); - holder.txtMonthName.setTextColor(horizontalCalendar.getTextColorSelected()); - holder.txtDayName.setTextColor(horizontalCalendar.getTextColorSelected()); - if (Build.VERSION.SDK_INT >= 16) { - holder.layoutBackground.setBackground(horizontalCalendar.getSelectedDateBackground()); - } else { - holder.layoutBackground.setBackgroundDrawable(horizontalCalendar.getSelectedDateBackground()); - } + applyStyle(holder, horizontalCalendar.getSelectedItemStyle()); holder.selectionView.setVisibility(View.VISIBLE); } // Unselected Days else { - holder.txtDayNumber.setTextColor(horizontalCalendar.getTextColorNormal()); - holder.txtMonthName.setTextColor(horizontalCalendar.getTextColorNormal()); - holder.txtDayName.setTextColor(horizontalCalendar.getTextColorNormal()); - if (Build.VERSION.SDK_INT >= 16) { - holder.layoutBackground.setBackground(null); - } else { - holder.layoutBackground.setBackgroundDrawable(null); - } + applyStyle(holder, horizontalCalendar.getDefaultStyle()); holder.selectionView.setVisibility(View.INVISIBLE); } + } + private void applyStyle(DayViewHolder holder, CalendarItemStyle itemStyle) { + holder.textTop.setTextColor(itemStyle.getColorTopText()); + holder.textMiddle.setTextColor(itemStyle.getColorMiddleText()); + holder.textBottom.setTextColor(itemStyle.getColorBottomText()); + + if (Build.VERSION.SDK_INT >= 16) { + holder.layoutBackground.setBackground(itemStyle.getBackground()); + } else { + holder.layoutBackground.setBackgroundDrawable(itemStyle.getBackground()); + } } @Override @@ -175,10 +160,15 @@ public Date getItem(int position) throws IndexOutOfBoundsException { return calendar.getTime(); } + public boolean isDisabled(int position) { + Date date = getItem(position); + return disablePredicate.test(date); + } + /** * calculate each item width depends on {@link HorizontalCalendar#numberOfDatesOnScreen} */ - private void calculateCellWidth() { + private void calculateCellWidth(Context context) { Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); @@ -200,12 +190,8 @@ public void onClick(View v) { if (holder.getAdapterPosition() == -1) return; - Date date = getItem(holder.getAdapterPosition()); - - if (!date.before(dateStart) && !date.after(dateEnd)) { - horizontalCalendar.calendarView.setSmoothScrollSpeed(HorizontalLayoutManager.SPEED_SLOW); - horizontalCalendar.centerCalendarToPosition(holder.getAdapterPosition()); - } + horizontalCalendar.calendarView.setSmoothScrollSpeed(HorizontalLayoutManager.SPEED_SLOW); + horizontalCalendar.centerCalendarToPosition(holder.getAdapterPosition()); } } @@ -220,7 +206,7 @@ private class MyOnLongClickListener implements View.OnLongClickListener { public boolean onLongClick(View v) { Date date = getItem(holder.getAdapterPosition()); HorizontalCalendarListener calendarListener = horizontalCalendar.getCalendarListener(); - if ((calendarListener != null) && !date.before(dateStart) && !date.after(dateEnd)) { + if (calendarListener != null) { return calendarListener.onDateLongClicked(date, holder.getAdapterPosition()); } return false; @@ -228,21 +214,21 @@ public boolean onLongClick(View v) { } static class DayViewHolder extends RecyclerView.ViewHolder { - TextView txtDayNumber; - TextView txtDayName; - TextView txtMonthName; + TextView textTop; + TextView textMiddle; + TextView textBottom; View selectionView; View layoutBackground; View rootView; - public DayViewHolder(View rootView) { + DayViewHolder(View rootView) { super(rootView); this.rootView = rootView; - txtDayNumber = rootView.findViewById(R.id.dayNumber); - txtDayName = rootView.findViewById(R.id.dayName); - txtMonthName = rootView.findViewById(R.id.monthName); - layoutBackground = rootView.findViewById(R.id.layoutBackground); - selectionView = rootView.findViewById(R.id.selection_view); + textTop = rootView.findViewById(R.id.hc_text_top); + textMiddle = rootView.findViewById(R.id.hc_text_middle); + textBottom = rootView.findViewById(R.id.hc_text_bottom); + layoutBackground = rootView.findViewById(R.id.hc_layoutBackground); + selectionView = rootView.findViewById(R.id.hc_selector); } } } diff --git a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarConfig.java b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarConfig.java new file mode 100644 index 0000000..dcc2885 --- /dev/null +++ b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarConfig.java @@ -0,0 +1,128 @@ +package devs.mulham.horizontalcalendar; + +/** + * @author Mulham-Raee + * @since v1.2.5 + */ +public class HorizontalCalendarConfig { + + static final float DEFAULT_SIZE_TEXT_TOP = 14f; + static final float DEFAULT_SIZE_TEXT_MIDDLE = 24f; + static final float DEFAULT_SIZE_TEXT_BOTTOM = 14f; + + static final String DEFAULT_FORMAT_TEXT_TOP = "MMM"; + static final String DEFAULT_FORMAT_TEXT_MIDDLE = "dd"; + static final String DEFAULT_FORMAT_TEXT_BOTTOM = "EEE"; + + /* Format & Font Sizes*/ + private String formatTopText; + private String formatMiddleText; + private String formatBottomText; + private float sizeTopText; + private float sizeMiddleText; + private float sizeBottomText; + + private Integer selectorColor; + private boolean showTopText; + private boolean showBottomText; + + public HorizontalCalendarConfig() { + } + + public HorizontalCalendarConfig(float sizeTopText, float sizeMiddleText, float sizeBottomText, Integer selectorColor) { + this.sizeTopText = sizeTopText; + this.sizeMiddleText = sizeMiddleText; + this.sizeBottomText = sizeBottomText; + this.selectorColor = selectorColor; + } + + public String getFormatTopText() { + return formatTopText; + } + + public void setFormatTopText(String formatTopText) { + this.formatTopText = formatTopText; + } + + public String getFormatMiddleText() { + return formatMiddleText; + } + + public void setFormatMiddleText(String formatMiddleText) { + this.formatMiddleText = formatMiddleText; + } + + public String getFormatBottomText() { + return formatBottomText; + } + + public void setFormatBottomText(String formatBottomText) { + this.formatBottomText = formatBottomText; + } + + public float getSizeTopText() { + return sizeTopText; + } + + public void setSizeTopText(float sizeTopText) { + this.sizeTopText = sizeTopText; + } + + public float getSizeMiddleText() { + return sizeMiddleText; + } + + public void setSizeMiddleText(float sizeMiddleText) { + this.sizeMiddleText = sizeMiddleText; + } + + public float getSizeBottomText() { + return sizeBottomText; + } + + public void setSizeBottomText(float sizeBottomText) { + this.sizeBottomText = sizeBottomText; + } + + public Integer getSelectorColor() { + return selectorColor; + } + + public void setSelectorColor(Integer selectorColor) { + this.selectorColor = selectorColor; + } + + public boolean isShowTopText() { + return showTopText; + } + + public void setShowTopText(boolean showTopText) { + this.showTopText = showTopText; + } + + public boolean isShowBottomText() { + return showBottomText; + } + + public void setShowBottomText(boolean showBottomText) { + this.showBottomText = showBottomText; + } + + public void setupDefaultValues(HorizontalCalendarConfig defaultConfig) { + if (defaultConfig == null) { + return; + } + if (selectorColor == null) { + selectorColor = defaultConfig.selectorColor; + } + if (sizeTopText == 0) { + sizeTopText = defaultConfig.sizeTopText; + } + if (sizeMiddleText == 0) { + sizeMiddleText = defaultConfig.sizeMiddleText; + } + if (sizeBottomText == 0) { + sizeBottomText = defaultConfig.sizeBottomText; + } + } +} diff --git a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarPredicate.java b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarPredicate.java new file mode 100644 index 0000000..bd78a47 --- /dev/null +++ b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarPredicate.java @@ -0,0 +1,35 @@ +package devs.mulham.horizontalcalendar; + +import java.util.Date; + +/** + * @author Mulham-Raee + * @since v1.2.5 + */ +public interface HorizontalCalendarPredicate { + + boolean test(Date date); + + CalendarItemStyle style(); + + class Or implements HorizontalCalendarPredicate { + + private final HorizontalCalendarPredicate firstPredicate; + private final HorizontalCalendarPredicate secondPredicate; + + public Or(HorizontalCalendarPredicate firstPredicate, HorizontalCalendarPredicate secondPredicate) { + this.firstPredicate = firstPredicate; + this.secondPredicate = secondPredicate; + } + + @Override + public boolean test(Date date) { + return firstPredicate.test(date) || secondPredicate.test(date); + } + + @Override + public CalendarItemStyle style() { + return firstPredicate.style(); + } + } +} diff --git a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarView.java b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarView.java index f9c0f63..426ed3e 100644 --- a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarView.java +++ b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalCalendarView.java @@ -16,16 +16,12 @@ */ public class HorizontalCalendarView extends RecyclerView { - private int textColorNormal, textColorSelected; - private Drawable selectedDateBackground; - private int selectorColor; - private float textSizeMonthName, textSizeDayNumber, textSizeDayName; + private CalendarItemStyle defaultStyle; + private CalendarItemStyle selectedItemStyle; + private HorizontalCalendarConfig config; private HorizontalCalendar horizontalCalendar; private final float FLING_SCALE_DOWN_FACTOR = 0.5f; - private final float DEFAULT_TEXT_SIZE_MONTH_NAME = 14f; - private final float DEFAULT_TEXT_SIZE_DAY_NUMBER = 24f; - private final float DEFAULT_TEXT_SIZE_DAY_NAME = 14f; public HorizontalCalendarView(Context context) { super(context); @@ -40,29 +36,43 @@ public HorizontalCalendarView(Context context, AttributeSet attrs) { 0, 0); try { - textColorNormal = a.getColor(R.styleable.HorizontalCalendarView_textColorNormal, Color.LTGRAY); - textColorSelected = a.getColor(R.styleable.HorizontalCalendarView_textColorSelected, Color.BLACK); - selectedDateBackground = a.getDrawable(R.styleable.HorizontalCalendarView_selectedDateBackground); - selectorColor = a.getColor(R.styleable.HorizontalCalendarView_selectorColor, fetchAccentColor()); - - textSizeMonthName = getRawSizeValue(a, R.styleable.HorizontalCalendarView_textSizeMonthName, - DEFAULT_TEXT_SIZE_MONTH_NAME); - textSizeDayNumber = getRawSizeValue(a, R.styleable.HorizontalCalendarView_textSizeDayNumber, - DEFAULT_TEXT_SIZE_DAY_NUMBER); - textSizeDayName = getRawSizeValue(a, R.styleable.HorizontalCalendarView_textSizeDayName, - DEFAULT_TEXT_SIZE_DAY_NAME); + int textColorNormal = a.getColor(R.styleable.HorizontalCalendarView_textColorNormal, Color.LTGRAY); + int colorTopText = a.getColor(R.styleable.HorizontalCalendarView_colorTopText, textColorNormal); + int colorMiddleText = a.getColor(R.styleable.HorizontalCalendarView_colorMiddleText, textColorNormal); + int colorBottomText = a.getColor(R.styleable.HorizontalCalendarView_colorBottomText, textColorNormal); + + int textColorSelected = a.getColor(R.styleable.HorizontalCalendarView_textColorSelected, Color.BLACK); + int colorTopTextSelected = a.getColor(R.styleable.HorizontalCalendarView_colorTopTextSelected, textColorSelected); + int colorMiddleTextSelected = a.getColor(R.styleable.HorizontalCalendarView_colorMiddleTextSelected, textColorSelected); + int colorBottomTextSelected = a.getColor(R.styleable.HorizontalCalendarView_colorBottomTextSelected, textColorSelected); + Drawable selectedDateBackground = a.getDrawable(R.styleable.HorizontalCalendarView_selectedDateBackground); + + int selectorColor = a.getColor(R.styleable.HorizontalCalendarView_selectorColor, fetchAccentColor()); + float sizeTopText = getRawSizeValue(a, R.styleable.HorizontalCalendarView_sizeTopText, + HorizontalCalendarConfig.DEFAULT_SIZE_TEXT_TOP); + float sizeMiddleText = getRawSizeValue(a, R.styleable.HorizontalCalendarView_sizeMiddleText, + HorizontalCalendarConfig.DEFAULT_SIZE_TEXT_MIDDLE); + float sizeBottomText = getRawSizeValue(a, R.styleable.HorizontalCalendarView_sizeBottomText, + HorizontalCalendarConfig.DEFAULT_SIZE_TEXT_BOTTOM); + + + defaultStyle = new CalendarItemStyle(colorTopText, colorMiddleText, colorBottomText, null); + selectedItemStyle = new CalendarItemStyle(colorTopTextSelected, colorMiddleTextSelected, colorBottomTextSelected, selectedDateBackground); + config = new HorizontalCalendarConfig(sizeTopText, sizeMiddleText, sizeBottomText, selectorColor); + } finally { a.recycle(); } + } /** - * get the raw value from a complex value ( Ex: complex = 14sp, returns 14) + * get the raw value from a complex value ( Ex: complex = 14sp, returns 14) */ - private float getRawSizeValue(TypedArray a ,int index, float defValue){ + private float getRawSizeValue(TypedArray a, int index, float defValue) { TypedValue outValue = new TypedValue(); boolean result = a.getValue(index, outValue); - if (!result){ + if (!result) { return defValue; } @@ -119,28 +129,14 @@ public HorizontalCalendar getHorizontalCalendar() { } public void setHorizontalCalendar(HorizontalCalendar horizontalCalendar) { - - if (horizontalCalendar.getTextColorNormal() == 0) { - horizontalCalendar.setTextColorNormal(textColorNormal); - } - if (horizontalCalendar.getTextColorSelected() == 0) { - horizontalCalendar.setTextColorSelected(textColorSelected); - } - if (horizontalCalendar.getSelectorColor() == null) { //compare with null because Color.TRANSPARENT == 0 - horizontalCalendar.setSelectorColor(selectorColor); - } - if (horizontalCalendar.getSelectedDateBackground() == null) { - horizontalCalendar.setSelectedDateBackground(selectedDateBackground); - } - if (horizontalCalendar.getTextSizeMonthName() == 0) { - horizontalCalendar.setTextSizeMonthName(textSizeMonthName); - } - if (horizontalCalendar.getTextSizeDayNumber() == 0) { - horizontalCalendar.setTextSizeDayNumber(textSizeDayNumber); - } - if (horizontalCalendar.getTextSizeDayName() == 0) { - horizontalCalendar.setTextSizeDayName(textSizeDayName); - } + horizontalCalendar.getConfig().setupDefaultValues(config); + horizontalCalendar.getDefaultStyle().setupDefaultValues(defaultStyle); + horizontalCalendar.getSelectedItemStyle().setupDefaultValues(selectedItemStyle); + + // clean, not needed anymore + config = null; + defaultStyle = null; + selectedItemStyle = null; this.horizontalCalendar = horizontalCalendar; } diff --git a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalSnapHelper.java b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalSnapHelper.java index 2ba4bc7..a7ea62f 100644 --- a/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalSnapHelper.java +++ b/horizontalcalendar/src/main/java/devs/mulham/horizontalcalendar/HorizontalSnapHelper.java @@ -30,13 +30,19 @@ public View findSnapView(RecyclerView.LayoutManager layoutManager) { selectedItemPosition = layoutManager.getPosition(snapView); } - horizontalCalendar.calendarListener - .onDateSelected(horizontalCalendar.getDateAt(selectedItemPosition), selectedItemPosition); + notifyCalendarListener(selectedItemPosition); } return snapView; } + private void notifyCalendarListener(int selectedItemPosition){ + if (!horizontalCalendar.isItemDisabled(selectedItemPosition)){ + horizontalCalendar.calendarListener + .onDateSelected(horizontalCalendar.getDateAt(selectedItemPosition), selectedItemPosition); + } + } + @Override public void attachToRecyclerView(@Nullable RecyclerView recyclerView) throws IllegalStateException { // Do nothing diff --git a/horizontalcalendar/src/main/res/layout/item_calendar.xml b/horizontalcalendar/src/main/res/layout/item_calendar.xml index b62a6c0..a8ad987 100644 --- a/horizontalcalendar/src/main/res/layout/item_calendar.xml +++ b/horizontalcalendar/src/main/res/layout/item_calendar.xml @@ -1,6 +1,6 @@ - + - + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + \ No newline at end of file