diff options
Diffstat (limited to '')
13 files changed, 1160 insertions, 173 deletions
diff --git a/app/build.gradle b/app/build.gradle index 592a625d..fced4802 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -98,6 +98,7 @@ dependencies { implementation "androidx.startup:startup-runtime:1.0.0-alpha01" //crashy implementation 'com.github.CraZyLegenD:Crashy:1.0.5' + implementation 'com.github.Piasy:BigImageViewer:1.6.5' def toroVersion = '3.7.0.2010003' implementation "im.ene.toro3:toro:$toroVersion" diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java index 68631472..8c7da456 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java @@ -26,7 +26,6 @@ import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; -import com.alexvasilkov.gestures.views.GestureFrameLayout; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; import com.bumptech.glide.load.DataSource; @@ -36,6 +35,11 @@ import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.transition.Transition; +import com.github.piasy.biv.BigImageViewer; +import com.github.piasy.biv.loader.ImageLoader; +import com.github.piasy.biv.loader.glide.GlideImageLoader; +import com.github.piasy.biv.view.BigImageView; +import com.github.piasy.biv.view.GlideImageViewFactory; import com.thefuntasty.hauler.DragDirection; import com.thefuntasty.hauler.HaulerView; @@ -63,7 +67,6 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.WallpaperSetter; -import pl.droidsonroids.gif.GifImageView; public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback { @@ -77,9 +80,13 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa @BindView(R.id.progress_bar_view_image_or_gif_activity) ProgressBar mProgressBar; @BindView(R.id.image_view_view_image_or_gif_activity) - GifImageView mImageView; + BigImageView mImageView; + /*@BindView(R.id.image_view_view_image_or_gif_activity) + SubsamplingScaleImageView mImageView; @BindView(R.id.gesture_layout_view_image_or_gif_activity) GestureFrameLayout gestureLayout; + @BindView(R.id.gif_view_view_image_or_gif_activity) + GifImageView mGifView;*/ @BindView(R.id.load_image_error_linear_layout_view_image_or_gif_activity) LinearLayout mLoadErrorLinearLayout; @Inject @@ -119,6 +126,8 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences .getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true); + BigImageViewer.initialize(GlideImageLoader.with(this)); + setContentView(R.layout.activity_view_image_or_gif); ButterKnife.bind(this); @@ -161,10 +170,6 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa loadImage(); }); - loadImage(); - - gestureLayout.getController().getSettings().setMaxZoom(10f).setDoubleTapZoom(2f).setPanEnabled(true); - mImageView.setOnClickListener(view -> { if (isActionBarHidden) { getWindow().getDecorView().setSystemUiVisibility( @@ -183,23 +188,102 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa isActionBarHidden = true; } }); - } - private void loadImage() { - glide.load(mImageUrl).listener(new RequestListener<Drawable>() { + mImageView.setImageViewFactory(new GlideImageViewFactory()); + + mImageView.setImageLoaderCallback(new ImageLoader.Callback() { + @Override + public void onCacheHit(int imageType, File image) { + + } + + @Override + public void onCacheMiss(int imageType, File image) { + + } + + @Override + public void onStart() { + + } + + @Override + public void onProgress(int progress) { + + } + + @Override + public void onFinish() { + + } + @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { + public void onSuccess(File image) { mProgressBar.setVisibility(View.GONE); - mLoadErrorLinearLayout.setVisibility(View.VISIBLE); - return false; } @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { + public void onFail(Exception error) { mProgressBar.setVisibility(View.GONE); - return false; + mLoadErrorLinearLayout.setVisibility(View.VISIBLE); } - }).override(Target.SIZE_ORIGINAL).into(mImageView); + }); + + /*if (isGif) { + gestureLayout.setVisibility(View.VISIBLE); + gestureLayout.getController().getSettings().setMaxZoom(10f).setDoubleTapZoom(2f).setPanEnabled(true); + mGifView.setOnClickListener(imageViewOnClickListener); + } else { + mImageView.setVisibility(View.VISIBLE); + mImageView.setOnClickListener(imageViewOnClickListener); + }*/ + + loadImage(); + } + + private void loadImage() { + mImageView.showImage(Uri.parse(mImageUrl)); + /*if (isGif) { + glide.load(mImageUrl).listener(new RequestListener<Drawable>() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { + mProgressBar.setVisibility(View.GONE); + mLoadErrorLinearLayout.setVisibility(View.VISIBLE); + return false; + } + + @Override + public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { + mProgressBar.setVisibility(View.GONE); + return false; + } + }).override(Target.SIZE_ORIGINAL).into(mGifView); + } else { + glide.asBitmap().load(mImageUrl).listener(new RequestListener<Bitmap>() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { + mProgressBar.setVisibility(View.GONE); + mLoadErrorLinearLayout.setVisibility(View.VISIBLE); + return false; + } + + @Override + public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { + mProgressBar.setVisibility(View.GONE); + return false; + } + }).override(Target.SIZE_ORIGINAL).into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + mImageView.setImage(ImageSource.bitmap(resource)); + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); + }*/ } @Override 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 50c85c54..af2ac5aa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -31,6 +31,8 @@ import androidx.transition.TransitionManager; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; import com.evernote.android.state.State; +import com.github.piasy.biv.BigImageViewer; +import com.github.piasy.biv.loader.glide.GlideImageLoader; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -63,6 +65,9 @@ import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment; import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostCommentSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Comment.Comment; +import ml.docilealligator.infinityforreddit.Comment.FetchComment; +import ml.docilealligator.infinityforreddit.Comment.FetchRemovedComment; +import ml.docilealligator.infinityforreddit.Comment.ParseComment; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer; import ml.docilealligator.infinityforreddit.DeleteThing; @@ -72,18 +77,15 @@ import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent; import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity; import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; -import ml.docilealligator.infinityforreddit.Comment.FetchComment; -import ml.docilealligator.infinityforreddit.Comment.FetchRemovedComment; -import ml.docilealligator.infinityforreddit.Post.FetchRemovedPost; import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.Comment.ParseComment; +import ml.docilealligator.infinityforreddit.Message.ReadMessage; import ml.docilealligator.infinityforreddit.Post.FetchPost; +import ml.docilealligator.infinityforreddit.Post.FetchRemovedPost; import ml.docilealligator.infinityforreddit.Post.HidePost; import ml.docilealligator.infinityforreddit.Post.ParsePost; import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.Message.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.SortType; @@ -208,6 +210,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS super.onCreate(savedInstanceState); + BigImageViewer.initialize(GlideImageLoader.with(this)); + setContentView(R.layout.activity_view_post_detail); Bridge.restoreInstanceState(this, savedInstanceState); 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 014f2cbd..45e3495e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -5,6 +5,7 @@ import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Bitmap; import android.graphics.ColorFilter; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; @@ -41,7 +42,12 @@ import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; +import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.Target; +import com.bumptech.glide.request.transition.Transition; +import com.davemorrissey.labs.subscaleview.ImageSource; +import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; +import com.github.piasy.biv.loader.ImageLoader; import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.text.Cue; @@ -50,10 +56,10 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.PlayerView; import com.libRG.CustomTextView; import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar; -import com.santalu.aspectratioimageview.AspectRatioImageView; import org.commonmark.ext.gfm.tables.TableBlock; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -97,7 +103,9 @@ import ml.docilealligator.infinityforreddit.BottomSheetFragment.ShareLinkBottomS import ml.docilealligator.infinityforreddit.Comment.Comment; import ml.docilealligator.infinityforreddit.Comment.FetchComment; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.CustomView.AspectRatioBigImageView; import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView; +import ml.docilealligator.infinityforreddit.CustomView.AspectRatioSubsamplingScaleImageView; import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager; import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Post.PostDataSource; @@ -109,7 +117,6 @@ import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; import ml.docilealligator.infinityforreddit.VoteThing; -import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.WRITE_COMMENT_REQUEST_CODE; @@ -117,19 +124,20 @@ import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.WRIT public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements CacheManager { private static final int VIEW_TYPE_POST_DETAIL_VIDEO_AUTOPLAY = 1; private static final int VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW = 2; - private static final int VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY = 3; - private static final int VIEW_TYPE_POST_DETAIL_LINK = 4; - private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 5; - private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 6; - private static final int VIEW_TYPE_FIRST_LOADING = 7; - private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 8; - private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 9; - private static final int VIEW_TYPE_COMMENT = 10; - private static final int VIEW_TYPE_COMMENT_FULLY_COLLAPSED = 11; - private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 12; - private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 13; - private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 14; - private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 15; + private static final int VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY = 3; + private static final int VIEW_TYPE_POST_DETAIL_IMAGE = 4; + private static final int VIEW_TYPE_POST_DETAIL_LINK = 5; + private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 6; + private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 7; + private static final int VIEW_TYPE_FIRST_LOADING = 8; + private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 9; + private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 10; + private static final int VIEW_TYPE_COMMENT = 11; + private static final int VIEW_TYPE_COMMENT_FULLY_COLLAPSED = 12; + private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 13; + private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 14; + private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 15; + private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 16; private AppCompatActivity mActivity; private Retrofit mRetrofit; @@ -432,12 +440,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy if (!mAutoplayNsfwVideos && mPost.isNSFW()) { return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW; } - return VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY; + return VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY; } else { return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW; } case Post.IMAGE_TYPE: - return VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY; + return VIEW_TYPE_POST_DETAIL_IMAGE; case Post.LINK_TYPE: return VIEW_TYPE_POST_DETAIL_LINK; case Post.NO_PREVIEW_LINK_TYPE: @@ -511,8 +519,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy return new PostDetailVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_video_autoplay, parent, false)); case VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW: return new PostDetailVideoAndGifPreviewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_video_and_gif_preview, parent, false)); - case VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY: - return new PostDetailImageAndGifAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_image_and_gif_autoplay, parent, false)); + case VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY: + return new PostDetailGifAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_gif_autoplay, parent, false)); + case VIEW_TYPE_POST_DETAIL_IMAGE: + return new PostDetailImageViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_image, parent, false)); case VIEW_TYPE_POST_DETAIL_LINK: return new PostDetailLinkViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_link, parent, false)); case VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK: @@ -703,7 +713,17 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy if (holder instanceof PostDetailVideoAutoplayViewHolder) { ((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) mPost.getPreviewWidth() / mPost.getPreviewHeight()); ((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE); - mGlide.load(mPost.getPreviewUrl()).apply(RequestOptions.noTransformation()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView); + mGlide.asBitmap().load(mPost.getPreviewUrl()).into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + ((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setImage(ImageSource.bitmap(resource)); + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); ((PostDetailVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo) ? 0f : 1f); ((PostDetailVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl())); } else if (holder instanceof PostDetailVideoAndGifPreviewHolder) { @@ -714,20 +734,17 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } ((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setRatio((float) mPost.getPreviewHeight() / (float) mPost.getPreviewWidth()); loadImage((PostDetailVideoAndGifPreviewHolder) holder); - } else if (holder instanceof PostDetailImageAndGifAutoplayViewHolder) { - if (mPost.getPostType() == Post.GIF_TYPE) { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mTypeTextView.setText(mActivity.getString(R.string.gif)); - } else { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mTypeTextView.setText(mActivity.getString(R.string.image)); - } - + } else if (holder instanceof PostDetailGifAutoplayViewHolder) { + ((PostDetailGifAutoplayViewHolder) holder).mImageView.setRatio((float) mPost.getPreviewHeight() / (float) mPost.getPreviewWidth()); + loadImage((PostDetailGifAutoplayViewHolder) holder); + } else if (holder instanceof PostDetailImageViewHolder) { if (mPost.getPreviewWidth() <= 0 || mPost.getPreviewHeight() <= 0) { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); - ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = (int) (400 * mScale); + ((PostDetailImageViewHolder) holder).mImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP); + ((PostDetailImageViewHolder) holder).mImageView.getLayoutParams().height = (int) (400 * mScale); } - ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) mPost.getPreviewHeight() / (float) mPost.getPreviewWidth()); - loadImage((PostDetailImageAndGifAutoplayViewHolder) holder); + ((PostDetailImageViewHolder) holder).mImageView.setRatio((float) mPost.getPreviewHeight() / (float) mPost.getPreviewWidth()); + loadImage((PostDetailImageViewHolder) holder); } else if (holder instanceof PostDetailLinkViewHolder) { String domain = Uri.parse(mPost.getUrl()).getHost(); ((PostDetailLinkViewHolder) holder).mLinkTextView.setText(domain); @@ -1217,40 +1234,94 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } private void loadImage(PostDetailBaseViewHolder holder) { - if (holder instanceof PostDetailImageAndGifAutoplayViewHolder) { - String url = mAutoplay && mPost.getPostType() == Post.GIF_TYPE ? mPost.getUrl() : mPost.getPreviewUrl(); - RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url) - .listener(new RequestListener<Drawable>() { + if (holder instanceof PostDetailGifAutoplayViewHolder) { + ((PostDetailGifAutoplayViewHolder) holder).mImageView.setImageLoaderCallback(new ImageLoader.Callback() { + @Override + public void onCacheHit(int imageType, File image) { + + } + + @Override + public void onCacheMiss(int imageType, File image) { + + } + + @Override + public void onStart() { + + } + + @Override + public void onProgress(int progress) { + + } + + @Override + public void onFinish() { + + } + + @Override + public void onSuccess(File image) { + ((PostDetailGifAutoplayViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + } + + @Override + public void onFail(Exception error) { + ((PostDetailGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); + ((PostDetailGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); + ((PostDetailGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { + ((PostDetailGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); + ((PostDetailGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + loadImage(holder); + }); + } + }); + ((PostDetailGifAutoplayViewHolder) holder).mImageView.showImage(Uri.parse(mPost.getUrl())); + } else if (holder instanceof PostDetailImageViewHolder) { + RequestBuilder<Bitmap> imageRequestBuilder = mGlide.asBitmap().load(mPost.getPreviewUrl()) + .listener(new RequestListener<Bitmap>() { @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { + ((PostDetailImageViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); + ((PostDetailImageViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); + ((PostDetailImageViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { + ((PostDetailImageViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); + ((PostDetailImageViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); loadImage(holder); }); return false; } @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { - ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { + ((PostDetailImageViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); return false; } }); + CustomTarget<Bitmap> customTarget = new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + ((PostDetailImageViewHolder) holder).mImageView.setImage(ImageSource.bitmap(resource)); + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }; + if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { - imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); + imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(customTarget); } else { - imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); + imageRequestBuilder.apply(RequestOptions.noTransformation()).into(customTarget); } } else if (holder instanceof PostDetailVideoAndGifPreviewHolder) { - RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(mPost.getPreviewUrl()) - .listener(new RequestListener<Drawable>() { + RequestBuilder<Bitmap> imageRequestBuilder = mGlide.asBitmap().load(mPost.getPreviewUrl()) + .listener(new RequestListener<Bitmap>() { @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { @@ -1262,23 +1333,35 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { + public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { ((PostDetailVideoAndGifPreviewHolder) holder).mLoadWrapper.setVisibility(View.GONE); return false; } }); + CustomTarget<Bitmap> customTarget = new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + ((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImage(ImageSource.bitmap(resource)); + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }; + if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); + .into(customTarget); } else { - imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); + imageRequestBuilder.apply(RequestOptions.noTransformation()).into(customTarget); } } else if (holder instanceof PostDetailLinkViewHolder) { - RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(mPost.getPreviewUrl()) - .listener(new RequestListener<Drawable>() { + RequestBuilder<Bitmap> imageRequestBuilder = mGlide.asBitmap().load(mPost.getPreviewUrl()) + .listener(new RequestListener<Bitmap>() { @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { ((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { @@ -1290,21 +1373,285 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { + public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { ((PostDetailLinkViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); return false; } }); + CustomTarget<Bitmap> customTarget = new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + ((PostDetailLinkViewHolder) holder).mImageView.setImage(ImageSource.bitmap(resource)); + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }; + if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { - imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .into(((PostDetailLinkViewHolder) holder).mImageView); + imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(customTarget); } else { - imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostDetailLinkViewHolder) holder).mImageView); + imageRequestBuilder.into(customTarget); } } } + /*private void loadImage(PostDetailBaseViewHolder holder) { + if (holder instanceof PostDetailImageAndGifAutoplayViewHolder) { + String url = mAutoplay && mPost.getPostType() == Post.GIF_TYPE ? mPost.getUrl() : mPost.getPreviewUrl(); + ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageLoaderCallback(new ImageLoader.Callback() { + @Override + public void onCacheHit(int imageType, File image) { + + } + + @Override + public void onCacheMiss(int imageType, File image) { + + } + + @Override + public void onStart() { + + } + + @Override + public void onProgress(int progress) { + + } + + @Override + public void onFinish() { + + } + + @Override + public void onSuccess(File image) { + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + } + + @Override + public void onFail(Exception error) { + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + loadImage(holder); + }); + } + }); + if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { + SubsamplingScaleImageView subsamplingScaleImageView = ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getSSIV(); + if (subsamplingScaleImageView != null) { + mGlide.asBitmap().load(url) + .listener(new RequestListener<Bitmap>() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + loadImage(holder); + }); + return false; + } + + @Override + public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { + ((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + return false; + } + }).apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + subsamplingScaleImageView.setImage(ImageSource.bitmap(resource)); + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); + } else { + ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.showImage(Uri.parse(url)); + } + } else { + ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.showImage(Uri.parse(url)); + } + } else if (holder instanceof PostDetailVideoAndGifPreviewHolder) { + ((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageLoaderCallback(new ImageLoader.Callback() { + @Override + public void onCacheHit(int imageType, File image) { + + } + + @Override + public void onCacheMiss(int imageType, File image) { + + } + + @Override + public void onStart() { + + } + + @Override + public void onProgress(int progress) { + + } + + @Override + public void onFinish() { + + } + + @Override + public void onSuccess(File image) { + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + } + + @Override + public void onFail(Exception error) { + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + loadImage(holder); + }); + } + }); + if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { + SubsamplingScaleImageView subsamplingScaleImageView = ((PostDetailVideoAndGifPreviewHolder) holder).mImageView.getSSIV(); + if (subsamplingScaleImageView != null) { + mGlide.asBitmap().load(mPost.getPreviewUrl()) + .listener(new RequestListener<Bitmap>() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + loadImage(holder); + }); + return false; + } + + @Override + public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { + ((PostDetailVideoAndGifPreviewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + return false; + } + }).apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) + .into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + subsamplingScaleImageView.setImage(ImageSource.bitmap(resource)); + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); + } else { + ((PostDetailVideoAndGifPreviewHolder) holder).mImageView.showImage(Uri.parse(mPost.getPreviewUrl())); + } + } else { + ((PostDetailVideoAndGifPreviewHolder) holder).mImageView.showImage(Uri.parse(mPost.getPreviewUrl())); + } + } else if (holder instanceof PostDetailLinkViewHolder) { + ((PostDetailLinkViewHolder) holder).mImageView.setImageLoaderCallback(new ImageLoader.Callback() { + @Override + public void onCacheHit(int imageType, File image) { + + } + + @Override + public void onCacheMiss(int imageType, File image) { + + } + + @Override + public void onStart() { + + } + + @Override + public void onProgress(int progress) { + + } + + @Override + public void onFinish() { + + } + + @Override + public void onSuccess(File image) { + ((PostDetailLinkViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + } + + @Override + public void onFail(Exception error) { + ((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); + ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); + ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { + ((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); + ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + loadImage(holder); + }); + } + }); + if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { + SubsamplingScaleImageView subsamplingScaleImageView = ((PostDetailLinkViewHolder) holder).mImageView.getSSIV(); + if (subsamplingScaleImageView != null) { + mGlide.asBitmap().load(mPost.getPreviewUrl()) + .listener(new RequestListener<Bitmap>() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { + ((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE); + ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.VISIBLE); + ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setOnClickListener(view -> { + ((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.VISIBLE); + ((PostDetailLinkViewHolder) holder).mLoadImageErrorTextView.setVisibility(View.GONE); + loadImage(holder); + }); + return false; + } + + @Override + public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { + ((PostDetailLinkViewHolder) holder).mLoadWrapper.setVisibility(View.GONE); + return false; + } + }).apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) + .into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + subsamplingScaleImageView.setImage(ImageSource.bitmap(resource)); + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); + } else { + ((PostDetailLinkViewHolder) holder).mImageView.showImage(Uri.parse(mPost.getPreviewUrl())); + } + } else { + ((PostDetailLinkViewHolder) holder).mImageView.showImage(Uri.parse(mPost.getPreviewUrl())); + } + } + }*/ + public void updatePost(Post post) { mPost = post; notifyItemChanged(0); @@ -1614,8 +1961,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy ((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.GONE); } else if (holder instanceof PostDetailVideoAndGifPreviewHolder) { mGlide.clear(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); - } else if (holder instanceof PostDetailImageAndGifAutoplayViewHolder) { - mGlide.clear(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); + } else if (holder instanceof PostDetailImageViewHolder) { + mGlide.clear(((PostDetailImageViewHolder) holder).mImageView); } else if (holder instanceof PostDetailLinkViewHolder) { mGlide.clear(((PostDetailLinkViewHolder) holder).mImageView); } @@ -2112,7 +2459,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy @BindView(R.id.player_view_item_post_detail_video_autoplay) PlayerView playerView; @BindView(R.id.preview_image_view_item_post_detail_video_autoplay) - GifImageView previewImageView; + SubsamplingScaleImageView previewImageView; @BindView(R.id.mute_exo_playback_control_view) ImageView muteButton; @BindView(R.id.fullscreen_exo_playback_control_view) @@ -2331,7 +2678,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy @BindView(R.id.load_image_error_text_view_item_post_detail_video_and_gif_preview) TextView mLoadImageErrorTextView; @BindView(R.id.image_view_item_post_detail_video_and_gif_preview) - AspectRatioImageView mImageView; + AspectRatioSubsamplingScaleImageView mImageView; @BindView(R.id.bottom_constraint_layout_item_post_detail_video_and_gif_preview) ConstraintLayout mBottomConstraintLayout; @BindView(R.id.plus_button_item_post_detail_video_and_gif_preview) @@ -2397,61 +2744,163 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } } - class PostDetailImageAndGifAutoplayViewHolder extends PostDetailBaseViewHolder { - @BindView(R.id.icon_gif_image_view_item_post_detail_image_and_gif_autoplay) + class PostDetailGifAutoplayViewHolder extends PostDetailBaseViewHolder { + @BindView(R.id.icon_gif_image_view_item_post_detail_gif_autoplay) + AspectRatioGifImageView mIconGifImageView; + @BindView(R.id.subreddit_text_view_item_post_detail_gif_autoplay) + TextView mSubredditTextView; + @BindView(R.id.user_text_view_item_post_detail_gif_autoplay) + TextView mUserTextView; + @BindView(R.id.author_flair_text_view_item_post_detail_gif_autoplay) + TextView mAuthorFlairTextView; + @BindView(R.id.post_time_text_view_item_post_detail_gif_autoplay) + TextView mPostTimeTextView; + @BindView(R.id.title_text_view_item_post_detail_gif_autoplay) + TextView mTitleTextView; + @BindView(R.id.type_text_view_item_post_detail_gif_autoplay) + CustomTextView mTypeTextView; + @BindView(R.id.crosspost_image_view_item_post_detail_gif_autoplay) + ImageView mCrosspostImageView; + @BindView(R.id.archived_image_view_item_post_detail_gif_autoplay) + ImageView mArchivedImageView; + @BindView(R.id.locked_image_view_item_post_detail_gif_autoplay) + ImageView mLockedImageView; + @BindView(R.id.nsfw_text_view_item_post_detail_gif_autoplay) + CustomTextView mNSFWTextView; + @BindView(R.id.spoiler_custom_text_view_item_post_detail_gif_autoplay) + CustomTextView mSpoilerTextView; + @BindView(R.id.flair_custom_text_view_item_post_detail_gif_autoplay) + CustomTextView mFlairTextView; + @BindView(R.id.awards_text_view_item_post_detail_gif_autoplay) + TextView mAwardsTextView; + @BindView(R.id.image_view_wrapper_item_post_detail_gif_autoplay) + RelativeLayout mRelativeLayout; + @BindView(R.id.load_wrapper_item_post_detail_gif_autoplay) + RelativeLayout mLoadWrapper; + @BindView(R.id.progress_bar_item_post_detail_gif_autoplay) + ProgressBar mLoadImageProgressBar; + @BindView(R.id.load_image_error_text_view_item_post_detail_gif_autoplay) + TextView mLoadImageErrorTextView; + @BindView(R.id.image_view_item_post_detail_gif_autoplay) + AspectRatioBigImageView mImageView; + @BindView(R.id.bottom_constraint_layout_item_post_detail_gif_autoplay) + ConstraintLayout mBottomConstraintLayout; + @BindView(R.id.plus_button_item_post_detail_gif_autoplay) + ImageView mUpvoteButton; + @BindView(R.id.score_text_view_item_post_detail_gif_autoplay) + TextView mScoreTextView; + @BindView(R.id.minus_button_item_post_detail_gif_autoplay) + ImageView mDownvoteButton; + @BindView(R.id.comments_count_item_post_detail_gif_autoplay) + TextView commentsCountTextView; + @BindView(R.id.save_button_item_post_detail_gif_autoplay) + ImageView mSaveButton; + @BindView(R.id.share_button_item_post_detail_gif_autoplay) + ImageView mShareButton; + + PostDetailGifAutoplayViewHolder(@NonNull View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + setBaseView(mIconGifImageView, + mSubredditTextView, + mUserTextView, + mAuthorFlairTextView, + mPostTimeTextView, + mTitleTextView, + mTypeTextView, + mCrosspostImageView, + mArchivedImageView, + mLockedImageView, + mNSFWTextView, + mSpoilerTextView, + mFlairTextView, + mAwardsTextView, + mBottomConstraintLayout, + mUpvoteButton, + mScoreTextView, + mDownvoteButton, + commentsCountTextView, + mSaveButton, + mShareButton); + + mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); + mLoadImageErrorTextView.setTextColor(mPrimaryTextColor); + + mImageView.setOnClickListener(view -> { + if (mPost.getPostType() == Post.IMAGE_TYPE) { + Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); + intent.putExtra(ViewImageOrGifActivity.IMAGE_URL_KEY, mPost.getUrl()); + intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, mPost.getSubredditNamePrefixed().substring(2) + + "-" + mPost.getId().substring(3) + ".jpg"); + intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, mPost.getTitle()); + mActivity.startActivity(intent); + } else if (mPost.getPostType() == Post.GIF_TYPE) { + Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); + intent.putExtra(ViewImageOrGifActivity.FILE_NAME_KEY, mPost.getSubredditName() + + "-" + mPost.getId() + ".gif"); + intent.putExtra(ViewImageOrGifActivity.GIF_URL_KEY, mPost.getVideoUrl()); + intent.putExtra(ViewImageOrGifActivity.POST_TITLE_KEY, mPost.getTitle()); + mActivity.startActivity(intent); + } + }); + } + } + + class PostDetailImageViewHolder extends PostDetailBaseViewHolder { + @BindView(R.id.icon_gif_image_view_item_post_detail_image) AspectRatioGifImageView mIconGifImageView; - @BindView(R.id.subreddit_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.subreddit_text_view_item_post_detail_image) TextView mSubredditTextView; - @BindView(R.id.user_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.user_text_view_item_post_detail_image) TextView mUserTextView; - @BindView(R.id.author_flair_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.author_flair_text_view_item_post_detail_image) TextView mAuthorFlairTextView; - @BindView(R.id.post_time_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.post_time_text_view_item_post_detail_image) TextView mPostTimeTextView; - @BindView(R.id.title_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.title_text_view_item_post_detail_image) TextView mTitleTextView; - @BindView(R.id.type_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.type_text_view_item_post_detail_image) CustomTextView mTypeTextView; - @BindView(R.id.crosspost_image_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.crosspost_image_view_item_post_detail_image) ImageView mCrosspostImageView; - @BindView(R.id.archived_image_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.archived_image_view_item_post_detail_image) ImageView mArchivedImageView; - @BindView(R.id.locked_image_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.locked_image_view_item_post_detail_image) ImageView mLockedImageView; - @BindView(R.id.nsfw_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.nsfw_text_view_item_post_detail_image) CustomTextView mNSFWTextView; - @BindView(R.id.spoiler_custom_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.spoiler_custom_text_view_item_post_detail_image) CustomTextView mSpoilerTextView; - @BindView(R.id.flair_custom_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.flair_custom_text_view_item_post_detail_image) CustomTextView mFlairTextView; - @BindView(R.id.awards_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.awards_text_view_item_post_detail_image) TextView mAwardsTextView; - @BindView(R.id.image_view_wrapper_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.image_view_wrapper_item_post_detail_image) RelativeLayout mRelativeLayout; - @BindView(R.id.load_wrapper_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.load_wrapper_item_post_detail_image) RelativeLayout mLoadWrapper; - @BindView(R.id.progress_bar_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.progress_bar_item_post_detail_image) ProgressBar mLoadImageProgressBar; - @BindView(R.id.load_image_error_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.load_image_error_text_view_item_post_detail_image) TextView mLoadImageErrorTextView; - @BindView(R.id.image_view_item_post_detail_image_and_gif_autoplay) - AspectRatioImageView mImageView; - @BindView(R.id.bottom_constraint_layout_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.image_view_item_post_detail_image) + AspectRatioSubsamplingScaleImageView mImageView; + @BindView(R.id.bottom_constraint_layout_item_post_detail_image) ConstraintLayout mBottomConstraintLayout; - @BindView(R.id.plus_button_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.plus_button_item_post_detail_image) ImageView mUpvoteButton; - @BindView(R.id.score_text_view_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.score_text_view_item_post_detail_image) TextView mScoreTextView; - @BindView(R.id.minus_button_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.minus_button_item_post_detail_image) ImageView mDownvoteButton; - @BindView(R.id.comments_count_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.comments_count_item_post_detail_image) TextView commentsCountTextView; - @BindView(R.id.save_button_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.save_button_item_post_detail_image) ImageView mSaveButton; - @BindView(R.id.share_button_item_post_detail_image_and_gif_autoplay) + @BindView(R.id.share_button_item_post_detail_image) ImageView mShareButton; - PostDetailImageAndGifAutoplayViewHolder(@NonNull View itemView) { + PostDetailImageViewHolder(@NonNull View itemView) { super(itemView); ButterKnife.bind(this, itemView); setBaseView(mIconGifImageView, @@ -2539,7 +2988,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy @BindView(R.id.load_image_error_text_view_item_post_detail_link) TextView mLoadImageErrorTextView; @BindView(R.id.image_view_item_post_detail_link) - AspectRatioImageView mImageView; + AspectRatioSubsamplingScaleImageView mImageView; @BindView(R.id.bottom_constraint_layout_item_post_detail_link) ConstraintLayout mBottomConstraintLayout; @BindView(R.id.plus_button_item_post_detail_link) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioBigImageView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioBigImageView.java new file mode 100644 index 00000000..43114665 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioBigImageView.java @@ -0,0 +1,60 @@ +package ml.docilealligator.infinityforreddit.CustomView; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; + +import com.github.piasy.biv.view.BigImageView; + +public class AspectRatioBigImageView extends BigImageView { + private float ratio; + + public AspectRatioBigImageView(Context context) { + super(context); + ratio = 1.0F; + } + + public AspectRatioBigImageView(Context context, AttributeSet attrs) { + super(context, attrs); + this.ratio = 1.0F; + this.init(context, attrs); + } + + public AspectRatioBigImageView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.ratio = 1.0F; + this.init(context, attrs); + } + + public final float getRatio() { + return this.ratio; + } + + public final void setRatio(float var1) { + this.ratio = var1; + } + + private void init(Context context, AttributeSet attrs) { + if (attrs != null) { + TypedArray a = context.obtainStyledAttributes(attrs, com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView); + this.ratio = a.getFloat(com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView_ari_ratio, 1.0F); + a.recycle(); + } + + } + + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + int width = this.getMeasuredWidth(); + int height = this.getMeasuredHeight(); + if (width != 0 || height != 0) { + if (width > 0) { + height = (int) ((float) width * this.ratio); + } else { + width = (int) ((float) height / this.ratio); + } + + this.setMeasuredDimension(width, height); + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioGifImageView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioGifImageView.java index 9f9d5483..f77f5bd8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioGifImageView.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioGifImageView.java @@ -28,7 +28,7 @@ public class AspectRatioGifImageView extends GifImageView { this.ratio = var1; } - private final void init(Context context, AttributeSet attrs) { + private void init(Context context, AttributeSet attrs) { if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView); this.ratio = a.getFloat(com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView_ari_ratio, 1.0F); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioSubsamplingScaleImageView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioSubsamplingScaleImageView.java new file mode 100644 index 00000000..9877e697 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/AspectRatioSubsamplingScaleImageView.java @@ -0,0 +1,54 @@ +package ml.docilealligator.infinityforreddit.CustomView; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; + +import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; + +public class AspectRatioSubsamplingScaleImageView extends SubsamplingScaleImageView { + private float ratio; + + public AspectRatioSubsamplingScaleImageView(Context context) { + super(context); + ratio = 1.0F; + } + + public AspectRatioSubsamplingScaleImageView(Context context, AttributeSet attr) { + super(context, attr); + this.ratio = 1.0F; + this.init(context, attr); + } + + public final float getRatio() { + return this.ratio; + } + + public final void setRatio(float var1) { + this.ratio = var1; + } + + private void init(Context context, AttributeSet attrs) { + if (attrs != null) { + TypedArray a = context.obtainStyledAttributes(attrs, com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView); + this.ratio = a.getFloat(com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView_ari_ratio, 1.0F); + a.recycle(); + } + + } + + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + int width = this.getMeasuredWidth(); + int height = this.getMeasuredHeight(); + if (width != 0 || height != 0) { + if (width > 0) { + height = (int) ((float) width * this.ratio); + } else { + width = (int) ((float) height / this.ratio); + } + + this.setMeasuredDimension(width, height); + } + } +} diff --git a/app/src/main/res/layout/activity_view_image_or_gif.xml b/app/src/main/res/layout/activity_view_image_or_gif.xml index 019bbc7b..0156de76 100644 --- a/app/src/main/res/layout/activity_view_image_or_gif.xml +++ b/app/src/main/res/layout/activity_view_image_or_gif.xml @@ -23,19 +23,13 @@ android:layout_height="wrap_content" android:layout_centerInParent="true" /> - <com.alexvasilkov.gestures.views.GestureFrameLayout - android:id="@+id/gesture_layout_view_image_or_gif_activity" + <com.github.piasy.biv.view.BigImageView + android:id="@+id/image_view_view_image_or_gif_activity" android:layout_width="match_parent" - android:layout_height="match_parent"> - - <pl.droidsonroids.gif.GifImageView - android:id="@+id/image_view_view_image_or_gif_activity" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:adjustViewBounds="true" - android:scaleType="fitCenter" - app:gest_fillViewport="true" /> - </com.alexvasilkov.gestures.views.GestureFrameLayout> + android:layout_height="match_parent" + app:initScaleType="fitCenter" + app:optimizeDisplay="true" + app:tapToRetry="false" /> <LinearLayout android:id="@+id/load_image_error_linear_layout_view_image_or_gif_activity" diff --git a/app/src/main/res/layout/item_post_detail_gif_autoplay.xml b/app/src/main/res/layout/item_post_detail_gif_autoplay.xml new file mode 100644 index 00000000..f81fffd6 --- /dev/null +++ b/app/src/main/res/layout/item_post_detail_gif_autoplay.xml @@ -0,0 +1,332 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:background="?attr/cardViewBackgroundColor"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/constraint_layout_item_post_detail_gif_autoplay" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView + android:id="@+id/icon_gif_image_view_item_post_detail_gif_autoplay" + android:layout_width="24dp" + android:layout_height="24dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <TextView + android:id="@+id/subreddit_text_view_item_post_detail_gif_autoplay" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + android:maxLines="2" + android:ellipsize="end" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_gif_autoplay" + app:layout_constraintEnd_toStartOf="@id/guideline" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintHorizontal_bias="0" /> + + <TextView + android:id="@+id/user_text_view_item_post_detail_gif_autoplay" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + android:maxLines="2" + android:ellipsize="end" + app:layout_constraintBottom_toTopOf="@+id/author_flair_text_view_item_post_detail_gif_autoplay" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_gif_autoplay" + app:layout_constraintEnd_toStartOf="@id/guideline" + app:layout_constraintTop_toBottomOf="@+id/subreddit_text_view_item_post_detail_gif_autoplay" + app:layout_constraintHorizontal_bias="0" /> + + <TextView + android:id="@+id/author_flair_text_view_item_post_detail_gif_autoplay" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + android:textSize="?attr/font_12" + android:fontFamily="?attr/font_family" + android:maxLines="2" + android:ellipsize="end" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_gif_autoplay" + app:layout_constraintEnd_toStartOf="@id/guideline" + app:layout_constraintTop_toBottomOf="@+id/user_text_view_item_post_detail_gif_autoplay" + app:layout_constraintHorizontal_bias="0" /> + + <TextView + android:id="@+id/post_time_text_view_item_post_detail_gif_autoplay" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:gravity="end" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + app:layout_constraintHorizontal_bias="1" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/guideline" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_constraintGuide_percent="0.6" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + <TextView + android:id="@+id/title_text_view_item_post_detail_gif_autoplay" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/title_font_18" + android:fontFamily="?attr/title_font_family" + android:textIsSelectable="true" + android:enabled="true" + android:focusable="true" + android:longClickable="true" /> + + <com.nex3z.flowlayout.FlowLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + app:flChildSpacing="16dp" + app:flChildSpacingForLastRow="align" + app:flRowSpacing="8dp"> + + <com.libRG.CustomTextView + android:id="@+id/type_text_view_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/gif" + android:textSize="?attr/font_12" + android:fontFamily="?attr/font_family" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/spoiler_custom_text_view_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="@string/spoiler" + android:textSize="?attr/font_12" + android:fontFamily="?attr/font_family" + android:padding="4dp" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/nsfw_text_view_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/nsfw" + android:textSize="?attr/font_12" + android:fontFamily="?attr/font_family" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <com.libRG.CustomTextView + android:id="@+id/flair_custom_text_view_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:padding="4dp" + android:textSize="?attr/font_12" + android:fontFamily="?attr/font_family" + android:visibility="gone" + app:lib_setRadius="3dp" + app:lib_setRoundedView="true" + app:lib_setShape="rectangle" /> + + <ImageView + android:id="@+id/archived_image_view_item_post_detail_gif_autoplay" + android:layout_width="20dp" + android:layout_height="20dp" + android:src="@drawable/ic_archive_outline" + android:visibility="gone" /> + + <ImageView + android:id="@+id/locked_image_view_item_post_detail_gif_autoplay" + android:layout_width="20dp" + android:layout_height="20dp" + android:src="@drawable/ic_outline_lock_24dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/crosspost_image_view_item_post_detail_gif_autoplay" + android:layout_width="20dp" + android:layout_height="20dp" + android:src="@drawable/crosspost" + android:visibility="gone" /> + + <TextView + android:id="@+id/awards_text_view_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="?attr/font_12" + android:fontFamily="?attr/font_family" + android:visibility="gone" /> + + </com.nex3z.flowlayout.FlowLayout> + + <RelativeLayout + android:id="@+id/image_view_wrapper_item_post_detail_gif_autoplay" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioBigImageView + android:id="@+id/image_view_item_post_detail_gif_autoplay" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:adjustViewBounds="true" + android:scaleType="fitStart" + app:optimizeDisplay="true" + app:tapToRetry="false" + app:zoomEnabled="false" + app:panEnabled="false" /> + + <RelativeLayout + android:id="@+id/load_wrapper_item_post_detail_gif_autoplay" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_centerInParent="true"> + + <ProgressBar + android:id="@+id/progress_bar_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" /> + + <TextView + android:id="@+id/load_image_error_text_view_item_post_detail_gif_autoplay" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawableTop="@drawable/ic_error_outline_black_24dp" + android:layout_centerInParent="true" + android:gravity="center" + android:text="@string/error_loading_image_tap_to_retry" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + android:visibility="gone" /> + + </RelativeLayout> + + </RelativeLayout> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/bottom_constraint_layout_item_post_detail_gif_autoplay"> + + <ImageView + android:id="@+id/plus_button_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" + android:tint="@android:color/tab_indicator_text" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + <TextView + android:id="@+id/score_text_view_item_post_detail_gif_autoplay" + android:layout_width="64dp" + android:layout_height="wrap_content" + android:gravity="center" + android:textSize="?attr/font_12" + android:textStyle="bold" + android:fontFamily="?attr/font_family" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/plus_button_item_post_detail_gif_autoplay" /> + + <ImageView + android:id="@+id/minus_button_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_arrow_downward_grey_24dp" + android:tint="@android:color/tab_indicator_text" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_detail_gif_autoplay" /> + + <TextView + android:id="@+id/comments_count_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:gravity="center_vertical" + android:textSize="?attr/font_12" + android:textStyle="bold" + android:fontFamily="?attr/font_family" + android:drawableStart="@drawable/ic_comment_grey_24dp" + android:drawablePadding="12dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_detail_gif_autoplay" /> + + <ImageView + android:id="@+id/save_button_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:tint="@android:color/tab_indicator_text" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintHorizontal_bias="1" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@id/comments_count_item_post_detail_gif_autoplay" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_gif_autoplay" /> + + <ImageView + android:id="@+id/share_button_item_post_detail_gif_autoplay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:src="@drawable/ic_share_grey_24dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml b/app/src/main/res/layout/item_post_detail_image.xml index f4f88d5a..b31ee7b4 100644 --- a/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml +++ b/app/src/main/res/layout/item_post_detail_image.xml @@ -7,13 +7,13 @@ android:background="?attr/cardViewBackgroundColor"> <androidx.constraintlayout.widget.ConstraintLayout - android:id="@+id/constraint_layout_item_post_detail_image_and_gif_autoplay" + android:id="@+id/constraint_layout_item_post_detail_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp"> <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView - android:id="@+id/icon_gif_image_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/icon_gif_image_view_item_post_detail_image" android:layout_width="24dp" android:layout_height="24dp" app:layout_constraintBottom_toBottomOf="parent" @@ -21,7 +21,7 @@ app:layout_constraintTop_toTopOf="parent" /> <TextView - android:id="@+id/subreddit_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/subreddit_text_view_item_post_detail_image" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="16dp" @@ -30,13 +30,13 @@ android:fontFamily="?attr/font_family" android:maxLines="2" android:ellipsize="end" - app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_image_and_gif_autoplay" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_image" app:layout_constraintEnd_toStartOf="@id/guideline" app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0" /> <TextView - android:id="@+id/user_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/user_text_view_item_post_detail_image" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="16dp" @@ -45,14 +45,14 @@ android:fontFamily="?attr/font_family" android:maxLines="2" android:ellipsize="end" - app:layout_constraintBottom_toTopOf="@+id/author_flair_text_view_item_post_detail_image_and_gif_autoplay" - app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_image_and_gif_autoplay" + app:layout_constraintBottom_toTopOf="@+id/author_flair_text_view_item_post_detail_image" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_image" app:layout_constraintEnd_toStartOf="@id/guideline" - app:layout_constraintTop_toBottomOf="@+id/subreddit_text_view_item_post_detail_image_and_gif_autoplay" + app:layout_constraintTop_toBottomOf="@+id/subreddit_text_view_item_post_detail_image" app:layout_constraintHorizontal_bias="0" /> <TextView - android:id="@+id/author_flair_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/author_flair_text_view_item_post_detail_image" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="16dp" @@ -63,13 +63,13 @@ android:ellipsize="end" android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_image_and_gif_autoplay" + app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_image" app:layout_constraintEnd_toStartOf="@id/guideline" - app:layout_constraintTop_toBottomOf="@+id/user_text_view_item_post_detail_image_and_gif_autoplay" + app:layout_constraintTop_toBottomOf="@+id/user_text_view_item_post_detail_image" app:layout_constraintHorizontal_bias="0" /> <TextView - android:id="@+id/post_time_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/post_time_text_view_item_post_detail_image" android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="end" @@ -91,7 +91,7 @@ </androidx.constraintlayout.widget.ConstraintLayout> <TextView - android:id="@+id/title_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/title_text_view_item_post_detail_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="16dp" @@ -113,10 +113,11 @@ app:flRowSpacing="8dp"> <com.libRG.CustomTextView - android:id="@+id/type_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/type_text_view_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="4dp" + android:text="@string/image" android:textSize="?attr/font_12" android:fontFamily="?attr/font_family" app:lib_setRadius="3dp" @@ -124,7 +125,7 @@ app:lib_setShape="rectangle" /> <com.libRG.CustomTextView - android:id="@+id/spoiler_custom_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/spoiler_custom_text_view_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" @@ -138,7 +139,7 @@ app:lib_setShape="rectangle" /> <com.libRG.CustomTextView - android:id="@+id/nsfw_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/nsfw_text_view_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="4dp" @@ -151,7 +152,7 @@ app:lib_setShape="rectangle" /> <com.libRG.CustomTextView - android:id="@+id/flair_custom_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/flair_custom_text_view_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" @@ -164,28 +165,28 @@ app:lib_setShape="rectangle" /> <ImageView - android:id="@+id/archived_image_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/archived_image_view_item_post_detail_image" android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/ic_archive_outline" android:visibility="gone" /> <ImageView - android:id="@+id/locked_image_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/locked_image_view_item_post_detail_image" android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/ic_outline_lock_24dp" android:visibility="gone" /> <ImageView - android:id="@+id/crosspost_image_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/crosspost_image_view_item_post_detail_image" android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/crosspost" android:visibility="gone" /> <TextView - android:id="@+id/awards_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/awards_text_view_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="?attr/font_12" @@ -195,31 +196,33 @@ </com.nex3z.flowlayout.FlowLayout> <RelativeLayout - android:id="@+id/image_view_wrapper_item_post_detail_image_and_gif_autoplay" + android:id="@+id/image_view_wrapper_item_post_detail_image" android:layout_width="match_parent" android:layout_height="wrap_content"> - <com.santalu.aspectratioimageview.AspectRatioImageView - android:id="@+id/image_view_item_post_detail_image_and_gif_autoplay" + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioSubsamplingScaleImageView + android:id="@+id/image_view_item_post_detail_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" - android:scaleType="fitStart"/> + android:scaleType="fitStart" + app:zoomEnabled="false" + app:panEnabled="false" /> <RelativeLayout - android:id="@+id/load_wrapper_item_post_detail_image_and_gif_autoplay" + android:id="@+id/load_wrapper_item_post_detail_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true"> <ProgressBar - android:id="@+id/progress_bar_item_post_detail_image_and_gif_autoplay" + android:id="@+id/progress_bar_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" /> <TextView - android:id="@+id/load_image_error_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/load_image_error_text_view_item_post_detail_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableTop="@drawable/ic_error_outline_black_24dp" @@ -237,10 +240,10 @@ <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:id="@+id/bottom_constraint_layout_item_post_detail_image_and_gif_autoplay"> + android:id="@+id/bottom_constraint_layout_item_post_detail_image"> <ImageView - android:id="@+id/plus_button_item_post_detail_image_and_gif_autoplay" + android:id="@+id/plus_button_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" @@ -254,7 +257,7 @@ app:layout_constraintStart_toStartOf="parent" /> <TextView - android:id="@+id/score_text_view_item_post_detail_image_and_gif_autoplay" + android:id="@+id/score_text_view_item_post_detail_image" android:layout_width="64dp" android:layout_height="wrap_content" android:gravity="center" @@ -263,10 +266,10 @@ android:fontFamily="?attr/font_family" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toEndOf="@id/plus_button_item_post_detail_image_and_gif_autoplay" /> + app:layout_constraintStart_toEndOf="@id/plus_button_item_post_detail_image" /> <ImageView - android:id="@+id/minus_button_item_post_detail_image_and_gif_autoplay" + android:id="@+id/minus_button_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" @@ -277,10 +280,10 @@ android:focusable="true" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_detail_image_and_gif_autoplay" /> + app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_detail_image" /> <TextView - android:id="@+id/comments_count_item_post_detail_image_and_gif_autoplay" + android:id="@+id/comments_count_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" @@ -292,10 +295,10 @@ android:drawablePadding="12dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toEndOf="@id/minus_button_item_post_detail_image_and_gif_autoplay" /> + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_detail_image" /> <ImageView - android:id="@+id/save_button_item_post_detail_image_and_gif_autoplay" + android:id="@+id/save_button_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" @@ -306,11 +309,11 @@ app:layout_constraintHorizontal_bias="1" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toEndOf="@id/comments_count_item_post_detail_image_and_gif_autoplay" - app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_image_and_gif_autoplay" /> + app:layout_constraintStart_toEndOf="@id/comments_count_item_post_detail_image" + app:layout_constraintEnd_toStartOf="@id/share_button_item_post_detail_image" /> <ImageView - android:id="@+id/share_button_item_post_detail_image_and_gif_autoplay" + android:id="@+id/share_button_item_post_detail_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" diff --git a/app/src/main/res/layout/item_post_detail_link.xml b/app/src/main/res/layout/item_post_detail_link.xml index c9e7bd2c..ba51e6a5 100644 --- a/app/src/main/res/layout/item_post_detail_link.xml +++ b/app/src/main/res/layout/item_post_detail_link.xml @@ -210,12 +210,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - <com.santalu.aspectratioimageview.AspectRatioImageView + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioSubsamplingScaleImageView android:id="@+id/image_view_item_post_detail_link" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" - android:scaleType="fitStart"/> + android:scaleType="fitStart" + app:zoomEnabled="false" + app:panEnabled="false" /> <RelativeLayout android:id="@+id/load_wrapper_item_post_detail_link" diff --git a/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml b/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml index c4b36198..a25c25a2 100644 --- a/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml +++ b/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml @@ -202,12 +202,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - <com.santalu.aspectratioimageview.AspectRatioImageView + <ml.docilealligator.infinityforreddit.CustomView.AspectRatioSubsamplingScaleImageView android:id="@+id/image_view_item_post_detail_video_and_gif_preview" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" - android:scaleType="fitStart"/> + android:scaleType="fitStart" + app:zoomEnabled="false" + app:panEnabled="false" /> <ImageView android:layout_width="wrap_content" 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 9d8e8590..3a41f4d3 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 @@ -208,12 +208,14 @@ android:layout_height="match_parent" app:controller_layout_id="@layout/exo_autoplay_playback_control_view"/> - <pl.droidsonroids.gif.GifImageView + <com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView android:id="@+id/preview_image_view_item_post_detail_video_autoplay" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitStart" - android:visibility="gone" /> + android:visibility="gone" + app:zoomEnabled="false" + app:panEnabled="false" /> </com.google.android.exoplayer2.ui.AspectRatioFrameLayout> |