Create MovableTextTexture when GalleryView attached
This commit is contained in:
1 parent
43b8a57849
commit
ba51bd823e
2 files changed
+12
-16
No files matched your search
@@ -18,6 +18,7 @@ package com.hippo.ehviewer.gallery.gl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.MotionEvent;
|
||||
@@ -100,7 +101,7 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
private static final int METHOD_SET_LAYOUT_MODE = 13;
|
||||
|
||||
private final Context mContext;
|
||||
private final MovableTextTexture mPageTextTexture;
|
||||
private MovableTextTexture mPageTextTexture;
|
||||
private final GestureRecognizer mGestureRecognizer;
|
||||
private Adapter mAdapter;
|
||||
|
||||
@@ -150,10 +151,9 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
private final List<Object[]> mArgsListTemp = new ArrayList<>(5);
|
||||
|
||||
public GalleryView(@NonNull Context context, @NonNull Adapter adapter,
|
||||
MovableTextTexture pageTextTexture, ActionListener listener, @LayoutMode int layoutMode) {
|
||||
ActionListener listener, @LayoutMode int layoutMode) {
|
||||
mContext = context;
|
||||
mAdapter = adapter;
|
||||
mPageTextTexture = pageTextTexture;
|
||||
mListener = listener;
|
||||
mEdgeView = new GLEdgeView(context);
|
||||
mGestureRecognizer = new GestureRecognizer(context, this);
|
||||
@@ -190,6 +190,11 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
super.onAttachToRoot(root);
|
||||
mEdgeView.onAttachToRoot(root);
|
||||
|
||||
mPageTextTexture = MovableTextTexture.create(Typeface.DEFAULT,
|
||||
mContext.getResources().getDimensionPixelSize(R.dimen.gallery_page_text),
|
||||
mContext.getResources().getColor(R.color.secondary_text_dark),
|
||||
new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'});
|
||||
|
||||
switch (mLayoutMode) {
|
||||
case LAYOUT_MODE_LEFT_TO_RIGHT:
|
||||
ensurePagerLayoutManager();
|
||||
@@ -223,6 +228,9 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
|
||||
mAdapter = mLayoutManager.onDetach();
|
||||
mLayoutManager = null;
|
||||
|
||||
mPageTextTexture.recycle();
|
||||
mPageTextTexture = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -37,7 +36,6 @@ import com.hippo.ehviewer.gallery.ZipGalleryProvider;
|
||||
import com.hippo.ehviewer.gallery.gl.GalleryPageView;
|
||||
import com.hippo.ehviewer.gallery.gl.GalleryView;
|
||||
import com.hippo.gl.glrenderer.ImageTexture;
|
||||
import com.hippo.gl.glrenderer.MovableTextTexture;
|
||||
import com.hippo.gl.view.GLRootView;
|
||||
import com.hippo.image.Image;
|
||||
import com.hippo.util.SystemUiHelper;
|
||||
@@ -64,8 +62,6 @@ public class GalleryActivity extends AppCompatActivity
|
||||
@Nullable
|
||||
private GalleryView mGalleryView;
|
||||
|
||||
@Nullable
|
||||
private MovableTextTexture mPageTextTexture;
|
||||
@Nullable
|
||||
private ImageTexture.Uploader mUploader;
|
||||
@Nullable
|
||||
@@ -155,13 +151,9 @@ public class GalleryActivity extends AppCompatActivity
|
||||
GLRootView glRootView = (GLRootView) findViewById(R.id.gl_root_view);
|
||||
mGalleryProvider.setGLRoot(glRootView);
|
||||
mUploader = new ImageTexture.Uploader(glRootView);
|
||||
mPageTextTexture = MovableTextTexture.create(Typeface.DEFAULT,
|
||||
getResources().getDimensionPixelSize(R.dimen.gallery_page_text),
|
||||
getResources().getColor(R.color.secondary_text_dark),
|
||||
new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'});
|
||||
|
||||
mGalleryView = new GalleryView(this, new GalleryAdapter(),
|
||||
mPageTextTexture, null, GalleryView.LAYOUT_MODE_TOP_TO_BOTTOM);
|
||||
null, GalleryView.LAYOUT_MODE_TOP_TO_BOTTOM);
|
||||
glRootView.setContentPane(mGalleryView);
|
||||
|
||||
// System UI helper
|
||||
@@ -192,10 +184,6 @@ public class GalleryActivity extends AppCompatActivity
|
||||
mUploader.clear();
|
||||
mUploader = null;
|
||||
}
|
||||
if (mPageTextTexture != null) {
|
||||
mPageTextTexture.recycle();
|
||||
mPageTextTexture = null;
|
||||
}
|
||||
if (mGalleryProvider != null) {
|
||||
mGalleryProvider.setGalleryProviderListener(null);
|
||||
mGalleryProvider.stop();
|
||||
|
||||
Reference in new issue
Block a user