mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-10-05 21:39:50 +02:00
Streamable videos autoplay.
This commit is contained in:
@@ -15,18 +15,12 @@ import retrofit2.Response;
|
|||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class FetchGfycatOrRedgifsVideoLinks {
|
public class FetchGfycatOrRedgifsVideoLinks {
|
||||||
private FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener;
|
|
||||||
Call<String> gfycatCall;
|
|
||||||
|
|
||||||
public interface FetchGfycatOrRedgifsVideoLinksListener {
|
public interface FetchGfycatOrRedgifsVideoLinksListener {
|
||||||
void success(String webm, String mp4);
|
void success(String webm, String mp4);
|
||||||
void failed(int errorCode);
|
void failed(int errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FetchGfycatOrRedgifsVideoLinks(FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
|
|
||||||
this.fetchGfycatOrRedgifsVideoLinksListener = fetchGfycatOrRedgifsVideoLinksListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fetchGfycatOrRedgifsVideoLinks(Executor executor, Handler handler, Retrofit gfycatRetrofit,
|
public static void fetchGfycatOrRedgifsVideoLinks(Executor executor, Handler handler, Retrofit gfycatRetrofit,
|
||||||
String gfycatId,
|
String gfycatId,
|
||||||
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
|
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
|
||||||
@@ -46,20 +40,20 @@ public class FetchGfycatOrRedgifsVideoLinks {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(Executor executor, Handler handler,
|
public static void fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(Executor executor, Handler handler,
|
||||||
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit,
|
Call<String> gfycatCall,
|
||||||
String gfycatId, boolean isGfycatVideo,
|
String gfycatId, boolean isGfycatVideo,
|
||||||
boolean automaticallyTryRedgifs) {
|
boolean automaticallyTryRedgifs,
|
||||||
|
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
gfycatCall = (isGfycatVideo ? gfycatRetrofit : redgifsRetrofit).create(GfycatAPI.class).getGfycatData(gfycatId);
|
|
||||||
try {
|
try {
|
||||||
Response<String> response = gfycatCall.execute();
|
Response<String> response = gfycatCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
parseGfycatVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
|
parseGfycatVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
|
||||||
} else {
|
} else {
|
||||||
if (response.code() == 404 && isGfycatVideo && automaticallyTryRedgifs) {
|
if (response.code() == 404 && isGfycatVideo && automaticallyTryRedgifs) {
|
||||||
fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(executor, handler, gfycatRetrofit,
|
fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(executor, handler, gfycatCall.clone(),
|
||||||
redgifsRetrofit, gfycatId, false, false);
|
gfycatId, false, false, fetchGfycatOrRedgifsVideoLinksListener);
|
||||||
} else {
|
} else {
|
||||||
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(response.code()));
|
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(response.code()));
|
||||||
}
|
}
|
||||||
@@ -71,12 +65,6 @@ public class FetchGfycatOrRedgifsVideoLinks {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
|
||||||
if (gfycatCall != null && !gfycatCall.isCanceled()) {
|
|
||||||
gfycatCall.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void parseGfycatVideoLinks(Handler handler, String response,
|
private static void parseGfycatVideoLinks(Handler handler, String response,
|
||||||
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
|
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
|
||||||
try {
|
try {
|
||||||
|
@@ -12,6 +12,7 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
|
import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
|
||||||
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
||||||
|
import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@@ -42,6 +43,31 @@ public class FetchStreamableVideo {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fetchStreamableVideoInRecyclerViewAdapter(Executor executor, Handler handler, Call<String> streamableCall,
|
||||||
|
FetchStreamableVideoListener fetchStreamableVideoListener) {
|
||||||
|
executor.execute(() -> {
|
||||||
|
try {
|
||||||
|
Response<String> response = streamableCall.execute();
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
JSONObject jsonObject = new JSONObject(response.body());
|
||||||
|
String title = jsonObject.getString(JSONUtils.TITLE_KEY);
|
||||||
|
JSONObject filesObject = jsonObject.getJSONObject(JSONUtils.FILES_KEY);
|
||||||
|
StreamableVideo.Media mp4 = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_KEY));
|
||||||
|
StreamableVideo.Media mp4Mobile = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
|
||||||
|
if (mp4 == null && mp4Mobile == null) {
|
||||||
|
handler.post(fetchStreamableVideoListener::failed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handler.post(() -> fetchStreamableVideoListener.success(new StreamableVideo(title, mp4, mp4Mobile)));
|
||||||
|
} else {
|
||||||
|
handler.post(fetchStreamableVideoListener::failed);
|
||||||
|
}
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static StreamableVideo.Media parseMedia(JSONObject jsonObject) {
|
private static StreamableVideo.Media parseMedia(JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
|
@@ -80,10 +80,12 @@ import jp.wasabeef.glide.transformations.BlurTransformation;
|
|||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
||||||
|
import ml.docilealligator.infinityforreddit.FetchStreamableVideo;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
|
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
|
import ml.docilealligator.infinityforreddit.StreamableVideo;
|
||||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||||
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
|
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
|
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
|
||||||
@@ -94,6 +96,8 @@ import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity
|
|||||||
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.apis.GfycatAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIcon;
|
import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIcon;
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.LoadUserData;
|
import ml.docilealligator.infinityforreddit.asynctasks.LoadUserData;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
|
||||||
@@ -112,6 +116,7 @@ import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
|||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
import retrofit2.Call;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements CacheManager {
|
public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements CacheManager {
|
||||||
@@ -130,6 +135,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
private Retrofit mOauthRetrofit;
|
private Retrofit mOauthRetrofit;
|
||||||
private Retrofit mGfycatRetrofit;
|
private Retrofit mGfycatRetrofit;
|
||||||
private Retrofit mRedgifsRetrofit;
|
private Retrofit mRedgifsRetrofit;
|
||||||
|
private Retrofit mStreamableRetrofit;
|
||||||
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Markwon mPostDetailMarkwon;
|
private Markwon mPostDetailMarkwon;
|
||||||
@@ -202,8 +208,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
public PostDetailRecyclerViewAdapter(AppCompatActivity activity, ViewPostDetailFragment fragment,
|
public PostDetailRecyclerViewAdapter(AppCompatActivity activity, ViewPostDetailFragment fragment,
|
||||||
Executor executor, CustomThemeWrapper customThemeWrapper,
|
Executor executor, CustomThemeWrapper customThemeWrapper,
|
||||||
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
|
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
|
||||||
Retrofit redgifsRetrofit, RedditDataRoomDatabase redditDataRoomDatabase,
|
Retrofit redgifsRetrofit, Retrofit streamableRetrofit,
|
||||||
RequestManager glide,
|
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
|
||||||
boolean separatePostAndComments, String accessToken,
|
boolean separatePostAndComments, String accessToken,
|
||||||
String accountName, Post post, Locale locale,
|
String accountName, Post post, Locale locale,
|
||||||
SharedPreferences sharedPreferences,
|
SharedPreferences sharedPreferences,
|
||||||
@@ -218,6 +224,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mOauthRetrofit = oauthRetrofit;
|
mOauthRetrofit = oauthRetrofit;
|
||||||
mGfycatRetrofit = gfycatRetrofit;
|
mGfycatRetrofit = gfycatRetrofit;
|
||||||
mRedgifsRetrofit = redgifsRetrofit;
|
mRedgifsRetrofit = redgifsRetrofit;
|
||||||
|
mStreamableRetrofit = streamableRetrofit;
|
||||||
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
mGlide = glide;
|
mGlide = glide;
|
||||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
@@ -633,13 +640,18 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
}
|
}
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo) ? 0f : 1f);
|
((PostDetailVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo) ? 0f : 1f);
|
||||||
|
|
||||||
if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
|
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
|
(mPost.isGfycat() ? mGfycatRetrofit : mRedgifsRetrofit).create(GfycatAPI.class).getGfycatData(mPost.getGfycatId());
|
||||||
|
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
|
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, mPost.getGfycatId(),
|
||||||
|
mPost.isGfycat(), mAutomaticallyTryRedgifs,
|
||||||
|
new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success(String webm, String mp4) {
|
public void success(String webm, String mp4) {
|
||||||
mPost.setVideoDownloadUrl(mp4);
|
mPost.setVideoDownloadUrl(mp4);
|
||||||
mPost.setVideoUrl(webm);
|
mPost.setVideoUrl(mp4);
|
||||||
mPost.setLoadGfyOrRedgifsVideoSuccess(true);
|
mPost.setLoadGfyOrStreamableVideoSuccess(true);
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl()));
|
((PostDetailVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -648,10 +660,26 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
((PostDetailVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.VISIBLE);
|
((PostDetailVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks
|
} else if(mPost.isStreamable() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
mGfycatRetrofit, mRedgifsRetrofit, mPost.getGfycatId(),
|
mStreamableRetrofit.create(StreamableAPI.class).getStreamableData(mPost.getStreamableShortCode());
|
||||||
mPost.isGfycat(), mAutomaticallyTryRedgifs);
|
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
|
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
||||||
|
new FetchStreamableVideo.FetchStreamableVideoListener() {
|
||||||
|
@Override
|
||||||
|
public void success(StreamableVideo streamableVideo) {
|
||||||
|
StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4;
|
||||||
|
mPost.setVideoDownloadUrl(media.url);
|
||||||
|
mPost.setVideoUrl(media.url);
|
||||||
|
mPost.setLoadGfyOrStreamableVideoSuccess(true);
|
||||||
|
((PostDetailVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed() {
|
||||||
|
((PostDetailVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl()));
|
((PostDetailVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl()));
|
||||||
}
|
}
|
||||||
@@ -1014,8 +1042,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
((PostDetailBaseViewHolder) holder).mNSFWTextView.setVisibility(View.GONE);
|
((PostDetailBaseViewHolder) holder).mNSFWTextView.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (holder instanceof PostDetailVideoAutoplayViewHolder) {
|
if (holder instanceof PostDetailVideoAutoplayViewHolder) {
|
||||||
if (((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks != null) {
|
if (((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) {
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks.cancel();
|
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel();
|
||||||
|
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null;
|
||||||
}
|
}
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.GONE);
|
((PostDetailVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.GONE);
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
|
((PostDetailVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
|
||||||
@@ -1504,7 +1533,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PostDetailVideoAutoplayViewHolder extends PostDetailBaseViewHolder implements ToroPlayer {
|
class PostDetailVideoAutoplayViewHolder extends PostDetailBaseViewHolder implements ToroPlayer {
|
||||||
public FetchGfycatOrRedgifsVideoLinks fetchGfycatOrRedgifsVideoLinks;
|
public Call<String> fetchGfycatOrStreamableVideoCall;
|
||||||
@BindView(R.id.icon_gif_image_view_item_post_detail_video_autoplay)
|
@BindView(R.id.icon_gif_image_view_item_post_detail_video_autoplay)
|
||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
@BindView(R.id.subreddit_text_view_item_post_detail_video_autoplay)
|
@BindView(R.id.subreddit_text_view_item_post_detail_video_autoplay)
|
||||||
@@ -1613,14 +1642,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
if (mPost.isGfycat()) {
|
if (mPost.isGfycat()) {
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
|
||||||
if (mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if (mPost.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
}
|
}
|
||||||
} else if (mPost.isRedgifs()) {
|
} else if (mPost.isRedgifs()) {
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
|
||||||
if (mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if (mPost.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
}
|
}
|
||||||
|
@@ -68,10 +68,12 @@ import im.ene.toro.widget.Container;
|
|||||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
||||||
|
import ml.docilealligator.infinityforreddit.FetchStreamableVideo;
|
||||||
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
|
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
|
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
|
import ml.docilealligator.infinityforreddit.StreamableVideo;
|
||||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||||
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
|
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||||
@@ -81,6 +83,8 @@ import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity
|
|||||||
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.apis.GfycatAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
|
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
|
||||||
@@ -92,6 +96,7 @@ import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
|||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
import retrofit2.Call;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,6 +132,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
private Retrofit mOauthRetrofit;
|
private Retrofit mOauthRetrofit;
|
||||||
private Retrofit mGfycatRetrofit;
|
private Retrofit mGfycatRetrofit;
|
||||||
private Retrofit mRedgifsRetrofit;
|
private Retrofit mRedgifsRetrofit;
|
||||||
|
private Retrofit mStreamableRetrofit;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
@@ -205,7 +211,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
private Callback mCallback;
|
private Callback mCallback;
|
||||||
|
|
||||||
public PostRecyclerViewAdapter(AppCompatActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
|
public PostRecyclerViewAdapter(AppCompatActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
|
||||||
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit,
|
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Retrofit streambleRetrofit,
|
||||||
CustomThemeWrapper customThemeWrapper, Locale locale,
|
CustomThemeWrapper customThemeWrapper, Locale locale,
|
||||||
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
|
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences nsfwAndSpoilerSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences nsfwAndSpoilerSharedPreferences,
|
||||||
@@ -220,6 +226,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
mOauthRetrofit = oauthRetrofit;
|
mOauthRetrofit = oauthRetrofit;
|
||||||
mGfycatRetrofit = gfycatRetrofit;
|
mGfycatRetrofit = gfycatRetrofit;
|
||||||
mRedgifsRetrofit = redgifsRetrofit;
|
mRedgifsRetrofit = redgifsRetrofit;
|
||||||
|
mStreamableRetrofit = streambleRetrofit;
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
mPostType = postType;
|
mPostType = postType;
|
||||||
mDisplaySubredditName = displaySubredditName;
|
mDisplaySubredditName = displaySubredditName;
|
||||||
@@ -685,13 +692,18 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
((PostVideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f);
|
((PostVideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
|
(post.isGfycat() ? mGfycatRetrofit : mRedgifsRetrofit).create(GfycatAPI.class).getGfycatData(post.getGfycatId());
|
||||||
|
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, post.getGfycatId(),
|
||||||
|
post.isGfycat(), mAutomaticallyTryRedgifs,
|
||||||
|
new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success(String webm, String mp4) {
|
public void success(String webm, String mp4) {
|
||||||
post.setVideoDownloadUrl(mp4);
|
post.setVideoDownloadUrl(mp4);
|
||||||
post.setVideoUrl(webm);
|
post.setVideoUrl(mp4);
|
||||||
post.setLoadGfyOrRedgifsVideoSuccess(true);
|
post.setLoadGfyOrStreamableVideoSuccess(true);
|
||||||
if (position == holder.getBindingAdapterPosition()) {
|
if (position == holder.getBindingAdapterPosition()) {
|
||||||
((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
||||||
}
|
}
|
||||||
@@ -704,10 +716,30 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks
|
} else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
mGfycatRetrofit, mRedgifsRetrofit, post.getGfycatId(),
|
mStreamableRetrofit.create(StreamableAPI.class).getStreamableData(post.getStreamableShortCode());
|
||||||
post.isGfycat(), mAutomaticallyTryRedgifs);
|
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
||||||
|
new FetchStreamableVideo.FetchStreamableVideoListener() {
|
||||||
|
@Override
|
||||||
|
public void success(StreamableVideo streamableVideo) {
|
||||||
|
StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4;
|
||||||
|
post.setVideoDownloadUrl(media.url);
|
||||||
|
post.setVideoUrl(media.url);
|
||||||
|
post.setLoadGfyOrStreamableVideoSuccess(true);
|
||||||
|
if (position == holder.getBindingAdapterPosition()) {
|
||||||
|
((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed() {
|
||||||
|
if (position == holder.getBindingAdapterPosition()) {
|
||||||
|
((PostVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
||||||
}
|
}
|
||||||
@@ -812,13 +844,18 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
((PostCard2VideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f);
|
((PostCard2VideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
|
(post.isGfycat() ? mGfycatRetrofit : mRedgifsRetrofit).create(GfycatAPI.class).getGfycatData(post.getGfycatId());
|
||||||
|
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, post.getGfycatId(),
|
||||||
|
post.isGfycat(), mAutomaticallyTryRedgifs,
|
||||||
|
new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success(String webm, String mp4) {
|
public void success(String webm, String mp4) {
|
||||||
post.setVideoDownloadUrl(mp4);
|
post.setVideoDownloadUrl(mp4);
|
||||||
post.setVideoUrl(webm);
|
post.setVideoUrl(mp4);
|
||||||
post.setLoadGfyOrRedgifsVideoSuccess(true);
|
post.setLoadGfyOrStreamableVideoSuccess(true);
|
||||||
if (position == holder.getBindingAdapterPosition()) {
|
if (position == holder.getBindingAdapterPosition()) {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
((PostCard2VideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
||||||
}
|
}
|
||||||
@@ -831,10 +868,30 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks
|
} else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||||
mGfycatRetrofit, mRedgifsRetrofit, post.getGfycatId(), post.isGfycat(),
|
mStreamableRetrofit.create(StreamableAPI.class).getStreamableData(post.getStreamableShortCode());
|
||||||
mAutomaticallyTryRedgifs);
|
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||||
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
|
||||||
|
new FetchStreamableVideo.FetchStreamableVideoListener() {
|
||||||
|
@Override
|
||||||
|
public void success(StreamableVideo streamableVideo) {
|
||||||
|
StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4;
|
||||||
|
post.setVideoDownloadUrl(media.url);
|
||||||
|
post.setVideoUrl(media.url);
|
||||||
|
post.setLoadGfyOrStreamableVideoSuccess(true);
|
||||||
|
if (position == holder.getBindingAdapterPosition()) {
|
||||||
|
((PostCard2VideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed() {
|
||||||
|
if (position == holder.getBindingAdapterPosition()) {
|
||||||
|
((PostCard2VideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
((PostCard2VideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
||||||
}
|
}
|
||||||
@@ -1693,8 +1750,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
((PostBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor);
|
((PostBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor);
|
||||||
if (holder instanceof PostVideoAutoplayViewHolder) {
|
if (holder instanceof PostVideoAutoplayViewHolder) {
|
||||||
((PostVideoAutoplayViewHolder) holder).mediaUri = null;
|
((PostVideoAutoplayViewHolder) holder).mediaUri = null;
|
||||||
if (((PostVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks != null) {
|
if (((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) {
|
||||||
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks.cancel();
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel();
|
||||||
|
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null;
|
||||||
}
|
}
|
||||||
((PostVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE);
|
((PostVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE);
|
||||||
((PostVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
|
((PostVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
|
||||||
@@ -1715,8 +1773,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.GONE);
|
((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.GONE);
|
||||||
} else if (holder instanceof PostCard2VideoAutoplayViewHolder) {
|
} else if (holder instanceof PostCard2VideoAutoplayViewHolder) {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).mediaUri = null;
|
((PostCard2VideoAutoplayViewHolder) holder).mediaUri = null;
|
||||||
if (((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks != null) {
|
if (((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks.cancel();
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel();
|
||||||
|
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null;
|
||||||
}
|
}
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE);
|
((PostCard2VideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE);
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
|
((PostCard2VideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
|
||||||
@@ -2558,7 +2617,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
ExoPlayerViewHelper helper;
|
ExoPlayerViewHelper helper;
|
||||||
private Uri mediaUri;
|
private Uri mediaUri;
|
||||||
private float volume;
|
private float volume;
|
||||||
public FetchGfycatOrRedgifsVideoLinks fetchGfycatOrRedgifsVideoLinks;
|
public Call<String> fetchGfycatOrStreamableVideoCall;
|
||||||
|
//public FetchGfycatOrRedgifsVideoLinks fetchGfycatOrRedgifsVideoLinks;
|
||||||
|
|
||||||
PostVideoAutoplayViewHolder(View itemView) {
|
PostVideoAutoplayViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@@ -2616,14 +2676,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
if (post.isGfycat()) {
|
if (post.isGfycat()) {
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
||||||
if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
}
|
}
|
||||||
} else if (post.isRedgifs()) {
|
} else if (post.isRedgifs()) {
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
||||||
if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
}
|
}
|
||||||
@@ -3839,7 +3899,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
ExoPlayerViewHelper helper;
|
ExoPlayerViewHelper helper;
|
||||||
private Uri mediaUri;
|
private Uri mediaUri;
|
||||||
private float volume;
|
private float volume;
|
||||||
public FetchGfycatOrRedgifsVideoLinks fetchGfycatOrRedgifsVideoLinks;
|
public Call<String> fetchGfycatOrStreamableVideoCall;
|
||||||
|
|
||||||
PostCard2VideoAutoplayViewHolder(View itemView) {
|
PostCard2VideoAutoplayViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@@ -3900,14 +3960,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
if (post.isGfycat()) {
|
if (post.isGfycat()) {
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
||||||
if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
}
|
}
|
||||||
} else if (post.isRedgifs()) {
|
} else if (post.isRedgifs()) {
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
|
||||||
if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
|
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||||
}
|
}
|
||||||
|
@@ -183,6 +183,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
@Named("redgifs")
|
@Named("redgifs")
|
||||||
Retrofit mRedgifsRetrofit;
|
Retrofit mRedgifsRetrofit;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("streamable")
|
||||||
|
Retrofit mStreamableRetrofit;
|
||||||
|
@Inject
|
||||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default")
|
@Named("default")
|
||||||
@@ -446,7 +449,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
|
||||||
accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@@ -523,7 +526,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
|
||||||
accessToken, accountName, postType, postLayout, displaySubredditName,
|
accessToken, accountName, postType, postLayout, displaySubredditName,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@@ -594,7 +597,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
|
||||||
accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@@ -659,7 +662,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
|
||||||
accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@@ -720,7 +723,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
|
||||||
accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@@ -780,7 +783,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
|
||||||
accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@@ -834,7 +837,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mStreamableRetrofit, mCustomThemeWrapper, locale,
|
||||||
accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
|
@@ -66,7 +66,6 @@ import butterknife.ButterKnife;
|
|||||||
import im.ene.toro.exoplayer.ExoCreator;
|
import im.ene.toro.exoplayer.ExoCreator;
|
||||||
import im.ene.toro.media.PlaybackInfo;
|
import im.ene.toro.media.PlaybackInfo;
|
||||||
import im.ene.toro.media.VolumeInfo;
|
import im.ene.toro.media.VolumeInfo;
|
||||||
import im.ene.toro.widget.Container;
|
|
||||||
import ml.docilealligator.infinityforreddit.DeleteThing;
|
import ml.docilealligator.infinityforreddit.DeleteThing;
|
||||||
import ml.docilealligator.infinityforreddit.Flair;
|
import ml.docilealligator.infinityforreddit.Flair;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
@@ -154,6 +153,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
@Named("redgifs")
|
@Named("redgifs")
|
||||||
Retrofit mRedgifsRetrofit;
|
Retrofit mRedgifsRetrofit;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("streamable")
|
||||||
|
Retrofit mStreamableRetrofit;
|
||||||
|
@Inject
|
||||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default")
|
@Named("default")
|
||||||
@@ -544,7 +546,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
|
|
||||||
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||||
this, mExecutor, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit,
|
this, mExecutor, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide,
|
mRedgifsRetrofit, mStreamableRetrofit, mRedditDataRoomDatabase, mGlide,
|
||||||
mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
|
mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
||||||
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
||||||
@@ -1190,7 +1192,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||||
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
||||||
mRetrofit, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
mRetrofit, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
||||||
mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
|
mStreamableRetrofit, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
|
||||||
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
||||||
mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
||||||
mExoCreator,
|
mExoCreator,
|
||||||
|
@@ -55,7 +55,7 @@ public class Post implements Parcelable {
|
|||||||
private boolean isGfycat;
|
private boolean isGfycat;
|
||||||
private boolean isRedgifs;
|
private boolean isRedgifs;
|
||||||
private boolean isStreamable;
|
private boolean isStreamable;
|
||||||
private boolean loadGfyOrRedgifsVideoSuccess;
|
private boolean loadGfyOrStreamableVideoSuccess;
|
||||||
private String permalink;
|
private String permalink;
|
||||||
private String flair;
|
private String flair;
|
||||||
private String awards;
|
private String awards;
|
||||||
@@ -178,7 +178,7 @@ public class Post implements Parcelable {
|
|||||||
isGfycat = in.readByte() != 0;
|
isGfycat = in.readByte() != 0;
|
||||||
isRedgifs = in.readByte() != 0;
|
isRedgifs = in.readByte() != 0;
|
||||||
isStreamable = in.readByte() != 0;
|
isStreamable = in.readByte() != 0;
|
||||||
loadGfyOrRedgifsVideoSuccess = in.readByte() != 0;
|
loadGfyOrStreamableVideoSuccess = in.readByte() != 0;
|
||||||
permalink = in.readString();
|
permalink = in.readString();
|
||||||
flair = in.readString();
|
flair = in.readString();
|
||||||
awards = in.readString();
|
awards = in.readString();
|
||||||
@@ -357,12 +357,12 @@ public class Post implements Parcelable {
|
|||||||
this.isStreamable = isStreamable;
|
this.isStreamable = isStreamable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoadGfycatOrRedgifsVideoSuccess() {
|
public boolean isLoadGfycatOrStreamableVideoSuccess() {
|
||||||
return loadGfyOrRedgifsVideoSuccess;
|
return loadGfyOrStreamableVideoSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadGfyOrRedgifsVideoSuccess(boolean loadGfyOrRedgifsVideoSuccess) {
|
public void setLoadGfyOrStreamableVideoSuccess(boolean loadGfyOrStreamableVideoSuccess) {
|
||||||
this.loadGfyOrRedgifsVideoSuccess = loadGfyOrRedgifsVideoSuccess;
|
this.loadGfyOrStreamableVideoSuccess = loadGfyOrStreamableVideoSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermalink() {
|
public String getPermalink() {
|
||||||
@@ -556,7 +556,7 @@ public class Post implements Parcelable {
|
|||||||
parcel.writeByte((byte) (isGfycat ? 1 : 0));
|
parcel.writeByte((byte) (isGfycat ? 1 : 0));
|
||||||
parcel.writeByte((byte) (isRedgifs ? 1 : 0));
|
parcel.writeByte((byte) (isRedgifs ? 1 : 0));
|
||||||
parcel.writeByte((byte) (isStreamable ? 1 : 0));
|
parcel.writeByte((byte) (isStreamable ? 1 : 0));
|
||||||
parcel.writeByte((byte) (loadGfyOrRedgifsVideoSuccess ? 1 : 0));
|
parcel.writeByte((byte) (loadGfyOrStreamableVideoSuccess ? 1 : 0));
|
||||||
parcel.writeString(permalink);
|
parcel.writeString(permalink);
|
||||||
parcel.writeString(flair);
|
parcel.writeString(flair);
|
||||||
parcel.writeString(awards);
|
parcel.writeString(awards);
|
||||||
|
Reference in New Issue
Block a user