mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 18:51:49 +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);
|
super(view);
|
||||||
this.adapter = adapter;
|
this.adapter = adapter;
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
|
|
||||||
int maxDim = ((ReaderActivity)adapter.getReader().getActivity()).getMaxBitmapSize();
|
int maxDim = ((ReaderActivity)adapter.getReader().getActivity()).getMaxBitmapSize();
|
||||||
|
|
||||||
imageView.setParallelLoadingEnabled(true);
|
imageView.setParallelLoadingEnabled(true);
|
||||||
@ -40,8 +40,17 @@ public class WebtoonHolder extends RecyclerView.ViewHolder {
|
|||||||
imageView.setMaxScale(10);
|
imageView.setMaxScale(10);
|
||||||
imageView.setOnTouchListener(touchListener);
|
imageView.setOnTouchListener(touchListener);
|
||||||
imageView.setMaxDimensions(maxDim, maxDim);
|
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);
|
container.setOnTouchListener(touchListener);
|
||||||
retryButton.setOnTouchListener((v, event) -> {
|
retryButton.setOnTouchListener((v, event) -> {
|
||||||
|
@ -35,7 +35,7 @@ public class WebtoonReader extends BaseReader {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
||||||
adapter = new WebtoonAdapter(this);
|
adapter = new WebtoonAdapter(this);
|
||||||
layoutManager = new PreCachingLayoutManager(getActivity());
|
layoutManager = new PreCachingLayoutManager(getActivity());
|
||||||
layoutManager.setExtraLayoutSpace(getResources().getDisplayMetrics().heightPixels);
|
layoutManager.setExtraLayoutSpace(getResources().getDisplayMetrics().heightPixels / 2);
|
||||||
|
|
||||||
recycler = new RecyclerView(getActivity());
|
recycler = new RecyclerView(getActivity());
|
||||||
recycler.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
recycler.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="300dp"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/frame_container">
|
android:id="@+id/frame_container">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
Loading…
Reference in New Issue
Block a user