Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
AlertDialog added to CreateMulti when exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
Barrett97 committed Aug 11, 2020
1 parent 42c6229 commit 101324c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ public void onComplete(List<MultiReddit> multis) {
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}

@Override
public void onBackPressed() {
new AlertDialogWrapper.Builder(CreateMulti.this).setTitle(R.string.general_confirm_exit)
.setMessage(R.string.multi_save_option)
.setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
MultiredditOverview.multiActivity.finish();
new SaveMulti().execute();
}
})
.setNegativeButton(R.string.btn_no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
finish();
}
})
.show();
}

public void showSelectDialog() {
//List of all subreddits of the multi
List<String> multiSubs = new ArrayList<>(subs);
Expand Down Expand Up @@ -353,6 +373,7 @@ protected Void doInBackground(Void... params) {
@Override
public void run() {
Log.v(LogUtil.getTag(), "Update Subreddits");
MultiredditOverview.multiActivity.finish();
new UserSubscriptions.SyncMultireddits(CreateMulti.this).execute();
}
});
Expand Down Expand Up @@ -433,6 +454,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
.setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MultiredditOverview.multiActivity.finish();
new MaterialDialog.Builder(CreateMulti.this)
.title(R.string.deleting)
.progress(true, 100)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.ccrama.redditslide.Activities;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
Expand Down Expand Up @@ -67,6 +68,8 @@ public class MultiredditOverview extends BaseActivityAnim {
public static final String EXTRA_PROFILE = "profile";
public static final String EXTRA_MULTI = "multi";

public static Activity multiActivity;

public static MultiReddit searchMulti;
public OverviewPagerAdapter adapter;
private ViewPager pager;
Expand Down Expand Up @@ -423,6 +426,8 @@ public void onClick(DialogInterface dialog, int which) {
public void onCreate(Bundle savedInstance) {
overrideSwipeFromAnywhere();

multiActivity = this;

super.onCreate(savedInstance);

applyColorTheme("");
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@
<string name="multi_submit_which_sub">Which sub would you like to submit to?</string>
<string name="multi_saved_successfully">Saved successfully</string>
<string name="delete_multireddit_title">Do you really want to delete /m/%1$s?</string>
<string name="multi_save_option">Would you like to save this multireddit?</string>



<!-- Content types -->
Expand Down

0 comments on commit 101324c

Please sign in to comment.