mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
Avoid OutOfMemory crashes on webtoon viewer increasing view holders height
This commit is contained in:
parent
ea4fa60e01
commit
f19889c222
@ -30,7 +30,7 @@ public class WebtoonHolder extends RecyclerView.ViewHolder {
|
||||
super(view);
|
||||
this.adapter = adapter;
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
|
||||
int maxDim = ((ReaderActivity)adapter.getReader().getActivity()).getMaxBitmapSize();
|
||||
|
||||
imageView.setParallelLoadingEnabled(true);
|
||||
@ -40,8 +40,17 @@ public class WebtoonHolder extends RecyclerView.ViewHolder {
|
||||
imageView.setMaxScale(10);
|
||||
imageView.setOnTouchListener(touchListener);
|
||||
imageView.setMaxDimensions(maxDim, maxDim);
|
||||
imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
||||
@Override
|
||||
public void onImageLoaded() {
|
||||
// When the image is loaded, reset the minimum height to avoid gaps
|
||||
container.setMinimumHeight(0);
|
||||
}
|
||||
});
|
||||
|
||||
progressBar.setMinimumHeight(view.getResources().getDisplayMetrics().heightPixels);
|
||||
// Avoid to create a lot of view holders taking all the screen height,
|
||||
// saving memory and a possible OOM
|
||||
container.setMinimumHeight(view.getResources().getDisplayMetrics().heightPixels);
|
||||
|
||||
container.setOnTouchListener(touchListener);
|
||||
retryButton.setOnTouchListener((v, event) -> {
|
||||
|
@ -35,7 +35,7 @@ public class WebtoonReader extends BaseReader {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
||||
adapter = new WebtoonAdapter(this);
|
||||
layoutManager = new PreCachingLayoutManager(getActivity());
|
||||
layoutManager.setExtraLayoutSpace(getResources().getDisplayMetrics().heightPixels);
|
||||
layoutManager.setExtraLayoutSpace(getResources().getDisplayMetrics().heightPixels / 2);
|
||||
|
||||
recycler = new RecyclerView(getActivity());
|
||||
recycler.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/frame_container">
|
||||
|
||||
<ProgressBar
|
||||
|
Loading…
Reference in New Issue
Block a user