mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Merge branch 'edi_habit_crash' into dev
This commit is contained in:
@@ -19,17 +19,19 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.activities.common.dialogs;
|
package org.isoron.uhabits.activities.common.dialogs;
|
||||||
|
|
||||||
import android.app.*;
|
import android.app.Dialog;
|
||||||
import android.content.*;
|
import android.content.DialogInterface;
|
||||||
import android.os.*;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.app.*;
|
import android.support.v7.app.AppCompatDialogFragment;
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.core.models.*;
|
import org.isoron.uhabits.core.models.WeekdayList;
|
||||||
import org.isoron.uhabits.core.utils.*;
|
import org.isoron.uhabits.core.utils.DateUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Calendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog that allows the user to pick one or more days of the week.
|
* Dialog that allows the user to pick one or more days of the week.
|
||||||
@@ -38,6 +40,7 @@ public class WeekdayPickerDialog extends AppCompatDialogFragment implements
|
|||||||
DialogInterface.OnMultiChoiceClickListener,
|
DialogInterface.OnMultiChoiceClickListener,
|
||||||
DialogInterface.OnClickListener
|
DialogInterface.OnClickListener
|
||||||
{
|
{
|
||||||
|
private static final String KEY_SELECTED_DAYS = "selectedDays";
|
||||||
private boolean[] selectedDays;
|
private boolean[] selectedDays;
|
||||||
|
|
||||||
private OnWeekdaysPickedListener listener;
|
private OnWeekdaysPickedListener listener;
|
||||||
@@ -48,6 +51,21 @@ public class WeekdayPickerDialog extends AppCompatDialogFragment implements
|
|||||||
selectedDays[which] = isChecked;
|
selectedDays[which] = isChecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if(savedInstanceState != null){
|
||||||
|
selectedDays = savedInstanceState.getBooleanArray(KEY_SELECTED_DAYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBooleanArray(KEY_SELECTED_DAYS, selectedDays);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which)
|
public void onClick(DialogInterface dialog, int which)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.activities.habits.edit;
|
package org.isoron.uhabits.activities.habits.edit;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.*;
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.support.annotation.*;
|
import android.support.annotation.*;
|
||||||
@@ -27,7 +27,7 @@ import android.support.v7.app.*;
|
|||||||
import android.text.format.*;
|
import android.text.format.*;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
|
|
||||||
import com.android.datetimepicker.time.*;
|
import com.android.datetimepicker.time.TimePickerDialog;
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
@@ -40,7 +40,7 @@ import org.isoron.uhabits.core.preferences.*;
|
|||||||
|
|
||||||
import butterknife.*;
|
import butterknife.*;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.*;
|
||||||
|
|
||||||
public class EditHabitDialog extends AppCompatDialogFragment
|
public class EditHabitDialog extends AppCompatDialogFragment
|
||||||
{
|
{
|
||||||
@@ -48,6 +48,8 @@ public class EditHabitDialog extends AppCompatDialogFragment
|
|||||||
|
|
||||||
public static final String BUNDLE_HABIT_TYPE = "habitType";
|
public static final String BUNDLE_HABIT_TYPE = "habitType";
|
||||||
|
|
||||||
|
private static final String WEEKDAY_PICKER_TAG = "weekdayPicker";
|
||||||
|
|
||||||
protected Habit originalHabit;
|
protected Habit originalHabit;
|
||||||
|
|
||||||
protected Preferences prefs;
|
protected Preferences prefs;
|
||||||
@@ -109,6 +111,8 @@ public class EditHabitDialog extends AppCompatDialogFragment
|
|||||||
setupReminderController();
|
setupReminderController();
|
||||||
setupNameController();
|
setupNameController();
|
||||||
|
|
||||||
|
restoreChildFragmentListeners();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,8 +272,16 @@ public class EditHabitDialog extends AppCompatDialogFragment
|
|||||||
WeekdayPickerDialog dialog = new WeekdayPickerDialog();
|
WeekdayPickerDialog dialog = new WeekdayPickerDialog();
|
||||||
dialog.setListener(reminderPanel);
|
dialog.setListener(reminderPanel);
|
||||||
dialog.setSelectedDays(currentDays);
|
dialog.setSelectedDays(currentDays);
|
||||||
dialog.show(getFragmentManager(), "weekdayPicker");
|
dialog.show(getChildFragmentManager(), WEEKDAY_PICKER_TAG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void restoreChildFragmentListeners()
|
||||||
|
{
|
||||||
|
final WeekdayPickerDialog dialog =
|
||||||
|
(WeekdayPickerDialog) getChildFragmentManager()
|
||||||
|
.findFragmentByTag(WEEKDAY_PICKER_TAG);
|
||||||
|
if(dialog != null) dialog.setListener(reminderPanel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user