aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorSergei Kozelko <KozelkoS@yandex.ru>2022-12-23 22:17:24 +0000
committerGitHub <noreply@github.com>2022-12-23 22:17:24 +0000
commita21eccca0d788958824c747f102ad8508aa089f8 (patch)
tree6dff3b8fe254be9bb5d81220efd01bd171b08ad3 /app/src
parent483cb7023c9cbb536978d487e4d9a4efb27a32d7 (diff)
downloadinfinity-for-reddit-a21eccca0d788958824c747f102ad8508aa089f8.tar
infinity-for-reddit-a21eccca0d788958824c747f102ad8508aa089f8.tar.gz
infinity-for-reddit-a21eccca0d788958824c747f102ad8508aa089f8.tar.bz2
infinity-for-reddit-a21eccca0d788958824c747f102ad8508aa089f8.tar.lz
infinity-for-reddit-a21eccca0d788958824c747f102ad8508aa089f8.tar.xz
infinity-for-reddit-a21eccca0d788958824c747f102ad8508aa089f8.tar.zst
infinity-for-reddit-a21eccca0d788958824c747f102ad8508aa089f8.zip
Inject Streamable api provider instead of Retrofit instance (#1217)
Low effort/high impact case. Simple change that removes Retrofit instance creation from startup path because it is used only after receiving response from Reddit. Eliminates Retrofit instance creation completely if it is not used. Also improves type safety by replacing common Retrofit type with specific api type.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java9
9 files changed, 54 insertions, 35 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java
index 91fc164c..ef5629d4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java
@@ -10,6 +10,8 @@ import org.json.JSONObject;
import java.io.IOException;
import java.util.concurrent.Executor;
+import javax.inject.Provider;
+
import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
import retrofit2.Call;
@@ -22,11 +24,11 @@ public class FetchStreamableVideo {
void failed();
}
- public static void fetchStreamableVideo(Executor executor, Handler handler, Retrofit streamableRetrofit,
+ public static void fetchStreamableVideo(Executor executor, Handler handler, Provider<StreamableAPI> streamableApiProvider,
String videoUrl, FetchStreamableVideoListener fetchStreamableVideoListener) {
executor.execute(() -> {
try {
- Response<String> response = streamableRetrofit.create(StreamableAPI.class).getStreamableData(videoUrl).execute();
+ Response<String> response = streamableApiProvider.get().getStreamableData(videoUrl).execute();
if (response.isSuccessful()) {
JSONObject jsonObject = new JSONObject(response.body());
String title = jsonObject.getString(JSONUtils.TITLE_KEY);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java
index 8638ea8b..647d87c8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java
@@ -9,6 +9,7 @@ import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
+import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
import ml.docilealligator.infinityforreddit.network.SortTypeConverterFactory;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
import okhttp3.ConnectionPool;
@@ -198,4 +199,10 @@ abstract class NetworkModule {
.baseUrl(APIUtils.STREAMABLE_API_BASE_URI)
.build();
}
+
+ @Provides
+ @Singleton
+ static StreamableAPI provideStreamableApi(@Named("streamable") Retrofit streamableRetrofit) {
+ return streamableRetrofit.create(StreamableAPI.class);
+ }
}
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 b9fa2655..ae8de478 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
@@ -76,6 +76,7 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
+import javax.inject.Provider;
import app.futured.hauler.DragDirection;
import app.futured.hauler.HaulerView;
@@ -88,6 +89,7 @@ import ml.docilealligator.infinityforreddit.FetchStreamableVideo;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.StreamableVideo;
+import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
import ml.docilealligator.infinityforreddit.apis.VReddIt;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PlaybackSpeedBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@@ -211,8 +213,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
Retrofit vReddItRetrofit;
@Inject
- @Named("streamable")
- Retrofit streamableRetrofit;
+ Provider<StreamableAPI> streamableApiProvider;
@Inject
@Named("default")
@@ -835,7 +836,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
private void loadStreamableVideo(String shortCode, Bundle savedInstanceState) {
progressBar.setVisibility(View.VISIBLE);
- FetchStreamableVideo.fetchStreamableVideo(mExecutor, new Handler(), streamableRetrofit, shortCode,
+ FetchStreamableVideo.fetchStreamableVideo(mExecutor, new Handler(), streamableApiProvider, shortCode,
new FetchStreamableVideo.FetchStreamableVideoListener() {
@Override
public void success(StreamableVideo streamableVideo) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
index 39639da2..db7abf03 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
@@ -57,6 +57,8 @@ import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.Executor;
+import javax.inject.Provider;
+
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.BlurTransformation;
@@ -141,7 +143,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
private Retrofit mOauthRetrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
- private Retrofit mStreamableRetrofit;
+ private Provider<StreamableAPI> mStreamableApiProvider;
private String mAccessToken;
private RequestManager mGlide;
private int mMaxResolution;
@@ -220,7 +222,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
private RecyclerView.RecycledViewPool mGalleryRecycledViewPool;
public HistoryPostRecyclerViewAdapter(BaseActivity activity, HistoryPostFragment fragment, Executor executor, Retrofit oauthRetrofit,
- Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Retrofit streambleRetrofit,
+ Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streambleApiProvider,
CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
SharedPreferences sharedPreferences, SharedPreferences currentAccountSharedPreferences,
@@ -236,7 +238,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
mOauthRetrofit = oauthRetrofit;
mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit;
- mStreamableRetrofit = streambleRetrofit;
+ mStreamableApiProvider = streambleApiProvider;
mAccessToken = accessToken;
mPostType = postType;
mDisplaySubredditName = displaySubredditName;
@@ -734,7 +736,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
});
} else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
- mStreamableRetrofit.create(StreamableAPI.class).getStreamableData(post.getStreamableShortCode());
+ mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
@@ -909,7 +911,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
});
} else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
- mStreamableRetrofit.create(StreamableAPI.class).getStreamableData(post.getStreamableShortCode());
+ mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
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 db468d42..cc888d26 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -53,6 +53,8 @@ import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.Executor;
+import javax.inject.Provider;
+
import butterknife.BindView;
import butterknife.ButterKnife;
import io.noties.markwon.AbstractMarkwonPlugin;
@@ -129,7 +131,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private Retrofit mOauthRetrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
- private Retrofit mStreamableRetrofit;
+ private final Provider<StreamableAPI> mStreamableApiProvider;
private RedditDataRoomDatabase mRedditDataRoomDatabase;
private SharedPreferences mCurrentAccountSharedPreferences;
private RequestManager mGlide;
@@ -208,7 +210,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
Executor executor, CustomThemeWrapper customThemeWrapper,
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
- Retrofit redgifsRetrofit, Retrofit streamableRetrofit,
+ Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
boolean separatePostAndComments, String accessToken,
String accountName, Post post, Locale locale,
@@ -225,7 +227,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mOauthRetrofit = oauthRetrofit;
mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit;
- mStreamableRetrofit = streamableRetrofit;
+ mStreamableApiProvider = streamableApiProvider;
mRedditDataRoomDatabase = redditDataRoomDatabase;
mGlide = glide;
mSaveMemoryCenterInsideDownsampleStrategy = new SaveMemoryCenterInisdeDownsampleStrategy(Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.POST_FEED_MAX_RESOLUTION, "5000000")));
@@ -669,7 +671,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
});
} else if(mPost.isStreamable() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
- mStreamableRetrofit.create(StreamableAPI.class).getStreamableData(mPost.getStreamableShortCode());
+ mStreamableApiProvider.get().getStreamableData(mPost.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
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 1f9f9af8..ac2df45d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -57,6 +57,8 @@ import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.Executor;
+import javax.inject.Provider;
+
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.BlurTransformation;
@@ -145,7 +147,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private Retrofit mOauthRetrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
- private Retrofit mStreamableRetrofit;
+ private Provider<StreamableAPI> mStreamableApiProvider;
private String mAccessToken;
private RequestManager mGlide;
private int mMaxResolution;
@@ -231,7 +233,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private RecyclerView.RecycledViewPool mGalleryRecycledViewPool;
public PostRecyclerViewAdapter(BaseActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
- Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Retrofit streambleRetrofit,
+ Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
SharedPreferences sharedPreferences, SharedPreferences currentAccountSharedPreferences,
@@ -248,7 +250,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mOauthRetrofit = oauthRetrofit;
mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit;
- mStreamableRetrofit = streambleRetrofit;
+ mStreamableApiProvider = streamableApiProvider;
mAccessToken = accessToken;
mPostType = postType;
mDisplaySubredditName = displaySubredditName;
@@ -765,7 +767,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
});
} else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
- mStreamableRetrofit.create(StreamableAPI.class).getStreamableData(post.getStreamableShortCode());
+ mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
@@ -946,7 +948,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
});
} else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
- mStreamableRetrofit.create(StreamableAPI.class).getStreamableData(post.getStreamableShortCode());
+ mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
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 27608f1f..dcdda517 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
@@ -59,6 +59,7 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
+import javax.inject.Provider;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -73,6 +74,7 @@ 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;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@@ -169,8 +171,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
@Named("redgifs")
Retrofit mRedgifsRetrofit;
@Inject
- @Named("streamable")
- Retrofit mStreamableRetrofit;
+ Provider<StreamableAPI> mStreamableApiProvider;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@@ -379,7 +380,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, defaultPostLayout);
mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
+ mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
mExoCreator, new HistoryPostRecyclerViewAdapter.Callback() {
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 35b470b8..af2d68e0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -63,6 +63,7 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
+import javax.inject.Provider;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -82,6 +83,7 @@ import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
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;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
@@ -190,8 +192,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Named("redgifs")
Retrofit mRedgifsRetrofit;
@Inject
- @Named("streamable")
- Retrofit mStreamableRetrofit;
+ Provider<StreamableAPI> mStreamableApiProvider;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@@ -462,7 +463,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
+ mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@@ -539,7 +540,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
+ mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, displaySubredditName,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@@ -610,7 +611,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
+ mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@@ -675,7 +676,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
+ mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@@ -736,7 +737,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
+ mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@@ -796,7 +797,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
+ mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@@ -853,7 +854,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
+ mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
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 40121261..c72aacf3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -62,6 +62,7 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
+import javax.inject.Provider;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -83,6 +84,7 @@ import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.adapters.CommentsRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.adapters.PostDetailRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
+import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
import ml.docilealligator.infinityforreddit.asynctasks.LoadUserData;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostCommentSortTypeBottomSheetFragment;
@@ -161,8 +163,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Named("redgifs")
Retrofit mRedgifsRetrofit;
@Inject
- @Named("streamable")
- Retrofit mStreamableRetrofit;
+ Provider<StreamableAPI> mStreamableApiProvider;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@@ -597,7 +598,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
this, mExecutor, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit,
- mRedgifsRetrofit, mStreamableRetrofit, mRedditDataRoomDatabase, mGlide,
+ mRedgifsRetrofit, mStreamableApiProvider, mRedditDataRoomDatabase, mGlide,
mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
@@ -1305,7 +1306,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
mRetrofit, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
- mStreamableRetrofit, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
+ mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
mPostDetailsSharedPreferences, mExoCreator,