Skip to content

Commit

Permalink
Settings: Don't directly call onStart/onStop on dialogs
Browse files Browse the repository at this point in the history
This messes with dialog lifecycle, move to onResume/onPause instead,
which also gets automatically called on preferences

Change-Id: I3bb0a25e275822bdc481ff659fc9c7f39541473c
  • Loading branch information
SebaUbuntu authored and GuidixX committed Jun 24, 2024
1 parent 77346f2 commit a81cc8c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: 2012 The CyanogenMod Project
* SPDX-FileCopyrightText: 2017-2022 The LineageOS Project
* SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -115,15 +115,17 @@ public void onBindViewHolder(PreferenceViewHolder holder) {
holder.itemView.setOnLongClickListener(this);
}

public void onStop() {
@Override
public void onPause() {
if (getDialog() != null) {
getDialog().onStop();
getDialog().onPause();
}
}

public void onStart() {
@Override
public void onResume() {
if (getDialog() != null) {
getDialog().onStart();
getDialog().onResume();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-FileCopyrightText: 2010 Daniel Nilsson
* SPDX-FileCopyrightText: 2012 The CyanogenMod Project
* SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
* SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -194,15 +194,11 @@ public void onRestoreInstanceState(Bundle state) {
mColorPicker.setColor(state.getInt(STATE_KEY_COLOR), true);
}

@Override
public void onStop() {
super.onStop();
public void onPause() {
dismissLed();
}

@Override
public void onStart() {
super.onStart();
public void onResume() {
updateLed();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: 2012 The CyanogenMod Project
* SPDX-FileCopyrightText: 2017-2023 The LineageOS Project
* SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -244,35 +244,6 @@ private void refreshDefault() {
}
}

@Override
public void onStart() {
super.onStart();
setChildrenStarted(getPreferenceScreen(), true);
}

@Override
public void onStop() {
super.onStop();
setChildrenStarted(getPreferenceScreen(), false);
}

private void setChildrenStarted(PreferenceGroup group, boolean started) {
final int count = group.getPreferenceCount();
for (int i = 0; i < count; i++) {
Preference pref = group.getPreference(i);
if (pref instanceof ApplicationLightPreference) {
ApplicationLightPreference ap = (ApplicationLightPreference) pref;
if (started) {
ap.onStart();
} else {
ap.onStop();
}
} else if (pref instanceof PreferenceGroup) {
setChildrenStarted((PreferenceGroup) pref, started);
}
}
}

private void refreshCustomApplicationPrefs() {
Context context = getActivity();

Expand Down

0 comments on commit a81cc8c

Please sign in to comment.