Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. // On clicking Time picker
  2. public void setTime(View v){
  3. Calendar now = Calendar.getInstance();
  4. TimePickerDialog tpd = TimePickerDialog.newInstance(
  5. this,
  6. now.get(Calendar.HOUR_OF_DAY),
  7. now.get(Calendar.MINUTE),
  8. false
  9. );
  10. tpd.setThemeDark(false);
  11. tpd.show(getFragmentManager(), "Timepickerdialog");
  12. }
  13.  
  14. // On clicking Date picker
  15. public void setDate(View v){
  16. Calendar now = Calendar.getInstance();
  17. DatePickerDialog dpd = DatePickerDialog.newInstance(
  18. this,
  19. now.get(Calendar.YEAR),
  20. now.get(Calendar.MONTH),
  21. now.get(Calendar.DAY_OF_MONTH)
  22. );
  23. dpd.show(getFragmentManager(), "Datepickerdialog");
  24. }
  25.  
  26. mWaterCalendar = mCalendar;
  27. mFeedCalendar = mCalendar;
  28. mHarvestCalendar = mCalendar;
  29. etc.
  30.  
  31. else if (radioWaterWeekly == radioWateringSchedule) {
  32. // Weekly Watering is selected
  33. mWaterCalendar.add(Calendar.DAY_OF_YEAR, 7);
  34. mTitle = "It's time for your weekly watering.";
  35. mRepeat = "true";
  36. mRepeatType = "Weekly";
  37. mRepeatTime = milWeek;
  38. Toast.makeText(GrowAssistantActivity.this, "Water Weekly Selected", Toast.LENGTH_SHORT).show();
  39. SetNotificationsButtonWater(v);
  40. }
  41.  
  42. if (radioSoil == radioGrowMediumChoice) {
  43. // Soil is selected
  44. mHarvestCalendar.add(Calendar.DAY_OF_YEAR, 70);
  45. mFlushCalendar = mHarvestCalendar
  46. SetNotificationsButtonHarvestDay(v);
  47. mFlushCalendar.add(Calendar.DAY_OF_YEAR, -14);
  48. Toast.makeText(GrowAssistantActivity.this, "Soil Grow Selected", Toast.LENGTH_SHORT).show();
  49. SetNotificationsButtonFlush(v);
  50. }
  51.  
  52. // WATERING REMINDERS - On clicking the set notifications button
  53. public void SetNotificationsButtonWater(View v){
  54. ReminderDatabase rb = new ReminderDatabase(this);
  55. mHour = mWaterCalendar.get(Calendar.HOUR_OF_DAY);
  56. mMinute = mWaterCalendar.get(Calendar.MINUTE);
  57. mYear = mWaterCalendar.get(Calendar.YEAR);
  58. mMonth = mWaterCalendar.get(Calendar.MONTH) + 1;
  59. mDay = mWaterCalendar.get(Calendar.DATE);
  60. mDate = mDay + "/" + mMonth + "/" + mYear;
  61. mRepeat = "true";
  62. // Creating Reminder
  63. int ID = rb.addReminder(new Reminder(mTitle, mDate, mTime, mRepeat, mRepeatNo, mRepeatType, mActive));
  64. // Create a new notification
  65. new AlarmReceiver().setRepeatAlarm(getApplicationContext(), mWaterCalendar, ID, mRepeatTime);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement