aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditListingRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java5
17 files changed, 36 insertions, 30 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java
index 1837d6e5..2971a150 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java
@@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit;
import android.os.Handler;
+import androidx.annotation.NonNull;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
@@ -22,7 +24,7 @@ public class FetchPostFilterReadPostsAndConcatenatedSubredditNames {
}
public static void fetchPostFilterAndReadPosts(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
- Handler handler, String accountName, int postFilterUsage,
+ Handler handler, @NonNull String accountName, int postFilterUsage,
String nameOfUsage, FetchPostFilterAndReadPostsListener fetchPostFilterAndReadPostsListener) {
executor.execute(() -> {
List<PostFilter> postFilters = redditDataRoomDatabase.postFilterDao().getValidPostFilters(postFilterUsage, nameOfUsage);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
index c14d930c..50e4d725 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
@@ -160,7 +160,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
return true;
}
- if (mAccessToken != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
String jsonModel = new MultiRedditJSONModel(nameEditText.getText().toString(), descriptionEditText.getText().toString(),
visibilitySwitch.isChecked(), mSubreddits).createJSONModel();
CreateMultiReddit.createMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken,
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
index 257ad00a..a7656c8f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -339,7 +339,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
startActivityForResult(intent, CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE);
});
- if (mAccessToken != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
fab.setOnLongClickListener(view -> {
FilteredThingFABMoreOptionsBottomSheetFragment filteredThingFABMoreOptionsBottomSheetFragment
= new FilteredThingFABMoreOptionsBottomSheetFragment();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
index 3e019455..9c916fe1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
@@ -300,7 +300,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
}
return true;
} else if (item.getItemId() == R.id.action_read_all_messages_inbox_activity) {
- if (mAccessToken != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Toast.makeText(this, R.string.please_wait, Toast.LENGTH_SHORT).show();
mOauthRetrofit.create(RedditAPI.class).readAllMessages(APIUtils.getOAuthHeader(mAccessToken))
.enqueue(new Callback<>() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 4cf166f6..45492485 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -988,7 +988,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
loadUserData();
- if (mAccessToken != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mMessageFullname != null) {
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
@Override
@@ -1006,7 +1006,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
private void loadSubscriptions() {
- if (mAccessToken != null && !mFetchSubscriptionsSuccess) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !mFetchSubscriptionsSuccess) {
FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null,
new ArrayList<>(), new ArrayList<>(),
new ArrayList<>(),
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
index 25108607..09d36b79 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
@@ -34,6 +34,7 @@ import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
@@ -150,7 +151,7 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
return;
}
- if (mAccessToken != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
loadMultiReddits();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
index bc22542b..f79d4667 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
@@ -324,7 +324,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
return;
}
- if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !(!forceLoad && mInsertSuccess)) {
FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null,
new ArrayList<>(), new ArrayList<>(),
new ArrayList<>(),
@@ -376,7 +376,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
}
private void loadMultiReddits() {
- if (mAccessToken != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
@Override
public void success(ArrayList<MultiReddit> multiReddits) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
index 3ded569d..64539461 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
@@ -528,6 +528,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_EDIT_AND_DELETE_AVAILABLE, true);
}
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
+ bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putParcelable(CommentMoreBottomSheetFragment.EXTRA_COMMENT, comment);
bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, getBindingAdapterPosition());
CommentMoreBottomSheetFragment commentMoreBottomSheetFragment = new CommentMoreBottomSheetFragment();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index e7f645c0..7faa3a23 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -1393,6 +1393,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_EDIT_AND_DELETE_AVAILABLE, true);
}
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
+ bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putParcelable(CommentMoreBottomSheetFragment.EXTRA_COMMENT, comment);
if (mIsSingleCommentThreadMode) {
bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, getBindingAdapterPosition() - 1);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 31720785..f356b8fb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -3255,7 +3255,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
void markPostRead(Post post, boolean changePostItemColor) {
- if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !post.isRead() && mMarkPostsAsRead) {
post.markAsRead();
if (changePostItemColor) {
if (itemViewIsNotCardView) {
@@ -4584,7 +4584,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
void markPostRead(Post post, boolean changePostItemColor) {
- if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !post.isRead() && mMarkPostsAsRead) {
post.markAsRead();
if (changePostItemColor) {
itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
@@ -4770,7 +4770,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
void markPostRead(Post post, boolean changePostItemColor) {
- if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !post.isRead() && mMarkPostsAsRead) {
post.markAsRead();
if (changePostItemColor) {
itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
@@ -4958,7 +4958,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
void markPostRead(Post post, boolean changePostItemColor) {
- if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !post.isRead() && mMarkPostsAsRead) {
post.markAsRead();
if (changePostItemColor) {
itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
@@ -5994,7 +5994,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
void markPostRead(Post post, boolean changePostItemColor) {
- if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !post.isRead() && mMarkPostsAsRead) {
post.markAsRead();
if (changePostItemColor) {
itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostFilledCardViewBackgroundColor));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditListingRecyclerViewAdapter.java
index e1cd8a1c..bdd28bdc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditListingRecyclerViewAdapter.java
@@ -31,6 +31,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsSubscribedToSubreddit;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@@ -156,7 +157,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
public void isNotSubscribed() {
((DataViewHolder) holder).subscribeButton.setVisibility(View.VISIBLE);
((DataViewHolder) holder).subscribeButton.setOnClickListener(view -> {
- if (accessToken != null) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
SubredditSubscription.subscribeToSubreddit(executor, new Handler(),
oauthRetrofit, retrofit, accessToken, subredditData.getName(),
accountName, redditDataRoomDatabase,
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
index f8ad6cb2..59345840 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
@@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.CommentFilterPreferenceActivity;
@@ -37,6 +38,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
public static final String EXTRA_COMMENT = "ECF";
public static final String EXTRA_ACCESS_TOKEN = "EAT";
+ public static final String EXTRA_ACCOUNT_NAME = "EAN";
public static final String EXTRA_EDIT_AND_DELETE_AVAILABLE = "EEADA";
public static final String EXTRA_POSITION = "EP";
public static final String EXTRA_SHOW_REPLY_AND_SAVE_OPTION = "ESSARO";
@@ -70,10 +72,11 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
return binding.getRoot();
}
String accessToken = bundle.getString(EXTRA_ACCESS_TOKEN);
+ String accountName = bundle.getString(EXTRA_ACCOUNT_NAME);
boolean editAndDeleteAvailable = bundle.getBoolean(EXTRA_EDIT_AND_DELETE_AVAILABLE, false);
boolean showReplyAndSaveOption = bundle.getBoolean(EXTRA_SHOW_REPLY_AND_SAVE_OPTION, false);
- if (accessToken != null && !accessToken.equals("")) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT) && !accessToken.equals("")) {
if (editAndDeleteAvailable) {
binding.editTextViewCommentMoreBottomSheetFragment.setVisibility(View.VISIBLE);
binding.deleteTextViewCommentMoreBottomSheetFragment.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
index 10244d4a..bced3f57 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
@@ -446,7 +446,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
if (postFilter == null) {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), null, PostFilterUsage.HISTORY_TYPE, PostFilterUsage.HISTORY_TYPE_USAGE_READ_POSTS, (postFilter, readPostList) -> {
+ new Handler(), accountName, PostFilterUsage.HISTORY_TYPE, PostFilterUsage.HISTORY_TYPE_USAGE_READ_POSTS, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
this.postFilter = postFilter;
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index 712eeb0a..624c4848 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -917,12 +917,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
((ActivityToolbarInterface) activity).displaySortType();
}
- if (accessToken != null && !accessToken.equals("")) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mPostHistorySharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false) && readPosts == null) {
if (getArguments().getBoolean(EXTRA_DISABLE_READ_POSTS, false)) {
if (postFilter == null) {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> {
+ new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
this.postFilter = postFilter;
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false);
@@ -948,7 +948,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} else {
if (postFilter == null) {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> {
+ new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
this.postFilter = postFilter;
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false);
@@ -999,7 +999,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
} else {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> {
+ new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
this.postFilter = postFilter;
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java
index d0177aaf..cda55e3b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java
@@ -150,7 +150,7 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
mGlide.clear(mImageView);
}
- if (accessToken != null) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
adapter.addUser(accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
}
adapter.setSubscribedSubreddits(subscribedSubredditData);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
index 1d30084b..1ee0d0d0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -576,7 +576,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
}
private void bindView() {
- if (mAccessToken != null && mMessageFullname != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && mMessageFullname != null) {
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
@Override
public void readSuccess() {
@@ -682,7 +682,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mMenu.findItem(R.id.action_comment_view_post_detail_fragment).setVisible(true);
mMenu.findItem(R.id.action_sort_view_post_detail_fragment).setVisible(true);
- if (mAccessToken != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mPost.isSaved()) {
saveItem.setVisible(true);
saveItem.setIcon(mSavedIcon);
@@ -976,7 +976,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
}
return true;
} else if (itemId == R.id.action_save_view_post_detail_fragment) {
- if (mPost != null && mAccessToken != null) {
+ if (mPost != null && !mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mPost.isSaved()) {
item.setIcon(mUnsavedIcon);
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(),
@@ -1040,7 +1040,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
startActivity(crosspostIntent);
return true;
} else if (itemId == R.id.action_hide_view_post_detail_fragment) {
- if (mPost != null && mAccessToken != null) {
+ if (mPost != null && !mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mPost.isHidden()) {
Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_hide_post));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java
index 3201cc6d..e19e5492 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java
@@ -5,8 +5,6 @@ import android.text.TextUtils;
import androidx.annotation.NonNull;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import ml.docilealligator.infinityforreddit.SortType;
@@ -59,8 +57,7 @@ public class FetchSubredditData {
boolean nsfw, final FetchSubredditListingDataListener fetchSubredditListingDataListener) {
RedditAPI api = retrofit.create(RedditAPI.class);
- Map<String, String> map = new HashMap<>();
- Map<String, String> headers = accessToken != null ? APIUtils.getOAuthHeader(accessToken) : Collections.unmodifiableMap(map);
+ Map<String, String> headers = APIUtils.getOAuthHeader(accessToken);
Call<String> subredditDataCall = api.searchSubreddits(query, after, sortType, nsfw ? 1 : 0, headers);
subredditDataCall.enqueue(new Callback<String>() {
@Override