diff options
author | Andrew Dolgov <[email protected]> | 2012-12-03 13:55:53 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-12-03 13:55:53 +0300 |
commit | c1c4c9032a95c171bd66e4a10387705b787cc453 (patch) | |
tree | 88b11f007dd2e777a72262d594a760b553017eda /src | |
parent | 33945d243edd7d7e613297293d20f125fb9b6041 (diff) |
update thumbnail code and disable it for the time being
Diffstat (limited to 'src')
-rw-r--r-- | src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java | 17 | ||||
-rw-r--r-- | src/org/fox/ttcomics/ComicFragment.java | 69 |
2 files changed, 40 insertions, 46 deletions
diff --git a/src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java b/src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java index d497839..422b08e 100644 --- a/src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java +++ b/src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java @@ -101,8 +101,7 @@ public class ImageViewTouchBase extends ImageView implements IDisposable { getProperBaseMatrix( getDrawable(), mBaseMatrix ); setImageMatrix( getImageViewMatrix() ); - if (mFitToWidth && getScale() - 1f <= 0.01) - zoomToWidth(); + if (mFitToWidth) zoomToWidth(); } } @@ -201,8 +200,7 @@ public class ImageViewTouchBase extends ImageView implements IDisposable { getProperBaseMatrix( drawable, mBaseMatrix ); super.setImageDrawable( drawable ); - if (mFitToWidth && getScale() - 1f <= 0.01) - zoomToWidth(); + if (mFitToWidth) zoomToWidth(); } else { mBaseMatrix.reset(); @@ -309,7 +307,7 @@ public class ImageViewTouchBase extends ImageView implements IDisposable { float heightScale = Math.min( viewHeight / h, MAX_ZOOM ); float scale = Math.min( widthScale, heightScale ); matrix.postScale( scale, scale ); - matrix.postTranslate( ( viewWidth - w * scale ) / MAX_ZOOM, ( viewHeight - h * scale ) / MAX_ZOOM ); + matrix.postTranslate( ( viewWidth - w * scale ) / 2.0f, ( viewHeight - h * scale ) / 2.0f ); } protected float getValue( Matrix matrix, int whichValue ) { @@ -406,9 +404,7 @@ public class ImageViewTouchBase extends ImageView implements IDisposable { } protected void zoomTo( float scale, float centerX, float centerY ) { - // Log.i(LOG_TAG, "zoomTo"); - - //if ( scale > mMaxZoom ) scale = mMaxZoom; + if ( scale > mMaxZoom ) scale = mMaxZoom; float oldScale = getScale(); float deltaScale = scale / oldScale; postScale( deltaScale, centerX, centerY ); @@ -503,11 +499,10 @@ public class ImageViewTouchBase extends ImageView implements IDisposable { RectF bitmapRect = getBitmapRect(); float w = bitmapRect.right - bitmapRect.left; - - float scale = 1f; if (w < getWidth()) { - scale = (float)getWidth() / w; + float scale = (float)getWidth() / w; + zoomTo(scale, 0f, 0f); } } diff --git a/src/org/fox/ttcomics/ComicFragment.java b/src/org/fox/ttcomics/ComicFragment.java index e4b8bf4..6769626 100644 --- a/src/org/fox/ttcomics/ComicFragment.java +++ b/src/org/fox/ttcomics/ComicFragment.java @@ -28,44 +28,43 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT private int m_page;
private CommonActivity m_activity;
private GestureDetector m_detector;
- private boolean m_thumbnail = true;
+ private boolean m_thumbnail = false;
public ComicFragment() {
super();
}
- public void setThumbnail(boolean thumbnail) {
+ private void setThumbnail(boolean thumbnail) {
if (m_thumbnail != thumbnail) {
-
m_thumbnail = thumbnail;
-
- AsyncTask<ComicArchive, Void, Bitmap> loadTask = new AsyncTask<ComicArchive, Void, Bitmap>() {
- @Override
- protected Bitmap doInBackground(ComicArchive... params) {
- return loadImage(params[0], m_page);
- }
-
- @Override
- protected void onPostExecute(Bitmap result) {
- CommonActivity activity = (CommonActivity) getActivity();
-
- ImageViewTouch image = (ImageViewTouch) getView().findViewById(R.id.comic_image);
+
+ if (isAdded()) {
+ AsyncTask<ComicArchive, Void, Bitmap> loadTask = new AsyncTask<ComicArchive, Void, Bitmap>() {
+ @Override
+ protected Bitmap doInBackground(ComicArchive... params) {
+ return loadImage(params[0], m_page);
+ }
- if (activity != null && isAdded() && image != null) {
- if (result != null) {
- image.setImageBitmap(result);
- } else {
- activity.toast(R.string.error_loading_image);
- image.setImageResource(R.drawable.badimage);
- }
- }
- }
- };
-
- ComicPager pager = (ComicPager) getActivity().getSupportFragmentManager().findFragmentByTag(CommonActivity.FRAG_COMICS_PAGER);
-
- loadTask.execute(pager.getArchive());
-
+ @Override
+ protected void onPostExecute(Bitmap result) {
+ CommonActivity activity = (CommonActivity) getActivity();
+
+ ImageViewTouch image = (ImageViewTouch) getView().findViewById(R.id.comic_image);
+
+ if (activity != null && isAdded() && image != null) {
+ if (result != null) {
+ image.setImageBitmap(result);
+ } else {
+ activity.toast(R.string.error_loading_image);
+ image.setImageResource(R.drawable.badimage);
+ }
+ }
+ }
+ };
+
+ ComicPager pager = (ComicPager) getActivity().getSupportFragmentManager().findFragmentByTag(CommonActivity.FRAG_COMICS_PAGER);
+ loadTask.execute(pager.getArchive());
+ }
}
}
@@ -88,7 +87,7 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT int sampleSizes[];
if (m_thumbnail) {
- sampleSizes = new int[] { 256 };
+ sampleSizes = new int[] { 512, 256 };
} else {
sampleSizes = new int[] { 1024, 768, 512, 256 };
}
@@ -135,11 +134,11 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT if (CommonActivity.isCompatMode() && m_prefs.getBoolean("use_dark_theme", false)) {
image.setBackgroundColor(0xff000000);
}
-
+
+ image.setFitToScreen(true);
+
if (m_prefs.getBoolean("fit_to_width", false)) {
image.setFitToWidth(true);
- } else {
- image.setFitToScreen(true);
}
AsyncTask<ComicArchive, Void, Bitmap> loadTask = new AsyncTask<ComicArchive, Void, Bitmap>() {
@@ -229,7 +228,7 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
- setThumbnail(!isVisibleToUser);
+ //setThumbnail(!isVisibleToUser); disabled
}
@Override
|