Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 300b1253 authored by James Lemieux's avatar James Lemieux Committed by android-build-merger
Browse files

Fix DeskClock recreation after altering settings

am: feec1985

* commit 'feec1985':
  Fix DeskClock recreation after altering settings
parents 5c940a2e feec1985
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@ public class DeskClock extends BaseActivity
    private TabsAdapter mTabsAdapter;
    private int mSelectedTab;

    /** {@code true} when a settings change necessitates recreating this activity. */
    private boolean mRecreateActivity;

    @Override
    public void onNewIntent(Intent newIntent) {
        super.onNewIntent(newIntent);
@@ -213,6 +216,24 @@ public class DeskClock extends BaseActivity
        DataModel.getDataModel().setApplicationInForeground(true);
    }

    @Override
    protected void onPostResume() {
        super.onPostResume();

        if (mRecreateActivity) {
            mRecreateActivity = false;

            // A runnable must be posted here or the new DeskClock activity will be recreated in a
            // paused state, even though it is the foreground activity.
            mViewPager.post(new Runnable() {
                @Override
                public void run() {
                    recreate();
                }
            });
        }
    }

    @Override
    public void onPause() {
        DataModel.getDataModel().setApplicationInForeground(false);
@@ -251,7 +272,7 @@ public class DeskClock extends BaseActivity
        // Recreate the activity if any settings have been changed
        if (requestCode == SettingMenuItemController.REQUEST_CHANGE_SETTINGS
                && resultCode == RESULT_OK) {
            recreate();
            mRecreateActivity = true;
        }
    }