Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,22 @@ public ViewHolder(View itemView, SimpleMonthView.OnDayClickListener onDayClickLi

protected void init() {
if (typedArray.getBoolean(R.styleable.DayPickerView_currentDaySelected, false))
onDayTapped(new CalendarDay(System.currentTimeMillis()));
onDayTapped(new CalendarDay(System.currentTimeMillis()), false);
}

public void onDayClick(SimpleMonthView simpleMonthView, CalendarDay calendarDay) {
if (calendarDay != null) {
onDayTapped(calendarDay);
onDayTapped(calendarDay, simpleMonthView.isSingleSelectionOnly());
}
}

protected void onDayTapped(CalendarDay calendarDay) {
protected void onDayTapped(CalendarDay calendarDay, boolean selection) {
mController.onDayOfMonthSelected(calendarDay.year, calendarDay.month, calendarDay.day);
setSelectedDay(calendarDay);
setSelectedDay(calendarDay, selection);
}

public void setSelectedDay(CalendarDay calendarDay) {
if (selectedDays.getFirst() != null && selectedDays.getLast() == null)
public void setSelectedDay(CalendarDay calendarDay, boolean selection) {
if (selectedDays.getFirst() != null && selectedDays.getLast() == null && !selection)
{
selectedDays.setLast(calendarDay);

Expand Down Expand Up @@ -288,4 +288,4 @@ public void setLast(K last)
this.last = last;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class SimpleMonthView extends View
private int mDayOfWeekStart = 0;
protected int mMonth;
protected Boolean mDrawRect;
protected Boolean mSingleSelection;
protected int mRowHeight = DEFAULT_HEIGHT;
protected int mWidth;
protected int mYear;
Expand Down Expand Up @@ -138,6 +139,8 @@ public SimpleMonthView(Context context, TypedArray typedArray)
mMonthTitleBGColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayText, resources.getColor(R.color.selected_day_text));

mDrawRect = typedArray.getBoolean(R.styleable.DayPickerView_drawRoundRect, false);

mSingleSelection = typedArray.getBoolean(R.styleable.DayPickerView_singleSelectionOnly, false);

mStringBuilder = new StringBuilder(50);

Expand Down Expand Up @@ -437,6 +440,10 @@ public void setMonthParams(HashMap<String, Integer> params) {

mNumRows = calculateNumRows();
}

public boolean isSingleSelectionOnly() {
return mSingleSelection;
}

public void setOnDayClickListener(OnDayClickListener onDayClickListener) {
mOnDayClickListener = onDayClickListener;
Expand All @@ -445,4 +452,4 @@ public void setOnDayClickListener(OnDayClickListener onDayClickListener) {
public static abstract interface OnDayClickListener {
public abstract void onDayClick(SimpleMonthView simpleMonthView, SimpleMonthAdapter.CalendarDay calendarDay);
}
}
}
3 changes: 2 additions & 1 deletion library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<attr name="enablePreviousDay" format="boolean" />
<attr name="currentDaySelected" format="boolean" />
<attr name="drawRoundRect" format="boolean" />
<attr name="singleSelectionOnly" format="boolean" />
<attr name="firstMonth" format="enum">
<enum name="january" value="0" />
<enum name="february" value="1" />
Expand Down Expand Up @@ -46,4 +47,4 @@
<enum name="december" value="11" />
</attr>
</declare-styleable>
</resources>
</resources>