diff options
author | Andrew Dolgov <[email protected]> | 2012-12-02 23:56:43 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-12-02 23:56:43 +0400 |
commit | 8d7a0fc4d2705ccfe81d650245dc221ec981db49 (patch) | |
tree | ebe2cfe80eed5d374b74c0737174d28914f96a9e /src | |
parent | e3f27576084274edd0c8adca740d2abff63ce5a5 (diff) |
Revert "runtime thumbnails"
This reverts commit df1b02237bfb79b51a29392ca4b3d2cd094dcacb.
Conflicts:
src/org/fox/ttcomics/ComicFragment.java
src/org/fox/ttcomics/ComicPager.java
Diffstat (limited to 'src')
-rw-r--r-- | src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java | 4 | ||||
-rw-r--r-- | src/org/fox/ttcomics/ComicFragment.java | 135 | ||||
-rw-r--r-- | src/org/fox/ttcomics/ComicPager.java | 34 |
3 files changed, 52 insertions, 121 deletions
diff --git a/src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java b/src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java index 51dce5b..a0e1a3b 100644 --- a/src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java +++ b/src/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java @@ -290,8 +290,8 @@ public class ImageViewTouchBase extends ImageView implements IDisposable { float w = bitmap.getIntrinsicWidth(); float h = bitmap.getIntrinsicHeight(); matrix.reset(); - float widthScale = viewWidth / w; //Math.min( viewWidth / w, MAX_ZOOM ); - float heightScale = viewHeight / h; //Math.min( viewHeight / h, MAX_ZOOM ); + float widthScale = Math.min( viewWidth / w, MAX_ZOOM ); + 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 ); diff --git a/src/org/fox/ttcomics/ComicFragment.java b/src/org/fox/ttcomics/ComicFragment.java index 4787297..09c9659 100644 --- a/src/org/fox/ttcomics/ComicFragment.java +++ b/src/org/fox/ttcomics/ComicFragment.java @@ -27,8 +27,6 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT private int m_page;
private CommonActivity m_activity;
private GestureDetector m_detector;
- private ComicArchive m_archive;
- private boolean m_thumbnail = true;
public ComicFragment() {
super();
@@ -38,41 +36,8 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT super();
m_page = page;
}
-
- public void setThumbnail(final boolean thumbnail) {
- if (isAdded() && getView() != null && 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, thumbnail);
- }
-
- @Override
- protected void onPostExecute(Bitmap result) {
- CommonActivity activity = (CommonActivity) getActivity();
-
- if (activity != null && isAdded() && getView() != null) {
- ImageViewTouch image = (ImageViewTouch) getView().findViewById(R.id.comic_image);
-
- if (result != null) {
- image.setImageBitmap(result);
- } else {
- activity.toast(R.string.error_loading_image);
- image.setImageResource(R.drawable.badimage);
- }
- }
- }
- };
-
- loadTask.execute(m_archive);
-
- }
-
- m_thumbnail = thumbnail;
- }
- private Bitmap loadImage(ComicArchive archive, int page, boolean thumbnail) {
+ public Bitmap loadImage(ComicArchive archive, int page) {
CommonActivity activity = (CommonActivity) getActivity();
try {
@@ -80,14 +45,10 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(archive.getItem(page), null, options);
- if (thumbnail) {
- options.inSampleSize = CommonActivity.calculateInSampleSize(options, 256, 256);
- } else {
- if (CommonActivity.isCompatMode()) {
- options.inSampleSize = CommonActivity.calculateInSampleSize(options, 512, 512);
- } else {
- options.inSampleSize = CommonActivity.calculateInSampleSize(options, 1024, 1024);
- }
+ if (CommonActivity.isCompatMode()) {
+ options.inSampleSize = CommonActivity.calculateInSampleSize(options, 512, 512);
+ } else {
+ options.inSampleSize = CommonActivity.calculateInSampleSize(options, 1024, 1024);
}
options.inJustDecodeBounds = false;
@@ -116,54 +77,53 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT m_page = savedInstanceState.getInt("page");
}
- if (CommonActivity.isCompatMode() && m_prefs.getBoolean("use_dark_theme", false)) {
- image.setBackgroundColor(0xff000000);
- }
-
- image.setFitToScreen(true);
-
ComicPager pager = (ComicPager) getActivity().getSupportFragmentManager().findFragmentByTag(CommonActivity.FRAG_COMICS_PAGER);
- if (pager != null) {
- m_thumbnail = pager.getPosition() != m_page;
- }
-
- AsyncTask<ComicArchive, Void, Bitmap> loadTask = new AsyncTask<ComicArchive, Void, Bitmap>() {
- @Override
- protected Bitmap doInBackground(ComicArchive... params) {
- return loadImage(params[0], m_page, m_thumbnail);
+ if (pager != null) {
+ if (CommonActivity.isCompatMode() && m_prefs.getBoolean("use_dark_theme", false)) {
+ image.setBackgroundColor(0xff000000);
}
- @Override
- protected void onPostExecute(Bitmap result) {
- CommonActivity activity = (CommonActivity) getActivity();
+ image.setFitToScreen(true);
+
+ 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()) {
- if (result != null) {
- image.setImageBitmap(result);
- } else {
- activity.toast(R.string.error_loading_image);
- image.setImageResource(R.drawable.badimage);
- }
- }
- }
- };
-
- loadTask.execute(m_archive);
-
- image.setOnScaleChangedListener(new ImageViewTouch.OnScaleChangedListener() {
- @Override
- public void onScaleChanged(float scale) {
- // TODO: shared scale change?
- }
- });
+ @Override
+ protected void onPostExecute(Bitmap result) {
+ CommonActivity activity = (CommonActivity) getActivity();
+
+ if (activity != null && isAdded()) {
+ if (result != null) {
+ image.setImageBitmap(result);
+ } else {
+ activity.toast(R.string.error_loading_image);
+ image.setImageResource(R.drawable.badimage);
+ }
+ }
+ }
+ };
+
+ loadTask.execute(pager.getArchive());
+
+ image.setOnScaleChangedListener(new ImageViewTouch.OnScaleChangedListener() {
+ @Override
+ public void onScaleChanged(float scale) {
+ // TODO: shared scale change?
+ }
+ });
- image.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View view, MotionEvent event) {
- return m_detector.onTouchEvent(event);
- }
- });
+ image.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View view, MotionEvent event) {
+ return m_detector.onTouchEvent(event);
+ }
+ });
+
+ }
TextView page = (TextView) view.findViewById(R.id.comic_page);
@@ -216,9 +176,6 @@ public class ComicFragment extends Fragment implements GestureDetector.OnDoubleT m_prefs = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext());
m_activity = (CommonActivity) activity;
- ComicPager pager = (ComicPager) getActivity().getSupportFragmentManager().findFragmentByTag(CommonActivity.FRAG_COMICS_PAGER);
- m_archive = pager.getArchive();
-
m_detector = new GestureDetector(m_activity, new GestureDetector.OnGestureListener() {
@Override
diff --git a/src/org/fox/ttcomics/ComicPager.java b/src/org/fox/ttcomics/ComicPager.java index cb10591..87199db 100644 --- a/src/org/fox/ttcomics/ComicPager.java +++ b/src/org/fox/ttcomics/ComicPager.java @@ -1,7 +1,6 @@ package org.fox.ttcomics;
import java.io.IOException;
-import java.util.HashMap;
import com.github.junrar.exception.RarException;
@@ -26,33 +25,19 @@ public class ComicPager extends Fragment { private CommonActivity m_activity;
private class PagerAdapter extends FragmentStatePagerAdapter {
- HashMap<Integer, ComicFragment> m_fragments = new HashMap<Integer, ComicFragment>();
-
public PagerAdapter(FragmentManager fm) {
super(fm);
}
-
+
@Override
public Fragment getItem(int position) {
- ComicFragment cf = new ComicFragment(position);
- m_fragments.put(position, cf);
- return cf;
+ return new ComicFragment(position);
}
-
+
@Override
public int getCount() {
return m_archive.getCount();
}
-
- @Override
- public void destroyItem(View container, int position, Object object) {
- super.destroyItem(container, position, object);
- m_fragments.remove(position);
- }
-
- public ComicFragment getFragmentAt(int position) {
- return m_fragments.get(position);
- }
}
private PagerAdapter m_adapter;
@@ -139,26 +124,15 @@ public class ComicPager extends Fragment { }
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- private ComicFragment m_current;
public void onPageSelected(int position) {
+
m_activity.onComicSelected(m_fileName, position);
m_activity.setProgress(Math.round(((float)position / (float)(m_archive.getCount()-1)) * 10000));
if (!CommonActivity.isCompatMode() && m_prefs.getBoolean("dim_status_bar", false)) {
view.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
}
-
- ComicFragment cf = m_adapter.getFragmentAt(position);
-
- if (cf != null) {
- if (m_current != null) {
- m_current.setThumbnail(true);
- }
-
- cf.setThumbnail(false);
- m_current = cf;
- }
}
public void onPageScrolled(int arg0, float arg1, int arg2) {
|