mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Use BigImageView in ViewRedditGalleryImageOrGifFragment. Fix subtitle not showing in FilteredThingActivity when browsing Reddit gallery posts.
This commit is contained in:
parent
bae154da45
commit
fd175178a2
@ -280,6 +280,9 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
|||||||
break;
|
break;
|
||||||
case Post.GIF_TYPE:
|
case Post.GIF_TYPE:
|
||||||
toolbar.setSubtitle(R.string.gif);
|
toolbar.setSubtitle(R.string.gif);
|
||||||
|
break;
|
||||||
|
case Post.GALLERY_TYPE:
|
||||||
|
toolbar.setSubtitle(R.string.gallery);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initializeFragment) {
|
if (initializeFragment) {
|
||||||
|
@ -107,6 +107,12 @@ public class ViewImgurImageFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
errorLinearLayout.setOnClickListener(view -> {
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
errorLinearLayout.setVisibility(View.GONE);
|
||||||
|
loadImage();
|
||||||
|
});
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,8 +35,12 @@ import com.bumptech.glide.request.RequestListener;
|
|||||||
import com.bumptech.glide.request.target.CustomTarget;
|
import com.bumptech.glide.request.target.CustomTarget;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.bumptech.glide.request.transition.Transition;
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
import com.davemorrissey.labs.subscaleview.ImageSource;
|
|
||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
|
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;
|
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)
|
@BindView(R.id.progress_bar_view_reddit_gallery_image_or_gif_fragment)
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
@BindView(R.id.image_view_view_reddit_gallery_image_or_gif_fragment)
|
@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)
|
@BindView(R.id.load_image_error_linear_layout_view_reddit_gallery_image_or_gif_fragment)
|
||||||
LinearLayout errorLinearLayout;
|
LinearLayout errorLinearLayout;
|
||||||
|
|
||||||
@ -79,6 +83,8 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
BigImageViewer.initialize(GlideImageLoader.with(activity));
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_view_reddit_gallery_image_or_gif, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_view_reddit_gallery_image_or_gif, container, false);
|
||||||
|
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
@ -88,6 +94,87 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
|||||||
media = getArguments().getParcelable(EXTRA_REDDIT_GALLERY_MEDIA);
|
media = getArguments().getParcelable(EXTRA_REDDIT_GALLERY_MEDIA);
|
||||||
glide = Glide.with(activity);
|
glide = Glide.with(activity);
|
||||||
mediaDownloader = new MediaDownloaderImpl();
|
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();
|
loadImage();
|
||||||
|
|
||||||
imageView.setOnClickListener(view -> {
|
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;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadImage() {
|
private void loadImage() {
|
||||||
glide.asBitmap().load(media.url).listener(new RequestListener<Bitmap>() {
|
imageView.showImage(Uri.parse(media.url));
|
||||||
@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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true" />
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
<com.github.piasy.biv.view.BigImageView
|
||||||
android:id="@+id/image_view_view_reddit_gallery_image_or_gif_fragment"
|
android:id="@+id/image_view_view_reddit_gallery_image_or_gif_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:quickScaleEnabled="false" />
|
app:optimizeDisplay="true"
|
||||||
|
app:tapToRetry="false" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/load_image_error_linear_layout_view_reddit_gallery_image_or_gif_fragment"
|
android:id="@+id/load_image_error_linear_layout_view_reddit_gallery_image_or_gif_fragment"
|
||||||
|
Loading…
Reference in New Issue
Block a user