aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-09-12 15:28:19 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-09-12 15:28:19 +0000
commit05e3889fe7eb9c01bd050da1da9d9e7f24f0945e (patch)
tree3c757c1f457815954e52a9c12286c8ecacb1c308
parent52ee70a57e988eb1cd3c6018a954278323e523ce (diff)
downloadinfinity-for-reddit-05e3889fe7eb9c01bd050da1da9d9e7f24f0945e.tar
infinity-for-reddit-05e3889fe7eb9c01bd050da1da9d9e7f24f0945e.tar.gz
infinity-for-reddit-05e3889fe7eb9c01bd050da1da9d9e7f24f0945e.tar.bz2
infinity-for-reddit-05e3889fe7eb9c01bd050da1da9d9e7f24f0945e.tar.lz
infinity-for-reddit-05e3889fe7eb9c01bd050da1da9d9e7f24f0945e.tar.xz
infinity-for-reddit-05e3889fe7eb9c01bd050da1da9d9e7f24f0945e.tar.zst
infinity-for-reddit-05e3889fe7eb9c01bd050da1da9d9e7f24f0945e.zip
Fix gfycat videos cannot be played after clicking the preview or fullscreen in PostRecyclerViewAdapter and CommentAndPostRecyclerViewAdapter.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java39
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java40
3 files changed, 66 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
index 8e26f0e0..946d92a5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
@@ -33,7 +33,6 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.TrackGroupArray;
-import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
@@ -217,6 +216,8 @@ public class ViewVideoActivity extends AppCompatActivity {
mVideoUri = Uri.parse(videoUrl);
videoDownloadUrl = savedInstanceState.getString(VIDEO_DOWNLOAD_URL_STATE);
}
+ } else {
+ mVideoUri = intent.getData();
}
if (mVideoUri == null) {
@@ -234,7 +235,7 @@ public class ViewVideoActivity extends AppCompatActivity {
} else {
dataSourceFactory = new DefaultDataSourceFactory(ViewVideoActivity.this,
Util.getUserAgent(ViewVideoActivity.this, "Infinity"));
- player.prepare(new DashMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
+ player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri));
preparePlayer(savedInstanceState);
}
} else if (videoType == VIDEO_TYPE_DIRECT) {
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 c86b4d38..b93f3375 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -2353,10 +2353,25 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
fullscreenButton.setOnClickListener(view -> {
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
- intent.setData(Uri.parse(mPost.getVideoUrl()));
- intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
- intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
- intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
+ if (mPost.isGfycat()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
+ if (mPost.isLoadGfyOrRedgifsVideoSuccess()) {
+ intent.setData(Uri.parse(mPost.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
+ }
+ } else if (mPost.isRedgifs()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
+ if (mPost.isLoadGfyOrRedgifsVideoSuccess()) {
+ intent.setData(Uri.parse(mPost.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
+ }
+ } else {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
+ intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
+ intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
+ }
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition());
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW());
@@ -2551,10 +2566,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mImageView.setOnClickListener(view -> {
if (mPost.getPostType() == Post.VIDEO_TYPE) {
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
- intent.setData(Uri.parse(mPost.getVideoUrl()));
- intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
- intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
- intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
+ if (mPost.isGfycat()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
+ } else if (mPost.isRedgifs()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
+ } else {
+ intent.setData(Uri.parse(mPost.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
+ intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
+ }
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW());
mActivity.startActivity(intent);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 9315f153..db81a51f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -1868,10 +1868,26 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Post post = getItem(position);
if (post != null) {
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
- intent.setData(Uri.parse(post.getVideoUrl()));
- intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
- intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
- intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
+ if (post.isGfycat()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
+ if (post.isLoadGfyOrRedgifsVideoSuccess()) {
+ intent.setData(Uri.parse(post.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
+ }
+ } else if (post.isRedgifs()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
+ if (post.isLoadGfyOrRedgifsVideoSuccess()) {
+ intent.setData(Uri.parse(post.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
+ }
+ } else {
+ intent.setData(Uri.parse(post.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
+ intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
+ intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
+ }
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition());
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
@@ -2081,10 +2097,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (post != null) {
if (post.getPostType() == Post.VIDEO_TYPE) {
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
- intent.setData(Uri.parse(post.getVideoUrl()));
- intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
- intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
- intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
+ if (post.isGfycat()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
+ } else if (post.isRedgifs()) {
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
+ intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
+ } else {
+ intent.setData(Uri.parse(post.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
+ intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
+ }
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
mActivity.startActivity(intent);