diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-09-28 13:13:06 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-09-28 13:13:06 +0000 |
commit | 1896b971cd2e7ea373ed2f333859e093901b9d9c (patch) | |
tree | cfad0bb7854be90cf33d7d843be2310f4d60b104 /app/src/main | |
parent | d5f3761973e20acb63e10bbfea529b2d1b3fbc85 (diff) | |
download | infinity-for-reddit-1896b971cd2e7ea373ed2f333859e093901b9d9c.tar infinity-for-reddit-1896b971cd2e7ea373ed2f333859e093901b9d9c.tar.gz infinity-for-reddit-1896b971cd2e7ea373ed2f333859e093901b9d9c.tar.bz2 infinity-for-reddit-1896b971cd2e7ea373ed2f333859e093901b9d9c.tar.lz infinity-for-reddit-1896b971cd2e7ea373ed2f333859e093901b9d9c.tar.xz infinity-for-reddit-1896b971cd2e7ea373ed2f333859e093901b9d9c.tar.zst infinity-for-reddit-1896b971cd2e7ea373ed2f333859e093901b9d9c.zip |
Delete anonymous multireddit in ViewMultiredditDetailActivity.
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java index d6c96495..2b2cd198 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java @@ -39,6 +39,7 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; +import ml.docilealligator.infinityforreddit.asynctasks.DeleteMultiredditInDatabase; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomSheetFragment; @@ -159,7 +160,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT setToolbarGoToTop(toolbar); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); - mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null); + mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-"); if (savedInstanceState != null) { isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); @@ -265,22 +266,32 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT .setTitle(R.string.delete) .setMessage(R.string.delete_multi_reddit_dialog_message) .setPositiveButton(R.string.delete, (dialogInterface, i) - -> DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase, - mAccessToken, mAccountName, multiPath, new DeleteMultiReddit.DeleteMultiRedditListener() { - @Override - public void success() { - Toast.makeText(ViewMultiRedditDetailActivity.this, - R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show(); - EventBus.getDefault().post(new RefreshMultiRedditsEvent()); - finish(); - } - - @Override - public void failed() { - Toast.makeText(ViewMultiRedditDetailActivity.this, - R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show(); - } - })) + -> { + if (mAccessToken == null) { + DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiPath, + () -> { + Toast.makeText(this, R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show(); + finish(); + }); + } else { + DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase, + mAccessToken, mAccountName, multiPath, new DeleteMultiReddit.DeleteMultiRedditListener() { + @Override + public void success() { + Toast.makeText(ViewMultiRedditDetailActivity.this, + R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show(); + EventBus.getDefault().post(new RefreshMultiRedditsEvent()); + finish(); + } + + @Override + public void failed() { + Toast.makeText(ViewMultiRedditDetailActivity.this, + R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show(); + } + }); + } + }) .setNegativeButton(R.string.cancel, null) .show(); return true; |