mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Include Subsampling Scale Image View as library to allow preloading tiles when a max bitmap size is provided.
This commit is contained in:
		| @@ -34,6 +34,7 @@ import eu.kanade.mangafeed.ui.reader.viewer.horizontal.LeftToRightReader; | ||||
| import eu.kanade.mangafeed.ui.reader.viewer.horizontal.RightToLeftReader; | ||||
| import eu.kanade.mangafeed.ui.reader.viewer.vertical.VerticalReader; | ||||
| import eu.kanade.mangafeed.ui.reader.viewer.webtoon.WebtoonReader; | ||||
| import eu.kanade.mangafeed.util.GLUtil; | ||||
| import eu.kanade.mangafeed.util.ToastUtil; | ||||
| import icepick.Icepick; | ||||
| import nucleus.factory.RequiresPresenter; | ||||
| @@ -57,6 +58,8 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> { | ||||
|     protected CompositeSubscription subscriptions; | ||||
|     private Subscription customBrightnessSubscription; | ||||
|  | ||||
|     private int maxBitmapSize; | ||||
|  | ||||
|     public static final int LEFT_TO_RIGHT = 1; | ||||
|     public static final int RIGHT_TO_LEFT = 2; | ||||
|     public static final int VERTICAL = 3; | ||||
| @@ -88,6 +91,8 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> { | ||||
|             setBlackTheme(); | ||||
|  | ||||
|         initializeSettings(); | ||||
|  | ||||
|         maxBitmapSize = GLUtil.getMaxTextureSize(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -282,4 +287,8 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> { | ||||
|         return viewer; | ||||
|     } | ||||
|  | ||||
|     public int getMaxBitmapSize() { | ||||
|         return maxBitmapSize; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -59,6 +59,8 @@ public class ViewPagerReaderFragment extends BaseFragment { | ||||
|              progressText.setTextColor(ContextCompat.getColor(getContext(), R.color.light_grey)); | ||||
|         } | ||||
|  | ||||
|         imageView.setParallelLoadingEnabled(true); | ||||
|         imageView.setMaxDimensions(activity.getMaxBitmapSize(), activity.getMaxBitmapSize()); | ||||
|         imageView.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED); | ||||
|         imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE); | ||||
|         imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE); | ||||
| @@ -103,7 +105,7 @@ public class ViewPagerReaderFragment extends BaseFragment { | ||||
|         if (page == null || page.getImagePath() == null) | ||||
|             return; | ||||
|  | ||||
|         imageView.setImage(ImageSource.uri(page.getImagePath()).tilingDisabled()); | ||||
|         imageView.setImage(ImageSource.uri(page.getImagePath())); | ||||
|         progressContainer.setVisibility(View.GONE); | ||||
|     } | ||||
|  | ||||
|   | ||||
							
								
								
									
										50
									
								
								app/src/main/java/eu/kanade/mangafeed/util/GLUtil.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								app/src/main/java/eu/kanade/mangafeed/util/GLUtil.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| package eu.kanade.mangafeed.util; | ||||
|  | ||||
| import javax.microedition.khronos.egl.EGL10; | ||||
| import javax.microedition.khronos.egl.EGLConfig; | ||||
| import javax.microedition.khronos.egl.EGLContext; | ||||
| import javax.microedition.khronos.egl.EGLDisplay; | ||||
|  | ||||
| public class GLUtil { | ||||
|  | ||||
|     public static int getMaxTextureSize() { | ||||
|         // Safe minimum default size | ||||
|         final int IMAGE_MAX_BITMAP_DIMENSION = 2048; | ||||
|  | ||||
|         // Get EGL Display | ||||
|         EGL10 egl = (EGL10) EGLContext.getEGL(); | ||||
|         EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); | ||||
|  | ||||
|         // Initialise | ||||
|         int[] version = new int[2]; | ||||
|         egl.eglInitialize(display, version); | ||||
|  | ||||
|         // Query total number of configurations | ||||
|         int[] totalConfigurations = new int[1]; | ||||
|         egl.eglGetConfigs(display, null, 0, totalConfigurations); | ||||
|  | ||||
|         // Query actual list configurations | ||||
|         EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; | ||||
|         egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); | ||||
|  | ||||
|         int[] textureSize = new int[1]; | ||||
|         int maximumTextureSize = 0; | ||||
|  | ||||
|         // Iterate through all the configurations to located the maximum texture size | ||||
|         for (int i = 0; i < totalConfigurations[0]; i++) { | ||||
|             // Only need to check for width since opengl textures are always squared | ||||
|             egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); | ||||
|  | ||||
|             // Keep track of the maximum texture size | ||||
|             if (maximumTextureSize < textureSize[0]) | ||||
|                 maximumTextureSize = textureSize[0]; | ||||
|         } | ||||
|  | ||||
|         // Release | ||||
|         egl.eglTerminate(display); | ||||
|  | ||||
|         // Return largest texture size found, or default | ||||
|         return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user