diff options
Diffstat (limited to 'app')
18 files changed, 43 insertions, 40 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java index 56a19b37..50f67c67 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java @@ -530,7 +530,8 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee } private void loadSubredditIcon() { - LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> { + LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, + mAccessToken, mAccountName, mOauthRetrofit, iconImageUrl -> { iconUrl = iconImageUrl; displaySubredditIcon(); loadSubredditIconSuccessful = true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java index e0fd0411..2b5799ef 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java @@ -492,7 +492,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF } private void loadSubredditIcon() { - LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> { + LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, + mAccessToken, mAccountName, mOauthRetrofit, iconImageUrl -> { iconUrl = iconImageUrl; displaySubredditIcon(); loadSubredditIconSuccessful = true; 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 34dff394..1f197874 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java @@ -144,6 +144,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr Executor mExecutor; private Account selectedAccount; private String mAccessToken; + private String mAccountName; private String iconUrl; private String subredditName; private boolean subredditSelected = false; @@ -196,6 +197,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr resources = getResources(); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); + mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT); if (savedInstanceState != null) { selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE); @@ -477,7 +479,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr private void loadSubredditIcon() { LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, - mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> { + mAccessToken, mAccountName, mOauthRetrofit, iconImageUrl -> { iconUrl = iconImageUrl; displaySubredditIcon(); loadSubredditIconSuccessful = true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java index 57edeb79..b8ff179a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java @@ -528,7 +528,8 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr } private void loadSubredditIcon() { - LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> { + LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, + mAccessToken, mAccountName, mOauthRetrofit, iconImageUrl -> { iconUrl = iconImageUrl; displaySubredditIcon(); loadSubredditIconSuccessful = true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java index 6205d54a..873d9ef5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java @@ -161,6 +161,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr Executor mExecutor; private Account selectedAccount; private String mAccessToken; + private String mAccountName; private String iconUrl; private String subredditName; private boolean subredditSelected = false; @@ -215,6 +216,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr resources = getResources(); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); + mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT); if (savedInstanceState != null) { selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE); @@ -484,7 +486,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr private void loadSubredditIcon() { LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, - mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> { + mAccessToken, mAccountName, mOauthRetrofit, iconImageUrl -> { iconUrl = iconImageUrl; displaySubredditIcon(); loadSubredditIconSuccessful = true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java index 716c108d..0ffbe321 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java @@ -512,7 +512,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF private void loadSubredditIcon() { LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, - mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> { + mAccessToken, mAccountName, mOauthRetrofit, iconImageUrl -> { iconUrl = iconImageUrl; displaySubredditIcon(); loadSubredditIconSuccessful = true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java index c72ad868..b3005638 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java @@ -155,6 +155,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom Executor mExecutor; private Account selectedAccount; private String mAccessToken; + private String mAccountName; private Post post; private String iconUrl; private String subredditName; @@ -209,6 +210,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom post = getIntent().getParcelableExtra(EXTRA_POST); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); + mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT); if (savedInstanceState != null) { selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE); @@ -499,7 +501,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom private void loadSubredditIcon() { LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, - mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> { + mAccessToken, mAccountName, mOauthRetrofit, iconImageUrl -> { iconUrl = iconImageUrl; displaySubredditIcon(); loadSubredditIconSuccessful = true; 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..2cb49550 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(mOauthRetrofit, subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() { @Override public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) { mNCurrentOnlineSubscribers = nCurrentOnlineSubscribers; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 311082b7..108d8c68 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -561,7 +561,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler if (mPost.getSubredditIconUrl() == null) { LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, mPost.getSubredditNamePrefixed().substring(2), - mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> { + mAccessToken, mAccountName, mOauthRetrofit, iconImageUrl -> { if (iconImageUrl == null || iconImageUrl.equals("")) { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java index 7959cc68..6a2a9286 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java @@ -2,7 +2,7 @@ package ml.docilealligator.infinityforreddit.asynctasks; import android.os.Handler; -import androidx.annotation.Nullable; +import androidx.annotation.NonNull; import java.util.ArrayList; import java.util.Collections; @@ -21,7 +21,7 @@ import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData; public class InsertSubscribedThings { public static void insertSubscribedThings(Executor executor, Handler handler, - RedditDataRoomDatabase redditDataRoomDatabase, @Nullable String accountName, + RedditDataRoomDatabase redditDataRoomDatabase, @NonNull String accountName, List<SubscribedSubredditData> subscribedSubredditDataList, List<SubscribedUserData> subscribedUserDataList, List<SubredditData> subredditDataList, 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 a6d23af4..0d82746d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIcon.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIcon.java @@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit.asynctasks; import android.os.Handler; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.concurrent.Executor; @@ -14,7 +16,8 @@ import retrofit2.Retrofit; public class LoadSubredditIcon { public static void loadSubredditIcon(Executor executor, Handler handler, RedditDataRoomDatabase redditDataRoomDatabase, - String subredditName, String accessToken, Retrofit oauthRetrofit, Retrofit retrofit, + String subredditName, String accessToken, @NonNull String accountName, + Retrofit oauthRetrofit, LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener) { executor.execute(() -> { SubredditDao subredditDao = redditDataRoomDatabase.subredditDao(); @@ -23,12 +26,12 @@ 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(oauthRetrofit, subredditName, accessToken, new FetchSubredditData.FetchSubredditDataListener() { @Override public void onFetchSubredditDataSuccess(SubredditData subredditData1, int nCurrentOnlineSubscribers) { ArrayList<SubredditData> singleSubredditDataList = new ArrayList<>(); singleSubredditDataList.add(subredditData1); - InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase, null, + InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase, accountName, null, null, singleSubredditDataList, () -> loadSubredditIconAsyncTaskListener.loadIconSuccess(subredditData1.getIconUrl())); } 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 bced3f57..492e2efa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java @@ -73,7 +73,6 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.adapters.HistoryPostRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.adapters.Paging3LoadingStateAdapter; -import ml.docilealligator.infinityforreddit.adapters.PostRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.apis.StreamableAPI; import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIcon; import ml.docilealligator.infinityforreddit.asynctasks.LoadUserData; @@ -932,7 +931,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato } else { if (isSubreddit) { LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, - subredditOrUserName, accessToken, mOauthRetrofit, mRetrofit, + subredditOrUserName, accessToken, accountName, mOauthRetrofit, iconImageUrl -> { subredditOrUserIcons.put(subredditOrUserName, iconImageUrl); loadIconListener.loadIconSuccess(subredditOrUserName, iconImageUrl); 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 624c4848..78edbbe1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -1239,28 +1239,28 @@ public class PostFragment extends Fragment implements FragmentCommunicator { //For anonymous user if (postType == PostPagingSource.TYPE_SEARCH) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor, - mRetrofit, null, accountName, mSharedPreferences, + mOauthRetrofit, accessToken, accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences, null, subredditName, query, trendingSource, postType, sortType, postFilter, readPosts)).get(PostViewModel.class); } else if (postType == PostPagingSource.TYPE_SUBREDDIT) { mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mExecutor, - mRetrofit, null, accountName, mSharedPreferences, + mOauthRetrofit, accessToken, accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences, null, subredditName, postType, sortType, postFilter, readPosts)).get(PostViewModel.class); } else if (postType == PostPagingSource.TYPE_MULTI_REDDIT) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor, - mRetrofit, null, accountName, mSharedPreferences, + mOauthRetrofit, accessToken, accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences, null, multiRedditPath, postType, sortType, postFilter, readPosts)).get(PostViewModel.class); } else if (postType == PostPagingSource.TYPE_USER) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor, - mRetrofit, null, accountName, mSharedPreferences, + mOauthRetrofit, accessToken, accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences, null, username, postType, sortType, postFilter, where, readPosts)).get(PostViewModel.class); } else { //Anonymous Front Page mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor, - mRetrofit, mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter)) + mOauthRetrofit, accessToken, mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter)) .get(PostViewModel.class); } @@ -1743,7 +1743,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } else { if (isSubreddit) { LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, - subredditOrUserName, accessToken, mOauthRetrofit, mRetrofit, + subredditOrUserName, accessToken, accountName, mOauthRetrofit, iconImageUrl -> { subredditOrUserIcons.put(subredditOrUserName, iconImageUrl); loadIconListener.loadIconSuccess(subredditOrUserName, iconImageUrl); 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..6c8ed4be 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java @@ -246,7 +246,7 @@ public class SidebarFragment extends Fragment { public void fetchSubredditData() { swipeRefreshLayout.setRefreshing(true); - FetchSubredditData.fetchSubredditData(mOauthRetrofit, mRetrofit, subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() { + FetchSubredditData.fetchSubredditData(mOauthRetrofit, 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 1ee0d0d0..8093fb1f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -1443,7 +1443,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic e.printStackTrace(); } } - FetchSubredditData.fetchSubredditData(mOauthRetrofit, mRetrofit, mPost.getSubredditName(), mAccessToken, + FetchSubredditData.fetchSubredditData(mOauthRetrofit, mPost.getSubredditName(), mAccessToken, new FetchSubredditData.FetchSubredditDataListener() { @Override public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java index 8cf513e9..7822a8a7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java @@ -360,10 +360,11 @@ public class PostViewModel extends ViewModel { } //Anonymous Front Page - public Factory(Executor executor, Retrofit retrofit, SharedPreferences sharedPreferences, + public Factory(Executor executor, Retrofit retrofit, String accessToken, SharedPreferences sharedPreferences, String concatenatedSubredditNames, int postType, SortType sortType, PostFilter postFilter) { this.executor = executor; this.retrofit = retrofit; + this.accessToken = accessToken; this.sharedPreferences = sharedPreferences; this.name = concatenatedSubredditNames; this.postType = postType; @@ -387,7 +388,7 @@ public class PostViewModel extends ViewModel { postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, name, postType, sortType, postFilter, readPostList); } else if (postType == PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE) { - return (T) new PostViewModel(executor, retrofit, null, null, sharedPreferences, + return (T) new PostViewModel(executor, retrofit, accessToken, null, sharedPreferences, null, null, name, postType, sortType, postFilter, null); } else { 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..c4c774f1 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; @@ -16,16 +14,9 @@ import retrofit2.Response; import retrofit2.Retrofit; public class FetchSubredditData { - public static void fetchSubredditData(Retrofit oauthRetrofit, Retrofit retrofit, String subredditName, String accessToken, final FetchSubredditDataListener fetchSubredditDataListener) { - RedditAPI api = retrofit.create(RedditAPI.class); - - Call<String> subredditData; - if (oauthRetrofit == null || TextUtils.isEmpty(accessToken)) { - subredditData = api.getSubredditData(subredditName); - } else { - RedditAPI oauthApi = oauthRetrofit.create(RedditAPI.class); - subredditData = oauthApi.getSubredditDataOauth(subredditName, APIUtils.getOAuthHeader(accessToken)); - } + 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<>() { @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 e8073caf..b6d9ccf1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java @@ -30,7 +30,7 @@ public class SubredditSubscription { RedditDataRoomDatabase redditDataRoomDatabase, String subredditName, SubredditSubscriptionListener subredditSubscriptionListener) { - FetchSubredditData.fetchSubredditData(null, retrofit, subredditName, "", new FetchSubredditData.FetchSubredditDataListener() { + FetchSubredditData.fetchSubredditData(null, subredditName, "", new FetchSubredditData.FetchSubredditDataListener() { @Override public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) { insertSubscription(executor, handler, redditDataRoomDatabase, @@ -76,7 +76,7 @@ public class SubredditSubscription { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { if (action.equals("sub")) { - FetchSubredditData.fetchSubredditData(oauthRetrofit, retrofit, subredditName, accessToken, new FetchSubredditData.FetchSubredditDataListener() { + FetchSubredditData.fetchSubredditData(oauthRetrofit, subredditName, accessToken, new FetchSubredditData.FetchSubredditDataListener() { @Override public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) { insertSubscription(executor, handler, redditDataRoomDatabase, |