From aa673436ab4fb13a810b6cdc4624f830c529d704 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sun, 13 Sep 2020 22:10:43 +0800 Subject: Gfycat and Redgifs videos autoplay in CommentAndPostRecyclerViewAdapter is available. Show an error icon when loading gfycats and redgifs videos failed in PostRecyclerViewAdapter and CommentAndPostRecyclerViewAdapter. --- .../Activity/ViewPostDetailActivity.java | 12 +++++- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 49 ++++++++++++++++++++-- .../Adapter/PostRecyclerViewAdapter.java | 5 ++- app/src/main/res/drawable/ic_error_white_36dp.xml | 9 ++++ .../res/layout/item_post_detail_video_autoplay.xml | 10 +++++ .../res/layout/item_post_video_type_autoplay.xml | 10 +++++ 6 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/ic_error_white_36dp.xml (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index d317800c..9b34f58f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -172,6 +172,12 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Named("oauth") Retrofit mOauthRetrofit; @Inject + @Named("gfycat") + Retrofit mGfycatRetrofit; + @Inject + @Named("redgifs") + Retrofit mRedgifsRetrofit; + @Inject RedditDataRoomDatabase mRedditDataRoomDatabase; @Inject @Named("default") @@ -489,7 +495,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS setupMenu(); mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this, - mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide, + mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit, + mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide, mWindowWidth, mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences, mExoCreator, new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() { @@ -651,7 +658,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS setupMenu(); mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this, - mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide, + mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit, + mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide, mWindowWidth, mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences, mExoCreator, new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index b93f3375..0faf9c78 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -105,6 +105,7 @@ import ml.docilealligator.infinityforreddit.Comment.FetchComment; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager; +import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; @@ -141,6 +142,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter + + diff --git a/app/src/main/res/layout/item_post_detail_video_autoplay.xml b/app/src/main/res/layout/item_post_detail_video_autoplay.xml index 6f3183b7..79e32dd7 100644 --- a/app/src/main/res/layout/item_post_detail_video_autoplay.xml +++ b/app/src/main/res/layout/item_post_detail_video_autoplay.xml @@ -214,6 +214,16 @@ android:scaleType="fitStart" android:visibility="gone" /> + + + +