@Override public void onClick(View v) { switch (v.getId()) { case R.id.tv_enable: config.setWidgetCountdownEnable(true); getActivity().finish(); break; case R.id.tv_disable: config.setWidgetCountdownEnable(false); getActivity().finish(); break; case R.id.tv_countdown_content: Intent intent = new Intent(getActivity(), CommentActivity.class); intent.putExtra(Constants.StringConstant.PARAMS_DATA, config.getCountdownContent()); intent.putExtra(Constants.StringConstant.PARAMS_DATA1, config.getWidgetCountdownColor()); startActivityForResult(intent, Constants.RequestCode.REQUEST_CODE_CHAGE_TEXT_TITLE); break; case R.id.tv_countdown_time: calendar.setTimeInMillis(config.getCountdownTimestamp()); dpd = DatePickerDialog.newInstance( this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), false); tpd = TimePickerDialog.newInstance( this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false, false); dpd.setYearRange(Constants.CommonValue.FIRST_YEAR, Constants.CommonValue.LAST_YEAR); dpd.setCloseOnSingleTapDay(false); dpd.show(getFragmentManager(), TAG); break; default: break; } }
@Override public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) { dateSelected = true; final long timestamp = initial.withYear(year).withMonthOfYear(month + 1).withDayOfMonth(day).getMillis(); datePickerDialog.dismiss(); startActivity( new Intent(this, TimePickerActivity.class) { { addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); putExtra(TimePickerActivity.EXTRA_TIMESTAMP, timestamp); } }); finish(); }
/** @param id */ protected boolean onItemSelected(int id) { Bundle args; boolean consumed = false; Calendar calendar = null; switch (id) { case Statics.ITEM_SAVE: saveTimer(); consumed = true; break; case Statics.ITEM_CANCEL: finish(Activity.RESULT_CANCELED); consumed = true; break; case Statics.ITEM_PICK_SERVICE: pickService(); consumed = true; break; case Statics.ITEM_PICK_BEGIN_DATE: calendar = getCalendar(mBegin); DatePickerDialog datePickerDialogBegin = DatePickerDialog.newInstance( new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet( DatePickerDialog datePickerDialog, int year, int month, int day) { TimerEditFragment.this.onDateSet(true, year, month, day); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), true); getMultiPaneHandler().showDialogFragment(datePickerDialogBegin, "dialog_pick_begin_date"); consumed = true; break; case Statics.ITEM_PICK_BEGIN_TIME: calendar = getCalendar(mBegin); TimePickerDialog timePickerDialogBegin = TimePickerDialog.newInstance( new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet( RadialPickerLayout radialPickerLayout, int hour, int minute) { TimerEditFragment.this.onTimeSet(true, hour, minute); } }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true, true); getMultiPaneHandler().showDialogFragment(timePickerDialogBegin, "dialog_pick_begin_time"); consumed = true; break; case Statics.ITEM_PICK_END_DATE: calendar = getCalendar(mEnd); DatePickerDialog datePickerDialogEnd = DatePickerDialog.newInstance( new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet( DatePickerDialog datePickerDialog, int year, int month, int day) { TimerEditFragment.this.onDateSet(false, year, month, day); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), true); getMultiPaneHandler().showDialogFragment(datePickerDialogEnd, "dialog_pick_end_date"); consumed = true; break; case Statics.ITEM_PICK_END_TIME: calendar = getCalendar(mEnd); TimePickerDialog timePickerDialogEnd = TimePickerDialog.newInstance( new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet( RadialPickerLayout radialPickerLayout, int hour, int minute) { TimerEditFragment.this.onTimeSet(false, hour, minute); } }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true, true); getMultiPaneHandler().showDialogFragment(timePickerDialogEnd, "dialog_pick_end_time"); consumed = true; break; case Statics.ITEM_PICK_REPEATED: pickRepeatings(); consumed = true; break; case Statics.ITEM_PICK_TAGS: pickTags(); consumed = true; break; default: consumed = super.onItemSelected(id); break; } return consumed; }