aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-01-08 05:08:15 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-01-08 05:08:15 +0000
commite54776153a44285f143f931e605bc111b042ef8e (patch)
treeb834b6d2640175dc0ff3d5ffb6812587185d0674 /app/src/main/java
parentecf6a0b33869053e2da5af65eb82dce33d9fefef (diff)
downloadinfinity-for-reddit-e54776153a44285f143f931e605bc111b042ef8e.tar
infinity-for-reddit-e54776153a44285f143f931e605bc111b042ef8e.tar.gz
infinity-for-reddit-e54776153a44285f143f931e605bc111b042ef8e.tar.bz2
infinity-for-reddit-e54776153a44285f143f931e605bc111b042ef8e.tar.lz
infinity-for-reddit-e54776153a44285f143f931e605bc111b042ef8e.tar.xz
infinity-for-reddit-e54776153a44285f143f931e605bc111b042ef8e.tar.zst
infinity-for-reddit-e54776153a44285f143f931e605bc111b042ef8e.zip
Continue changing anonymous mode.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchPost.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSource.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSourceFactory.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java12
20 files changed, 40 insertions, 67 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java
index 050dc613..d6b7a74c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java
@@ -28,8 +28,8 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity {
@BindView(R.id.relative_layout_fetch_random_subreddit_or_post_activity)
RelativeLayout relativeLayout;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
+ @Named("application_only_oauth")
+ Retrofit mApplicationOnlyOauthRetrofit;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@@ -49,7 +49,8 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity {
int option = getIntent().getIntExtra(EXTRA_RANDOM_OPTION, RandomBottomSheetFragment.RANDOM_SUBREDDIT);
- FetchPost.fetchRandomPost(mExecutor, new Handler(), mRetrofit, option == RandomBottomSheetFragment.RANDOM_NSFW_SUBREDDIT
+ FetchPost.fetchRandomPost(mExecutor, new Handler(), mApplicationOnlyOauthRetrofit,
+ option == RandomBottomSheetFragment.RANDOM_NSFW_SUBREDDIT
|| option == RandomBottomSheetFragment.RANDOM_NSFW_POST, new FetchPost.FetchRandomPostListener() {
@Override
public void fetchRandomPostSuccess(String postId, String subredditName) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
index 5f474442..6f67febd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
@@ -363,7 +363,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
mRetrofit.newBuilder()
.baseUrl("http://localhost/")
.addConverterFactory(ScalarsConverterFactory.create())
- .build().create(TitleSuggestion.class).getHtml(url).enqueue(new Callback<String>() {
+ .build().create(TitleSuggestion.class).getHtml(url).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/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
index 28e4898d..79983a1d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
@@ -83,9 +83,6 @@ public class TrendingActivity extends BaseActivity {
@BindView(R.id.fetch_trending_search_text_view_trending_activity)
TextView errorTextView;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
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 ce78d3c9..b55da858 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
@@ -99,9 +99,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
@BindView(R.id.toolbar_view_multi_reddit_detail_activity)
Toolbar toolbar;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
index 6ba110d7..1d0919d4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
@@ -127,9 +127,6 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
@BindView(R.id.close_search_panel_image_view_view_post_detail_activity)
ImageView closeSearchPanelImageView;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
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 b9a77bc2..6633b7f0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -174,9 +174,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@BindView(R.id.description_text_view_view_subreddit_detail_activity)
TextView descriptionTextView;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index 578001b9..2f3f30c1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -168,9 +168,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@BindView(R.id.description_text_view_view_user_detail_activity)
TextView descriptionTextView;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
index 2b047074..69fd01e4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
@@ -199,8 +199,8 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
private boolean useBottomAppBar;
@Inject
- @Named("no_oauth")
- Retrofit retrofit;
+ @Named("application_only_oauth")
+ Retrofit applicationOnlyOauthRetrofit;
@Inject
@Named("gfycat")
@@ -782,7 +782,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
private void loadVReddItVideo(Bundle savedInstanceState) {
progressBar.setVisibility(View.VISIBLE);
- vReddItRetrofit.create(VReddIt.class).getRedirectUrl(getIntent().getStringExtra(EXTRA_V_REDD_IT_URL)).enqueue(new Callback<String>() {
+ vReddItRetrofit.create(VReddIt.class).getRedirectUrl(getIntent().getStringExtra(EXTRA_V_REDD_IT_URL)).enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
Uri redirectUri = Uri.parse(response.raw().request().url().toString());
@@ -791,7 +791,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
List<String> segments = redirectUri.getPathSegments();
int commentsIndex = segments.lastIndexOf("comments");
String postId = segments.get(commentsIndex + 1);
- FetchPost.fetchPost(mExecutor, new Handler(), retrofit, postId, null,
+ FetchPost.fetchPost(mExecutor, new Handler(), applicationOnlyOauthRetrofit, postId, null,
new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
index 6372191f..7507f21c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
@@ -92,8 +92,8 @@ public class WikiActivity extends BaseActivity {
TextView mFetchWikiInfoTextView;
@Inject
- @Named("no_oauth")
- Retrofit retrofit;
+ @Named("application_only_oauth")
+ Retrofit applicationOnlyOauthRetrofit;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@@ -256,7 +256,7 @@ public class WikiActivity extends BaseActivity {
Glide.with(this).clear(mFetchWikiInfoImageView);
mFetchWikiInfoLinearLayout.setVisibility(View.GONE);
- retrofit.create(RedditAPI.class).getWikiPage(mSubredditName, getIntent().getStringExtra(EXTRA_WIKI_PATH)).enqueue(new Callback<String>() {
+ applicationOnlyOauthRetrofit.create(RedditAPI.class).getWikiPage(mSubredditName, getIntent().getStringExtra(EXTRA_WIKI_PATH)).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/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
index f9c4eac2..44ba63b6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
@@ -206,10 +206,10 @@ public interface RedditAPI {
Call<String> awardThing(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@GET("/r/random/comments.json?limit=1&raw_json=1")
- Call<String> getRandomPost();
+ Call<String> getRandomPostOauth();
@GET("/r/randnsfw/new.json?sort=new&t=all&limit=1&raw_json=1")
- Call<String> getRandomNSFWPost();
+ Call<String> getRandomNSFWPostOauth();
@POST("/api/read_all_messages")
Call<String> readAllMessages(@HeaderMap Map<String, String> headers);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java
index 42eca51c..f3b5d1d1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java
@@ -55,9 +55,6 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
CustomThemeWrapper mCustomThemeWrapper;
private String mAccessToken;
private String mSubredditName;
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 b5632e1c..082733b6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -179,9 +179,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
TextView mFetchPostInfoTextView;
PostViewModel mPostViewModel;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
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 6c8ed4be..c56f7521 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
@@ -71,9 +71,6 @@ public class SidebarFragment extends Fragment {
@BindView(R.id.markdown_recycler_view_sidebar_fragment)
RecyclerView recyclerView;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
index 4ce99fe9..0d235589 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
@@ -77,9 +77,6 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
TextView mFetchUserListingInfoTextView;
UserListingViewModel mUserListingViewModel;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
@@ -182,7 +179,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
});
}
- UserListingViewModel.Factory factory = new UserListingViewModel.Factory(mRetrofit, mQuery,
+ UserListingViewModel.Factory factory = new UserListingViewModel.Factory(mApplicationOnlyOauth, mQuery,
sortType, nsfw);
mUserListingViewModel = new ViewModelProvider(this, factory).get(UserListingViewModel.class);
mUserListingViewModel.getUsers().observe(getViewLifecycleOwner(), UserData -> mAdapter.submitList(UserData));
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 d1fb5e8d..eb68bbc1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -148,9 +148,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@BindView(R.id.fetch_post_info_text_view_view_post_detail_fragment)
TextView mFetchPostInfoTextView;
@Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
@Named("pushshift")
Retrofit pushshiftRetrofit;
@Inject
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchPost.java
index d3032e6c..a1579d86 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchPost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchPost.java
@@ -5,6 +5,7 @@ import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import java.util.HashMap;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
@@ -15,10 +16,11 @@ import retrofit2.Response;
import retrofit2.Retrofit;
public class FetchPost {
- public static void fetchPost(Executor executor, Handler handler, Retrofit retrofit, String id,
+ public static void fetchPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String id,
@Nullable String accessToken,
FetchPostListener fetchPostListener) {
- Call<String> postCall = retrofit.create(RedditAPI.class).getPostOauth(id, APIUtils.getOAuthHeader(accessToken));
+ Call<String> postCall = oauthRetrofit.create(RedditAPI.class).getPostOauth(id,
+ accessToken == null ? new HashMap<>() : APIUtils.getOAuthHeader(accessToken));
postCall.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
@@ -46,13 +48,13 @@ public class FetchPost {
});
}
- public static void fetchRandomPost(Executor executor, Handler handler, Retrofit retrofit, boolean isNSFW,
- FetchRandomPostListener fetchRandomPostListener) {
+ public static void fetchRandomPost(Executor executor, Handler handler, Retrofit applicationOnlyOauthRetrofit,
+ boolean isNSFW, FetchRandomPostListener fetchRandomPostListener) {
Call<String> call;
if (isNSFW) {
- call = retrofit.create(RedditAPI.class).getRandomNSFWPost();
+ call = applicationOnlyOauthRetrofit.create(RedditAPI.class).getRandomNSFWPostOauth();
} else {
- call = retrofit.create(RedditAPI.class).getRandomPost();
+ call = applicationOnlyOauthRetrofit.create(RedditAPI.class).getRandomPostOauth();
}
call.enqueue(new Callback<>() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java
index 55c47c3d..1c1c8c3b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java
@@ -57,9 +57,9 @@ public class FetchUserData {
});
}
- public static void fetchUserListingData(Retrofit retrofit, String query, String after, SortType.Type sortType, boolean nsfw,
+ public static void fetchUserListingData(Retrofit applicationOnlyOauthRetrofit, String query, String after, SortType.Type sortType, boolean nsfw,
FetchUserListingDataListener fetchUserListingDataListener) {
- RedditAPI api = retrofit.create(RedditAPI.class);
+ RedditAPI api = applicationOnlyOauthRetrofit.create(RedditAPI.class);
Call<String> userInfo = api.searchUsers(query, after, sortType, nsfw ? 1 : 0);
userInfo.enqueue(new Callback<>() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSource.java
index c3d922a7..825cd0d4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSource.java
@@ -12,7 +12,7 @@ import retrofit2.Retrofit;
public class UserListingDataSource extends PageKeyedDataSource<String, UserData> {
- private final Retrofit retrofit;
+ private final Retrofit applicationOnlyOauthRetrofit;
private final String query;
private final SortType sortType;
private final boolean nsfw;
@@ -24,8 +24,8 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
private PageKeyedDataSource.LoadParams<String> params;
private PageKeyedDataSource.LoadCallback<String, UserData> callback;
- UserListingDataSource(Retrofit retrofit, String query, SortType sortType, boolean nsfw) {
- this.retrofit = retrofit;
+ UserListingDataSource(Retrofit applicationOnlyOauthRetrofit, String query, SortType sortType, boolean nsfw) {
+ this.applicationOnlyOauthRetrofit = applicationOnlyOauthRetrofit;
this.query = query;
this.sortType = sortType;
this.nsfw = nsfw;
@@ -50,7 +50,7 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
public void loadInitial(@NonNull PageKeyedDataSource.LoadInitialParams<String> params, @NonNull PageKeyedDataSource.LoadInitialCallback<String, UserData> callback) {
initialLoadStateLiveData.postValue(NetworkState.LOADING);
- FetchUserData.fetchUserListingData(retrofit, query, null, sortType.getType(), nsfw,
+ FetchUserData.fetchUserListingData(applicationOnlyOauthRetrofit, query, null, sortType.getType(), nsfw,
new FetchUserData.FetchUserListingDataListener() {
@Override
public void onFetchUserListingDataSuccess(ArrayList<UserData> UserData, String after) {
@@ -81,7 +81,7 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
return;
}
- FetchUserData.fetchUserListingData(retrofit, query, params.key, sortType.getType(), nsfw,
+ FetchUserData.fetchUserListingData(applicationOnlyOauthRetrofit, query, params.key, sortType.getType(), nsfw,
new FetchUserData.FetchUserListingDataListener() {
@Override
public void onFetchUserListingDataSuccess(ArrayList<UserData> UserData, String after) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSourceFactory.java
index 9d52d087..5bd3a51b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSourceFactory.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingDataSourceFactory.java
@@ -8,7 +8,7 @@ import ml.docilealligator.infinityforreddit.SortType;
import retrofit2.Retrofit;
public class UserListingDataSourceFactory extends DataSource.Factory {
- private final Retrofit retrofit;
+ private final Retrofit applicationOnlyOauthRetrofit;
private final String query;
private SortType sortType;
private final boolean nsfw;
@@ -16,8 +16,8 @@ public class UserListingDataSourceFactory extends DataSource.Factory {
private UserListingDataSource userListingDataSource;
private final MutableLiveData<UserListingDataSource> userListingDataSourceMutableLiveData;
- UserListingDataSourceFactory(Retrofit retrofit, String query, SortType sortType, boolean nsfw) {
- this.retrofit = retrofit;
+ UserListingDataSourceFactory(Retrofit applicationOnlyOauthRetrofit, String query, SortType sortType, boolean nsfw) {
+ this.applicationOnlyOauthRetrofit = applicationOnlyOauthRetrofit;
this.query = query;
this.sortType = sortType;
this.nsfw = nsfw;
@@ -27,7 +27,7 @@ public class UserListingDataSourceFactory extends DataSource.Factory {
@NonNull
@Override
public DataSource create() {
- userListingDataSource = new UserListingDataSource(retrofit, query, sortType, nsfw);
+ userListingDataSource = new UserListingDataSource(applicationOnlyOauthRetrofit, query, sortType, nsfw);
userListingDataSourceMutableLiveData.postValue(userListingDataSource);
return userListingDataSource;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java
index daffdf1e..29c3c0ff 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java
@@ -21,8 +21,8 @@ public class UserListingViewModel extends ViewModel {
private final LiveData<PagedList<UserData>> users;
private final MutableLiveData<SortType> sortTypeLiveData;
- public UserListingViewModel(Retrofit retrofit, String query, SortType sortType, boolean nsfw) {
- userListingDataSourceFactory = new UserListingDataSourceFactory(retrofit, query, sortType, nsfw);
+ public UserListingViewModel(Retrofit appliationOnlyOauthRetrofit, String query, SortType sortType, boolean nsfw) {
+ userListingDataSourceFactory = new UserListingDataSourceFactory(appliationOnlyOauthRetrofit, query, sortType, nsfw);
initialLoadingState = Transformations.switchMap(userListingDataSourceFactory.getUserListingDataSourceMutableLiveData(),
UserListingDataSource::getInitialLoadStateLiveData);
@@ -74,13 +74,13 @@ public class UserListingViewModel extends ViewModel {
}
public static class Factory extends ViewModelProvider.NewInstanceFactory {
- private final Retrofit retrofit;
+ private final Retrofit applicationOnlyOauthRetrofit;
private final String query;
private final SortType sortType;
private final boolean nsfw;
- public Factory(Retrofit retrofit, String query, SortType sortType, boolean nsfw) {
- this.retrofit = retrofit;
+ public Factory(Retrofit applicationOnlyOauthRetrofit, String query, SortType sortType, boolean nsfw) {
+ this.applicationOnlyOauthRetrofit = applicationOnlyOauthRetrofit;
this.query = query;
this.sortType = sortType;
this.nsfw = nsfw;
@@ -89,7 +89,7 @@ public class UserListingViewModel extends ViewModel {
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
- return (T) new UserListingViewModel(retrofit, query, sortType, nsfw);
+ return (T) new UserListingViewModel(applicationOnlyOauthRetrofit, query, sortType, nsfw);
}
}
}