Skip to content

Commit

Permalink
#10: Faster image detail swiping => faster initial image detail view …
Browse files Browse the repository at this point in the history
…loading: initially the view is loaded with low res image. on first zoom it is reloaded with maximum resolution
  • Loading branch information
k3b committed Sep 13, 2015
1 parent 29a74f3 commit 9829b0a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 23 deletions.
3 changes: 1 addition & 2 deletions ToDo.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
TODO

#10 Fast swiping through images does not work
load preview images.on zoom start load original image
if image exists but is not in media database restart media scanner for containing folder

#6 geo-picker
extera_stream-uri(s) => blue: selected items via geo:, content: or file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class ImagePagerAdapterFromCursor extends PagerAdapter implements Querya
// workaround because setEllipsize(TextUtils.TruncateAt.MIDDLE) is not possible for title
private final int mMaxTitleLength;

private QueryParameterParcelable parameters; // defining sql to get data
private QueryParameterParcelable mParameters; // defining sql to get data
private Cursor mCursor = null; // the content of the page
private boolean mDataValid = true;

Expand All @@ -88,7 +88,7 @@ public ImagePagerAdapterFromCursor(final Activity context, QueryParameterParcela
*/
@Override
public void requery(final Activity context, QueryParameterParcelable parameters) {
this.parameters = parameters;
this.mParameters = parameters;
if (Global.debugEnabledSql) {
Log.i(Global.LOG_CONTEXT, debugPrefix + "requery " + ((parameters != null) ? parameters.toSqlString() : null));
}
Expand Down Expand Up @@ -342,22 +342,9 @@ public int getCursorFromPath(String path) {
return -1;
}

private boolean mHasLowMemory = false;
private void setImage(int position, long imageID, Uri uri, PhotoView photoView) {
if (!mHasLowMemory) {
try {
photoView.setImageURI(uri);
return;
} catch (OutOfMemoryError e) {
String message = photoView.getContext().getString(R.string.err_low_memory);
Log.e(Global.LOG_CONTEXT, debugPrefix + "instantiateItem(#" + position + ") => " + message);
Toast.makeText(photoView.getContext(), message, Toast.LENGTH_LONG).show();
mHasLowMemory = true;
// show only once
}
}

// mHasLowMemory
/** k3b 20150913 #10: Faster initial loading: initially the view is loaded with low res image. on first zoom it is reloaded with this uri */
photoView.setImageReloadURI(uri);
Bitmap thumbnail = MediaStore.Images.Thumbnails.getThumbnail(
photoView.getContext().getContentResolver(),
imageID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,9 @@ protected void onAttachedToWindow() {
init();
super.onAttachedToWindow();
}

/** k3b 20150913 #10: Faster initial loading: initially the view is loaded with low res image. on first zoom it is reloaded with this uri */
public void setImageReloadURI(Uri uri) {
mAttacher.setImageReloadURI(uri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.graphics.Matrix.ScaleToFit;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
Expand Down Expand Up @@ -53,7 +54,7 @@ public class PhotoViewAttacher implements IPhotoView, View.OnTouchListener,

// let debug flag be dynamic, but still Proguard can be used to remove from
// release builds
private static final boolean DEBUG = Log.isLoggable(LOG_TAG, Log.DEBUG);
private static final boolean DEBUG = true; //!!! Log.isLoggable(LOG_TAG, Log.DEBUG);

static final Interpolator sInterpolator = new AccelerateDecelerateInterpolator();
int ZOOM_DURATION = DEFAULT_ZOOM_DURATION;
Expand All @@ -70,6 +71,9 @@ public class PhotoViewAttacher implements IPhotoView, View.OnTouchListener,
private boolean mAllowParentInterceptOnEdge = true;
private boolean mBlockParentIntercept = false;

/** k3b 20150913 #10: Faster initial loading: initially the view is loaded with low res image. on first zoom it is reloaded with this uri */
private Uri mImageReloadURI = null;

private static void checkZoomLevels(float minZoom, float midZoom,
float maxZoom) {
if (minZoom >= midZoom) {
Expand Down Expand Up @@ -446,15 +450,38 @@ public void onGlobalLayout() {
}
}

/** invoked by the guesture detector */
@Override
public void onScale(float scaleFactor, float focusX, float focusY) {
//!!!
if (DEBUG) {
LogManager.getLogger().d(
LOG_TAG,
String.format("onScale: scale: %.2f. fX: %.2f. fY: %.2f",
scaleFactor, focusX, focusY));
}

/** k3b 20150913 #10: Faster initial loading: initially the view is loaded with low res image. on first zoom it is reloaded with this uri */
if (mImageReloadURI != null) {
ImageView imageView = getImageView();
if (imageView != null) {
if (DEBUG) {
LogManager.getLogger().d(
LOG_TAG,
"onScale: Reloading image from " + mImageReloadURI);
}
try {
imageView.setImageURI(mImageReloadURI);
} catch (OutOfMemoryError e) {
LogManager.getLogger().e(
LOG_TAG,
"onScale: Not enought memory to reloading image from " + mImageReloadURI + " failed: " + e.getMessage());
}

mImageReloadURI = null; // either success or error: do not try it again
}
}

if (getScale() < mMaxScale || scaleFactor < 1f) {
if (null != mScaleChangeListener) {
mScaleChangeListener.onScaleChange(scaleFactor, focusX, focusY);
Expand Down Expand Up @@ -937,6 +964,11 @@ private int getImageViewHeight(ImageView imageView) {
return imageView.getHeight() - imageView.getPaddingTop() - imageView.getPaddingBottom();
}

/** k3b 20150913 #10: Faster initial loading: initially the view is loaded with low res image. on first zoom it is reloaded with this uri */
public void setImageReloadURI(Uri imageReloadURI) {
this.mImageReloadURI = imageReloadURI;
}

/**
* Interface definition for a callback to be invoked when the internal Matrix has changed for
* this View.
Expand Down
9 changes: 6 additions & 3 deletions wiki/History.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [v0.4.2.*](https://github.com/k3b/AndroFotoFinder/issues?q=milestone%3Av0.4.2) (not released yet)

* [Image-View](https://github.com/k3b/AndroFotoFinder/wiki/Image-View) :
* [#10 Faster image detail swiping](https://github.com/k3b/AndroFotoFinder/issues/10)
* initially the view is loaded with low res image. on first zoom it is reloaded with maximum resolution.
* [Geografic-Map](https://github.com/k3b/AndroFotoFinder/wiki/geographic-map) :
* menu to open [Filter-View](https://github.com/k3b/AndroFotoFinder/wiki/Filter-View)
* purpose: Filter the photos that are visible in the map.
Expand All @@ -15,7 +18,7 @@
* [Image-View](https://github.com/k3b/AndroFotoFinder/wiki/Image-View) if xxx is an existing image file.
* else [Gallery-View](https://github.com/k3b/AndroFotoFinder/wiki/Gallery-View) where xxx is used as a path filter

## [v0.4.1.150911](https://github.com/k3b/AndroFotoFinder/issues?q=milestone%3Av0.4.1)
## [v0.4.1.150911](https://github.com/k3b/AndroFotoFinder/issues?q=milestone%3Av0.4.1) available in [F-Droid app store](https://f-droid.org) since 2015-09-12

* [Gallery-View](https://github.com/k3b/AndroFotoFinder/wiki/Gallery-View) :
* [Selection](Gallery-View#Multiselection): add/remove [all visible](Gallery-View#CurrentSet)
Expand All @@ -35,11 +38,11 @@
* New filter option : only photos with no geo infos.
* App can be installed on SD-Card

## [v0.4.0.150816](https://github.com/k3b/AndroFotoFinder/releases/tag/v0.4.0.150816)
## [v0.4.0.150816](https://github.com/k3b/AndroFotoFinder/releases/tag/v0.4.0.150816) available in [F-Droid app store](https://f-droid.org) since 2015-08-18

* [Gallery-View](https://github.com/k3b/AndroFotoFinder/wiki/Gallery-View) : Implemented [#1 Multi selection and share/send image](https://github.com/k3b/AndroFotoFinder/issues/1)
* [Gallery-View](https://github.com/k3b/AndroFotoFinder/wiki/Gallery-View) in multi selection mode : Implemented Delete/Copy/Move/CreateFolder/Write-Log

## [v0.3.4.150728](https://github.com/k3b/AndroFotoFinder/releases/tag/v0.3.4.150728)
## [v0.3.4.150728](https://github.com/k3b/AndroFotoFinder/releases/tag/v0.3.4.150728) available in [F-Droid app store](https://f-droid.org) since 2015-08-01

* Initial public release on FDroid

0 comments on commit 9829b0a

Please sign in to comment.