mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Avoid OutOfMemory crashes on webtoon viewer increasing view holders height
This commit is contained in:
		| @@ -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)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user