Show a dialog before closing CustomizeThemeActivity.

This commit is contained in:
Alex Ning 2021-10-08 20:19:50 +08:00
parent bac1dca855
commit f5a333e2ac
2 changed files with 14 additions and 12 deletions

View File

@ -15,6 +15,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import org.greenrobot.eventbus.EventBus;
@ -27,6 +28,9 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.adapters.CustomizeThemeRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.asynctasks.GetCustomTheme;
import ml.docilealligator.infinityforreddit.asynctasks.InsertCustomTheme;
@ -34,9 +38,6 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
public class CustomizeThemeActivity extends BaseActivity {
@ -230,6 +231,16 @@ public class CustomizeThemeActivity extends BaseActivity {
}
}
@Override
public void onBackPressed() {
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.discard)
.setPositiveButton(R.string.discard_dialog_button, (dialogInterface, i)
-> super.onBackPressed())
.setNegativeButton(R.string.no, null)
.show();
}
@Override
protected SharedPreferences getDefaultSharedPreferences() {
return sharedPreferences;

View File

@ -1,9 +0,0 @@
package ml.docilealligator.infinityforreddit.events;
public class ChangeConfirmToExitEvent {
public boolean confirmToExit;
public ChangeConfirmToExitEvent(boolean confirmToExit) {
this.confirmToExit = confirmToExit;
}
}