Implement save and restore instance state
This commit is contained in:
parent
6585cca738
commit
65671c3650
@ -222,7 +222,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog /*DialogFra
|
||||
}
|
||||
|
||||
if (index == MINUTE_INDEX) {
|
||||
createMinutesGrid();
|
||||
createMinuteTuners();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -277,7 +277,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog /*DialogFra
|
||||
onValueSelected(HOUR_INDEX, mSelectedHourOfDay, false);
|
||||
}
|
||||
|
||||
private void createMinutesGrid() {
|
||||
private void createMinuteTuners() {
|
||||
// https://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-by.html
|
||||
// "When inflating a layout starting with a <merge />, you *must* specify a parent ViewGroup
|
||||
// and you must set attachToRoot to true (see the documentation of the LayoutInflater#inflate() method)"
|
||||
@ -442,7 +442,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog /*DialogFra
|
||||
mInitialHourOfDay = savedInstanceState.getInt(KEY_HOUR_OF_DAY);
|
||||
mInitialMinute = savedInstanceState.getInt(KEY_MINUTE);
|
||||
mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
|
||||
mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
|
||||
// mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
|
||||
mThemeDark = savedInstanceState.getBoolean(KEY_DARK_THEME);
|
||||
}
|
||||
}
|
||||
@ -464,7 +464,7 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog /*DialogFra
|
||||
setNumberTexts();
|
||||
setClickListenersOnButtons();
|
||||
if (mCurrentIndex == MINUTE_INDEX) {
|
||||
createMinutesGrid();
|
||||
createMinuteTuners();
|
||||
}
|
||||
|
||||
Resources res = getResources();
|
||||
@ -676,6 +676,11 @@ public class NumberGridTimePickerDialog extends BaseTimePickerDialog /*DialogFra
|
||||
// }
|
||||
// outState.putBoolean(KEY_DARK_THEME, mThemeDark);
|
||||
// }
|
||||
outState.putInt(KEY_HOUR_OF_DAY, mSelectedHourOfDay);
|
||||
outState.putInt(KEY_MINUTE, mSelectedMinute);
|
||||
outState.putBoolean(KEY_IS_24_HOUR_VIEW, mIs24HourMode);
|
||||
outState.putInt(KEY_CURRENT_ITEM_SHOWING, mCurrentIndex);
|
||||
outState.putBoolean(KEY_DARK_THEME, mThemeDark);
|
||||
}
|
||||
|
||||
// /**
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
app:columnCount="3"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_edge_margin"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_edge_margin"
|
||||
android:paddingBottom="28dp"/>
|
||||
android:paddingBottom="@dimen/anchored_fab_vertical_space"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
|
||||
@ -26,8 +26,11 @@ doesn't work. -->
|
||||
<com.philliphsu.clock2.editalarm.NumpadTimePicker
|
||||
android:id="@+id/number_grid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/numpad_height"
|
||||
android:layout_height="310dp"
|
||||
android:layout_below="@id/header_divider"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_vertical_space"/>
|
||||
android:layout_marginTop="@dimen/bottom_sheet_vertical_space"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_edge_margin"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_edge_margin"
|
||||
android:paddingBottom="@dimen/bottom_sheet_edge_margin"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@ -24,6 +24,7 @@
|
||||
<!-- Bottom sheet specs -->
|
||||
<dimen name="bottom_sheet_edge_margin">24dp</dimen>
|
||||
<dimen name="bottom_sheet_vertical_space">16dp</dimen>
|
||||
<dimen name="anchored_fab_vertical_space">28dp</dimen>
|
||||
<!-- If the total height of the contents of a bottom sheet does not exceed this limit,
|
||||
then the sheet will show fully expanded; the contents are not stretched to match this height.
|
||||
This is large enough to accommodate most, if not all, of our layouts. -->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user