diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-07-16 14:58:11 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-07-16 14:58:11 +0000 |
commit | fd175178a2219df4369f68bcfc92e10d80468b64 (patch) | |
tree | 08c67a4c2ec5683269e267ea4e32e04653dac35f /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | bae154da4520571ec116815648ad3dbc942bdb2d (diff) | |
download | infinity-for-reddit-fd175178a2219df4369f68bcfc92e10d80468b64.tar infinity-for-reddit-fd175178a2219df4369f68bcfc92e10d80468b64.tar.gz infinity-for-reddit-fd175178a2219df4369f68bcfc92e10d80468b64.tar.bz2 infinity-for-reddit-fd175178a2219df4369f68bcfc92e10d80468b64.tar.lz infinity-for-reddit-fd175178a2219df4369f68bcfc92e10d80468b64.tar.xz infinity-for-reddit-fd175178a2219df4369f68bcfc92e10d80468b64.tar.zst infinity-for-reddit-fd175178a2219df4369f68bcfc92e10d80468b64.zip |
Use BigImageView in ViewRedditGalleryImageOrGifFragment. Fix subtitle not showing in FilteredThingActivity when browsing Reddit gallery posts.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
3 files changed, 105 insertions, 26 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java index 87d4e0f2..a0b8bd47 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java @@ -280,6 +280,9 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec break; case Post.GIF_TYPE: toolbar.setSubtitle(R.string.gif); + break; + case Post.GALLERY_TYPE: + toolbar.setSubtitle(R.string.gallery); } if (initializeFragment) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java index d6651066..d25408aa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java @@ -107,6 +107,12 @@ public class ViewImgurImageFragment extends Fragment { } }); + errorLinearLayout.setOnClickListener(view -> { + progressBar.setVisibility(View.VISIBLE); + errorLinearLayout.setVisibility(View.GONE); + loadImage(); + }); + return rootView; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewRedditGalleryImageOrGifFragment.java index 2d456910..0b466749 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewRedditGalleryImageOrGifFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewRedditGalleryImageOrGifFragment.java @@ -35,8 +35,12 @@ 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.davemorrissey.labs.subscaleview.ImageSource; import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; +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 java.io.File; @@ -61,7 +65,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { @BindView(R.id.progress_bar_view_reddit_gallery_image_or_gif_fragment) ProgressBar progressBar; @BindView(R.id.image_view_view_reddit_gallery_image_or_gif_fragment) - SubsamplingScaleImageView imageView; + BigImageView imageView; @BindView(R.id.load_image_error_linear_layout_view_reddit_gallery_image_or_gif_fragment) LinearLayout errorLinearLayout; @@ -79,6 +83,8 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + BigImageViewer.initialize(GlideImageLoader.with(activity)); + View rootView = inflater.inflate(R.layout.fragment_view_reddit_gallery_image_or_gif, container, false); ButterKnife.bind(this, rootView); @@ -88,6 +94,87 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { media = getArguments().getParcelable(EXTRA_REDDIT_GALLERY_MEDIA); glide = Glide.with(activity); mediaDownloader = new MediaDownloaderImpl(); + + imageView.setImageViewFactory(new GlideImageViewFactory()); + + imageView.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) { + progressBar.setVisibility(View.GONE); + + final SubsamplingScaleImageView view = imageView.getSSIV(); + + if (view != null) { + view.setMinimumDpi(80); + + view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() { + @Override + public void onReady() { + + } + + @Override + public void onImageLoaded() { + view.setDoubleTapZoomDpi(70); + view.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED); + view.setQuickScaleEnabled(false); + } + + @Override + public void onPreviewLoadError(Exception e) { + + } + + @Override + public void onImageLoadError(Exception e) { + + } + + @Override + public void onTileLoadError(Exception e) { + + } + + @Override + public void onPreviewReleased() { + + } + }); + } + } + + @Override + public void onFail(Exception error) { + progressBar.setVisibility(View.GONE); + errorLinearLayout.setVisibility(View.VISIBLE); + } + }); + loadImage(); imageView.setOnClickListener(view -> { @@ -109,34 +196,17 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { } }); + errorLinearLayout.setOnClickListener(view -> { + progressBar.setVisibility(View.VISIBLE); + errorLinearLayout.setVisibility(View.GONE); + loadImage(); + }); + return rootView; } private void loadImage() { - glide.asBitmap().load(media.url).listener(new RequestListener<Bitmap>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { - progressBar.setVisibility(View.GONE); - errorLinearLayout.setVisibility(View.VISIBLE); - return false; - } - - @Override - public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { - progressBar.setVisibility(View.GONE); - return false; - } - }).into(new CustomTarget<Bitmap>() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { - imageView.setImage(ImageSource.bitmap(resource)); - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); + imageView.showImage(Uri.parse(media.url)); } @Override |