Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow hiding duration view #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -159,6 +159,8 @@ public class SmoothDateRangePickerFragment extends DialogFragment implements OnC

private boolean mDelayAnimation = true;

private boolean mShowDuration = true;

// Accessibility strings.
private String mDayPickerDescription;
private String mSelectDay;
Expand Down Expand Up @@ -204,10 +206,25 @@ public SmoothDateRangePickerFragment() {
* @param dayOfMonth The initial day of the dialog.
*/
public static SmoothDateRangePickerFragment newInstance(OnDateRangeSetListener callBack, int year,
int monthOfYear,
int dayOfMonth) {
int monthOfYear,
int dayOfMonth,
boolean showDuration) {
SmoothDateRangePickerFragment ret = new SmoothDateRangePickerFragment();
ret.initialize(callBack, year, monthOfYear, dayOfMonth);
ret.initialize(callBack, year, monthOfYear, dayOfMonth, showDuration);
return ret;
}

/**
* @param callBack How the parent is notified that the date is set.
* @param year The initial year of the dialog.
* @param monthOfYear The initial month of the dialog.
* @param dayOfMonth The initial day of the dialog.
*/
public static SmoothDateRangePickerFragment newInstance(OnDateRangeSetListener callBack, int year,
int monthOfYear,
int dayOfMonth) {
SmoothDateRangePickerFragment ret = new SmoothDateRangePickerFragment();
ret.initialize(callBack, year, monthOfYear, dayOfMonth, true);
return ret;
}

Expand All @@ -219,11 +236,11 @@ public static SmoothDateRangePickerFragment newInstance(OnDateRangeSetListener c
SmoothDateRangePickerFragment ret = new SmoothDateRangePickerFragment();
Calendar todayCal = Calendar.getInstance();
ret.initialize(callBack, todayCal.get(Calendar.YEAR), todayCal.get(Calendar.MONTH),
todayCal.get(Calendar.DAY_OF_MONTH));
todayCal.get(Calendar.DAY_OF_MONTH), true);
return ret;
}

public void initialize(OnDateRangeSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
public void initialize(OnDateRangeSetListener callBack, int year, int monthOfYear, int dayOfMonth, boolean showDuration) {
mCallBack = callBack;
mCalendar.set(Calendar.YEAR, year);
mCalendar.set(Calendar.MONTH, monthOfYear);
Expand All @@ -236,6 +253,7 @@ public void initialize(OnDateRangeSetListener callBack, int year, int monthOfYea
mAccentColor = -1;
mVibrate = true;
mDismissOnPause = false;
mShowDuration = showDuration;
}

@Override
Expand Down Expand Up @@ -320,6 +338,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
mYearViewEnd.setOnClickListener(this);

mDurationView = (LinearLayout) view.findViewById(R.id.date_picker_duration_layout);
if(!mShowDuration) {
mDurationView.setVisibility(View.GONE);
}
mDurationView.setOnClickListener(this);
mDurationTextView = (TextView) view.findViewById(R.id.date_picker_duration_days);
mDurationEditText = (EditText) view.findViewById(R.id.date_picker_duration_days_et);
Expand Down Expand Up @@ -781,6 +802,10 @@ public void setMaxDate(Calendar calendar) {
}
}

public void setShowDuration(boolean showDuration) {
this.mShowDuration = showDuration;
}

/**
* @return The maximal date supported by this DatePicker. Null if it has not been set.
*/
Expand Down