From 0c0ac9dee54cd6c4fad8fbd119216c9b0a73dcdf Mon Sep 17 00:00:00 2001 From: Alinson Xavier Date: Sat, 5 Mar 2016 06:48:25 -0500 Subject: [PATCH] Minor formatting --- .../uhabits/fragments/EditHabitFragment.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/isoron/uhabits/fragments/EditHabitFragment.java b/app/src/main/java/org/isoron/uhabits/fragments/EditHabitFragment.java index 82a32d37d..84bbf4822 100644 --- a/app/src/main/java/org/isoron/uhabits/fragments/EditHabitFragment.java +++ b/app/src/main/java/org/isoron/uhabits/fragments/EditHabitFragment.java @@ -57,8 +57,15 @@ public class EditHabitFragment extends DialogFragment private OnSavedListener onSavedListener; - private Habit originalHabit, modifiedHabit; - private TextView tvName, tvDescription, tvFreqNum, tvFreqDen, tvReminderTime, tvReminderDays; + private Habit originalHabit; + private Habit modifiedHabit; + + private TextView tvName; + private TextView tvDescription; + private TextView tvFreqNum; + private TextView tvFreqDen; + private TextView tvReminderTime; + private TextView tvReminderDays; private SharedPreferences prefs; private boolean is24HourMode; @@ -96,13 +103,13 @@ public class EditHabitFragment extends DialogFragment Button buttonSave = (Button) view.findViewById(R.id.buttonSave); Button buttonDiscard = (Button) view.findViewById(R.id.buttonDiscard); + ImageButton buttonPickColor = (ImageButton) view.findViewById(R.id.buttonPickColor); buttonSave.setOnClickListener(this); buttonDiscard.setOnClickListener(this); tvReminderTime.setOnClickListener(this); tvReminderDays.setOnClickListener(this); - - ImageButton buttonPickColor = (ImageButton) view.findViewById(R.id.buttonPickColor); + buttonPickColor.setOnClickListener(this); prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); @@ -140,8 +147,6 @@ public class EditHabitFragment extends DialogFragment changeColor(modifiedHabit.color); updateReminder(); - buttonPickColor.setOnClickListener(this); - return view; } @@ -225,8 +230,6 @@ public class EditHabitFragment extends DialogFragment private void onSaveButtonClick() { - Command command = null; - modifiedHabit.name = tvName.getText().toString().trim(); modifiedHabit.description = tvDescription.getText().toString().trim(); modifiedHabit.freqNum = Integer.parseInt(tvFreqNum.getText().toString()); @@ -239,6 +242,7 @@ public class EditHabitFragment extends DialogFragment editor.putInt("pref_default_habit_freq_den", modifiedHabit.freqDen); editor.apply(); + Command command = null; Habit savedHabit = null; if (mode == EDIT_MODE) @@ -246,8 +250,10 @@ public class EditHabitFragment extends DialogFragment command = new EditHabitCommand(originalHabit, modifiedHabit); savedHabit = originalHabit; } - - if (mode == CREATE_MODE) command = new CreateHabitCommand(modifiedHabit); + else if (mode == CREATE_MODE) + { + command = new CreateHabitCommand(modifiedHabit); + } if (onSavedListener != null) onSavedListener.onSaved(command, savedHabit); @@ -325,6 +331,7 @@ public class EditHabitFragment extends DialogFragment int count = 0; for(int i = 0; i < 7; i++) if(selectedDays[i]) count++; + if(count == 0) Arrays.fill(selectedDays, true); modifiedHabit.reminderDays = DateHelper.packWeekdayList(selectedDays);