diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-01-08 01:21:33 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-01-08 01:21:33 +0000 |
commit | 780a719227339c5af28473a87ac2e4641091e33d (patch) | |
tree | aaa885c2edadfaeb49f601d58b2e2062a7573792 /app/src/main | |
parent | b2ae0388bb0391d20c3956a8f62be21c2851873a (diff) | |
download | infinity-for-reddit-780a719227339c5af28473a87ac2e4641091e33d.tar infinity-for-reddit-780a719227339c5af28473a87ac2e4641091e33d.tar.gz infinity-for-reddit-780a719227339c5af28473a87ac2e4641091e33d.tar.bz2 infinity-for-reddit-780a719227339c5af28473a87ac2e4641091e33d.tar.lz infinity-for-reddit-780a719227339c5af28473a87ac2e4641091e33d.tar.xz infinity-for-reddit-780a719227339c5af28473a87ac2e4641091e33d.tar.zst infinity-for-reddit-780a719227339c5af28473a87ac2e4641091e33d.zip |
Continue changing anonymous mode.
Diffstat (limited to '')
5 files changed, 24 insertions, 18 deletions
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 2cb49550..b9a77bc2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -180,6 +180,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Named("oauth") Retrofit mOauthRetrofit; @Inject + @Named("application_only_oauth") + Retrofit mApplicationOnlyOauthRetrofit; + @Inject RedditDataRoomDatabase mRedditDataRoomDatabase; @Inject @Named("default") @@ -959,7 +962,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp subscriptionReady = false; if (getResources().getString(R.string.subscribe).contentEquals(subscribeSubredditChip.getText())) { SubredditSubscription.anonymousSubscribeToSubreddit(mExecutor, new Handler(), - mRetrofit, mRedditDataRoomDatabase, subredditName, + mApplicationOnlyOauthRetrofit, mRedditDataRoomDatabase, subredditName, new SubredditSubscription.SubredditSubscriptionListener() { @Override public void onSubredditSubscriptionSuccess() { @@ -1000,7 +1003,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp subscriptionReady = false; if (getResources().getString(R.string.subscribe).contentEquals(subscribeSubredditChip.getText())) { SubredditSubscription.subscribeToSubreddit(mExecutor, new Handler(), mOauthRetrofit, - mRetrofit, mAccessToken, subredditName, mAccountName, mRedditDataRoomDatabase, + mAccessToken, subredditName, mAccountName, mRedditDataRoomDatabase, new SubredditSubscription.SubredditSubscriptionListener() { @Override public void onSubredditSubscriptionSuccess() { 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 c1d60585..39cafb9d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditListingRecyclerViewAdapter.java @@ -60,7 +60,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred private final BaseActivity activity; private final Executor executor; private final Retrofit oauthRetrofit; - private final Retrofit retrofit; + private final Retrofit applicationOnlyOauthRetrofit; private final String accessToken; private final String accountName; private final RedditDataRoomDatabase redditDataRoomDatabase; @@ -75,7 +75,8 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred private NetworkState networkState; private final Callback callback; - public SubredditListingRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit, Retrofit retrofit, + public SubredditListingRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit, + Retrofit applicationOnlyOauthRetrofit, CustomThemeWrapper customThemeWrapper, @Nullable String accessToken, @NonNull String accountName, RedditDataRoomDatabase redditDataRoomDatabase, @@ -84,7 +85,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred this.activity = activity; this.executor = executor; this.oauthRetrofit = oauthRetrofit; - this.retrofit = retrofit; + this.applicationOnlyOauthRetrofit = applicationOnlyOauthRetrofit; this.accessToken = accessToken; this.accountName = accountName; this.redditDataRoomDatabase = redditDataRoomDatabase; @@ -160,7 +161,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred ((DataViewHolder) holder).subscribeButton.setOnClickListener(view -> { if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) { SubredditSubscription.subscribeToSubreddit(executor, new Handler(), - oauthRetrofit, retrofit, accessToken, subredditData.getName(), + oauthRetrofit, accessToken, subredditData.getName(), accountName, redditDataRoomDatabase, new SubredditSubscription.SubredditSubscriptionListener() { @Override @@ -176,7 +177,8 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred }); } else { SubredditSubscription.anonymousSubscribeToSubreddit(executor, new Handler(), - retrofit, redditDataRoomDatabase, subredditData.getName(), + applicationOnlyOauthRetrofit, redditDataRoomDatabase, + subredditData.getName(), new SubredditSubscription.SubredditSubscriptionListener() { @Override public void onSubredditSubscriptionSuccess() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java index 0cf8b4cb..dad3a4b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java @@ -77,12 +77,12 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun TextView mFetchSubredditListingInfoTextView; SubredditListingViewModel mSubredditListingViewModel; @Inject - @Named("no_oauth") - Retrofit mRetrofit; - @Inject @Named("oauth") Retrofit mOauthRetrofit; @Inject + @Named("application_only_oauth") + Retrofit mApplicationOnlyOauthRetrofit; + @Inject RedditDataRoomDatabase mRedditDataRoomDatabase; @Inject @Named("default") @@ -143,7 +143,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase())); boolean nsfw = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false); - mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRetrofit, + mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mApplicationOnlyOauthRetrofit, mCustomThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase, getArguments().getBoolean(EXTRA_IS_MULTI_SELECTION, false), new SubredditListingRecyclerViewAdapter.Callback() { 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 b4ca4f0f..a6480ead 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java @@ -15,7 +15,8 @@ import retrofit2.Response; import retrofit2.Retrofit; public class FetchSubredditData { - public static void fetchSubredditData(Retrofit oauthRetrofit, String subredditName, String accessToken, final FetchSubredditDataListener fetchSubredditDataListener) { + public static void fetchSubredditData(Retrofit oauthRetrofit, String subredditName, String accessToken, + final FetchSubredditDataListener fetchSubredditDataListener) { RedditAPI oauthApi = oauthRetrofit.create(RedditAPI.class); Call<String> subredditData = oauthApi.getSubredditDataOauth(subredditName, APIUtils.getOAuthHeader(accessToken)); subredditData.enqueue(new Callback<>() { @@ -47,8 +48,8 @@ public class FetchSubredditData { public static void fetchSubredditData(Retrofit applicationOnlyOauthRetrofit, String subredditName, final FetchSubredditDataListener fetchSubredditDataListener) { - RedditAPI oauthApi = applicationOnlyOauthRetrofit.create(RedditAPI.class); - Call<String> subredditData = oauthApi.getSubredditDataOauth(subredditName, new HashMap<>()); + Call<String> subredditData = applicationOnlyOauthRetrofit.create(RedditAPI.class) + .getSubredditDataOauth(subredditName, new HashMap<>()); subredditData.enqueue(new Callback<>() { @Override public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java index 71372ade..969f9ea4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java @@ -20,18 +20,18 @@ import retrofit2.Retrofit; public class SubredditSubscription { public static void subscribeToSubreddit(Executor executor, Handler handler, Retrofit oauthRetrofit, - Retrofit retrofit, @Nullable String accessToken, String subredditName, + @Nullable String accessToken, String subredditName, @NonNull String accountName, RedditDataRoomDatabase redditDataRoomDatabase, SubredditSubscriptionListener subredditSubscriptionListener) { subredditSubscription(executor, handler, oauthRetrofit, accessToken, subredditName, accountName, "sub", redditDataRoomDatabase, subredditSubscriptionListener); } - public static void anonymousSubscribeToSubreddit(Executor executor, Handler handler, Retrofit retrofit, + public static void anonymousSubscribeToSubreddit(Executor executor, Handler handler, Retrofit applicationOnlyOauth, RedditDataRoomDatabase redditDataRoomDatabase, String subredditName, SubredditSubscriptionListener subredditSubscriptionListener) { - FetchSubredditData.fetchSubredditData(null, subredditName, "", new FetchSubredditData.FetchSubredditDataListener() { + FetchSubredditData.fetchSubredditData(applicationOnlyOauth, subredditName, new FetchSubredditData.FetchSubredditDataListener() { @Override public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) { insertSubscription(executor, handler, redditDataRoomDatabase, @@ -72,7 +72,7 @@ public class SubredditSubscription { params.put(APIUtils.SR_NAME_KEY, subredditName); Call<String> subredditSubscriptionCall = api.subredditSubscription(APIUtils.getOAuthHeader(accessToken), params); - subredditSubscriptionCall.enqueue(new Callback<String>() { + subredditSubscriptionCall.enqueue(new Callback<>() { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { |