From e5750e35b7945df6172868b153b325689c97e56e Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 10 Apr 2021 10:00:46 +0800 Subject: Fix unable to check anonymous subscription. --- .../activities/AnonymousSubscriptionsActivity.java | 11 +++++++++++ .../asynctasks/CheckIsSubscribedToSubreddit.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java index 2c40b1e8..f0e753b7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java @@ -3,10 +3,12 @@ package ml.docilealligator.infinityforreddit.activities; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; +import android.view.MenuItem; import android.view.View; import android.view.Window; import android.view.WindowManager; +import androidx.annotation.NonNull; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; @@ -99,4 +101,13 @@ public class AnonymousSubscriptionsActivity extends BaseActivity { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + if (item.getItemId() == android.R.id.home) { + finish(); + return true; + } + return false; + } } \ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java index d977f159..f6768d11 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java @@ -16,7 +16,7 @@ public class CheckIsSubscribedToSubreddit { if (!redditDataRoomDatabase.accountDao().isAnonymousAccountInserted()) { redditDataRoomDatabase.accountDao().insertAnonymousAccount(); } - SubscribedSubredditData subscribedSubredditData = redditDataRoomDatabase.subscribedSubredditDao().getSubscribedSubreddit(subredditName, accountName); + SubscribedSubredditData subscribedSubredditData = redditDataRoomDatabase.subscribedSubredditDao().getSubscribedSubreddit(subredditName, accountName == null ? "-" : accountName); handler.post(() -> { if (subscribedSubredditData != null) { checkIsSubscribedToSubredditListener.isSubscribed(); -- cgit v1.2.3