aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-01-24 04:29:15 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-01-24 04:29:15 +0000
commitadaa1d3dc8ff37f911aa36f9f7bf12c66d6a0112 (patch)
treef8aa6fae985876c4cef6cbd8d1b4d2893c2ec407 /app/src/main/java/ml/docilealligator/infinityforreddit
parent2fdd38f188698041da45110df092215273bd8cba (diff)
downloadinfinity-for-reddit-adaa1d3dc8ff37f911aa36f9f7bf12c66d6a0112.tar
infinity-for-reddit-adaa1d3dc8ff37f911aa36f9f7bf12c66d6a0112.tar.gz
infinity-for-reddit-adaa1d3dc8ff37f911aa36f9f7bf12c66d6a0112.tar.bz2
infinity-for-reddit-adaa1d3dc8ff37f911aa36f9f7bf12c66d6a0112.tar.lz
infinity-for-reddit-adaa1d3dc8ff37f911aa36f9f7bf12c66d6a0112.tar.xz
infinity-for-reddit-adaa1d3dc8ff37f911aa36f9f7bf12c66d6a0112.tar.zst
infinity-for-reddit-adaa1d3dc8ff37f911aa36f9f7bf12c66d6a0112.zip
Version 6.7.1. Fix FetchSubredditData.fetchSubredditData not working in anonymous mode.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIcon.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java4
6 files changed, 12 insertions, 8 deletions
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 270694b4..a657d12c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -1430,7 +1430,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
editable.toString(), nsfw);
- subredditAutocompleteCall.enqueue(new Callback<String>() {
+ subredditAutocompleteCall.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index 3f8c21cc..3a6f2f41 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -582,7 +582,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private void fetchSubredditData() {
if (!mFetchSubredditInfoSuccess) {
- FetchSubredditData.fetchSubredditData(mOauthRetrofit, mRetrofit, subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
+ FetchSubredditData.fetchSubredditData(mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
mNCurrentOnlineSubscribers = nCurrentOnlineSubscribers;
@@ -1587,6 +1587,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
SidebarFragment fragment = new SidebarFragment();
Bundle bundle = new Bundle();
bundle.putString(SidebarFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
+ bundle.putString(SidebarFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(SidebarFragment.EXTRA_SUBREDDIT_NAME, subredditName);
fragment.setArguments(bundle);
return fragment;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIcon.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIcon.java
index bfdb8098..bf0121fd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIcon.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIcon.java
@@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.subreddit.FetchSubredditData;
import ml.docilealligator.infinityforreddit.subreddit.SubredditDao;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
@@ -26,7 +27,7 @@ public class LoadSubredditIcon {
String iconImageUrl = subredditDao.getSubredditData(subredditName).getIconUrl();
handler.post(() -> loadSubredditIconAsyncTaskListener.loadIconSuccess(iconImageUrl));
} else {
- handler.post(() -> FetchSubredditData.fetchSubredditData(oauthRetrofit, retrofit, subredditName, accessToken, new FetchSubredditData.FetchSubredditDataListener() {
+ handler.post(() -> FetchSubredditData.fetchSubredditData(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : oauthRetrofit, retrofit, subredditName, accessToken, new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData1, int nCurrentOnlineSubscribers) {
ArrayList<SubredditData> singleSubredditDataList = new ArrayList<>();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
index a8298a92..6e8bfb14 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
@@ -38,6 +38,7 @@ import io.noties.markwon.core.MarkwonTheme;
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.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewImageOrGifActivity;
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
@@ -65,6 +66,7 @@ public class SidebarFragment extends Fragment {
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
public static final String EXTRA_ACCESS_TOKEN = "EAT";
+ public static final String EXTRA_ACCOUNT_NAME = "EAN";
public SubredditViewModel mSubredditViewModel;
@BindView(R.id.swipe_refresh_layout_sidebar_fragment)
SwipeRefreshLayout swipeRefreshLayout;
@@ -84,6 +86,7 @@ public class SidebarFragment extends Fragment {
Executor mExecutor;
private ViewSubredditDetailActivity activity;
private String mAccessToken;
+ private String mAccountName;
private String subredditName;
private LinearLayoutManagerBugFixed linearLayoutManager;
private int markdownColor;
@@ -108,6 +111,7 @@ public class SidebarFragment extends Fragment {
EventBus.getDefault().register(this);
mAccessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
+ mAccountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
if (subredditName == null) {
Toast.makeText(activity, R.string.error_getting_subreddit_name, Toast.LENGTH_SHORT).show();
@@ -246,7 +250,7 @@ public class SidebarFragment extends Fragment {
public void fetchSubredditData() {
swipeRefreshLayout.setRefreshing(true);
- FetchSubredditData.fetchSubredditData(mOauthRetrofit, mRetrofit, subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
+ FetchSubredditData.fetchSubredditData(mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
swipeRefreshLayout.setRefreshing(false);
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 c7dff78d..548f7e2f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -1434,7 +1434,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
e.printStackTrace();
}
}
- FetchSubredditData.fetchSubredditData(mOauthRetrofit, mRetrofit, mPost.getSubredditName(), mAccessToken,
+ FetchSubredditData.fetchSubredditData(mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, mPost.getSubredditName(), mAccessToken,
new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
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 e19e5492..4d02a154 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java
@@ -1,7 +1,5 @@
package ml.docilealligator.infinityforreddit.subreddit;
-import android.text.TextUtils;
-
import androidx.annotation.NonNull;
import java.util.ArrayList;
@@ -20,7 +18,7 @@ public class FetchSubredditData {
RedditAPI api = retrofit.create(RedditAPI.class);
Call<String> subredditData;
- if (oauthRetrofit == null || TextUtils.isEmpty(accessToken)) {
+ if (oauthRetrofit == null) {
subredditData = api.getSubredditData(subredditName);
} else {
RedditAPI oauthApi = oauthRetrofit.create(RedditAPI.class);