diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImagePagerAdapterFromCursor.java b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImagePagerAdapterFromCursor.java index bfd5dd87..8a26b8c1 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImagePagerAdapterFromCursor.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImagePagerAdapterFromCursor.java @@ -39,7 +39,9 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoader; -import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer; +import com.nostra13.universalimageloader.core.assist.LoadedFrom; +import com.nostra13.universalimageloader.core.display.BitmapDisplayer; +import com.nostra13.universalimageloader.core.imageaware.ImageAware; import java.util.Date; @@ -298,92 +300,24 @@ public int getPositionFromPath(IFile file) { return result; } - @NonNull - protected View createViewWithContent( - int position, ViewGroup container, IFile imageFile, Uri imageUri, String debugContext, int size) { - final Context context = container.getContext(); - - final boolean useLayout = true; - - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - - PhotoViewEx photoView; - View root; - TextView contextTextView = null; - - if (useLayout) { - root = inflater.inflate(R.layout.pager_item_image, container, false); - - photoView = (PhotoViewEx) root.findViewById(R.id.image); - mImageButtonController.create((ImageButton) root.findViewById(R.id.cmd_any)); - contextTextView = (TextView) root.findViewById(R.id.text); - - } else { - photoView = new PhotoViewEx(context); - root = photoView; - } - - if (contextTextView != null) { - String contextText = DBUtils.getString(getCursorAt(position), CONTEXT_COLUMN_FIELD, null); - - if ((contextText != null) && (contextText.length() > 0)) { - contextTextView.setVisibility(View.VISIBLE); - contextTextView.setText(ImageContextController.sqlFormat(contextText)); - } else { - contextTextView.setVisibility(View.INVISIBLE); - } - } - - photoView.setMaximumScale(20); - photoView.setMediumScale(5); - - String loadType; - - if (imageFile != null) { - // if image is big use memoryefficient, fast, low-quality thumbnail (old code) - if (size > Global.imageDetailThumbnailIfBiggerThan) { - loadType = "image too big using thumb "; - setImageFromThumbnail(photoView, imageFile); - } else { - try { - // #53 Optimisation: no need for thumbnail - saves cache memory but may throw OutOfMemoryError - loadType = "image small enough "; - Bitmap bitmap = HugeImageLoader.loadImage(imageFile, MAX_IMAGE_DIMENSION, MAX_IMAGE_DIMENSION); - // rotation is done by photoView - photoView.setImageBitmap(bitmap); - photoView.setImageReloadFile((IFile) null); - photoView.setDebugPrefix(imageFile.getName()); - } catch (OutOfMemoryError err) { - loadType = "small image out of memory using thumb "; - setImageFromThumbnail(photoView, imageFile); - } - } - final int rotationInDegrees = PhotoPropertiesBulkUpdateService.getRotationFromExifOrientation(imageFile, null); - if (Global.debugEnabledViewItem) { - Log.i(Global.LOG_CONTEXT, mDebugPrefix + debugContext + position + ", rotation=" + - rotationInDegrees + ", " - + loadType + ") => " + imageFile + " => " + photoView); - } - photoView.setRotationTo(rotationInDegrees); - } else if (imageUri != null) { - if (Global.debugEnabledViewItem) { - Log.i(Global.LOG_CONTEXT, mDebugPrefix + debugContext + ") => " + imageUri + " => " + photoView); - } - photoView.setImageURI(imageUri); - } else if (Global.debugEnabledViewItem) { - Log.w(Global.LOG_CONTEXT, mDebugPrefix + debugContext + ") no ifile and no imageUri " + photoView); - } - - container.addView(root, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - return root; - } - private void setImageFromThumbnail(PhotoViewEx photoView, IFile imageFile) { /** 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.setImageReloadFile(imageFile); - ImageLoader.getInstance().displayImage(imageFile.getAsUriString(), photoView, mDisplayImageOptions); + String uri = imageFile.getAsUriString(); + ImageLoader.getInstance().displayImage(uri, photoView, mDisplayImageOptions); + } + + /** + * debug only to allow setting a breakpoint. Copy of original code + */ + private static class SimpleBitmapDisplayer implements BitmapDisplayer { + @Override + public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { + imageAware.setImageBitmap(bitmap); + } + } /** @@ -447,7 +381,7 @@ public boolean isInSingleImageMode() { private class ImageButtonControllerImpl { private MenuItem mMenuItem = null; - private View.OnClickListener mClickListener; + private final View.OnClickListener mClickListener; private final View.OnLongClickListener mLongClickListener; public ImageButtonControllerImpl() { diff --git a/app/src/main/java/de/k3b/android/io/AndroidFileCommands.java b/app/src/main/java/de/k3b/android/io/AndroidFileCommands.java index 2e27cc46..0be4d384 100644 --- a/app/src/main/java/de/k3b/android/io/AndroidFileCommands.java +++ b/app/src/main/java/de/k3b/android/io/AndroidFileCommands.java @@ -264,6 +264,7 @@ public void onMoveOrCopyDirectoryPick(boolean move, SelectedFiles selectedFiles, // public int moveOrCopyFilesTo(boolean move, SelectedFiles selectedFiles, File destDirFolder, IProgessListener progessListener) { moveOrCopyFilesTo(move, selectedFiles, destDirFolder, null); + PhotoChangeNotifyer.onNotifyPhotoChanged(); } } @@ -471,13 +472,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View result = super.onCreateView(inflater, container, savedInstanceState); - chkFullScan = (CheckBox) result.findViewById(R.id.chkFullScan); + chkFullScan = result.findViewById(R.id.chkFullScan); chkFullScan.setVisibility(View.VISIBLE); - chkRescanNeverScannedByAPM = (CheckBox) result.findViewById(R.id.chkRescanNeverScannedByAPM); + chkRescanNeverScannedByAPM = result.findViewById(R.id.chkRescanNeverScannedByAPM); chkRescanNeverScannedByAPM.setVisibility(View.VISIBLE); - chkScanForDeleted = (CheckBox) result.findViewById(R.id.chkScanForDeleted); + chkScanForDeleted = result.findViewById(R.id.chkScanForDeleted); chkScanForDeleted.setVisibility(View.VISIBLE); chkFullScan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { diff --git a/app/src/main/java/de/k3b/android/io/DocumentFileCache.java b/app/src/main/java/de/k3b/android/io/DocumentFileCache.java index 835fe0f1..bda67d4f 100644 --- a/app/src/main/java/de/k3b/android/io/DocumentFileCache.java +++ b/app/src/main/java/de/k3b/android/io/DocumentFileCache.java @@ -57,7 +57,8 @@ public DocumentFile findFile(DocumentFile parentDoc, File parentFile, String dis if (!parentFile.equals(currentFileCache.lastParentFile)) { currentFileCache.lastParentFile = parentFile; currentFileCache.lastChildDocFiles.clear(); - for (DocumentFile childDoc : parentDoc.listFiles()) { + DocumentFile[] childDocuments = parentDoc.listFiles(); + for (DocumentFile childDoc : childDocuments) { if (childDoc.isFile()) { String childDocName = childDoc.getName().toLowerCase(); if (PhotoPropertiesUtil.isImage(childDocName, PhotoPropertiesUtil.IMG_TYPE_ALL | PhotoPropertiesUtil.IMG_TYPE_XMP)) { diff --git a/app/src/main/java/de/k3b/android/util/PhotoChangeNotifyer.java b/app/src/main/java/de/k3b/android/util/PhotoChangeNotifyer.java index da422188..e896f360 100644 --- a/app/src/main/java/de/k3b/android/util/PhotoChangeNotifyer.java +++ b/app/src/main/java/de/k3b/android/util/PhotoChangeNotifyer.java @@ -36,6 +36,10 @@ public static void setPhotoChangedListener(PhotoChangedListener photoChangedList PhotoChangeNotifyer.photoChangedListener = photoChangedListener; } + public static void onNotifyPhotoChanged() { + if (photoChangedListener != null) photoChangedListener.onNotifyPhotoChanged(); + } + public static void notifyPhotoChanged(Context context, PhotoChangedListener adapter) { if (adapter != null) adapter.onNotifyPhotoChanged(); diff --git a/libK3bFilefacade/src/main/java/de/k3b/io/filefacade/FileFacade.java b/libK3bFilefacade/src/main/java/de/k3b/io/filefacade/FileFacade.java index b34858ba..de5e8773 100644 --- a/libK3bFilefacade/src/main/java/de/k3b/io/filefacade/FileFacade.java +++ b/libK3bFilefacade/src/main/java/de/k3b/io/filefacade/FileFacade.java @@ -315,7 +315,7 @@ public long length() { @Override public String toString() { - return String.format("%s: %i-%s", this.getClass().getSimpleName(), strategyID, file.getAbsoluteFile()); + return String.format("%s: %d-%s", this.getClass().getSimpleName(), strategyID, file.getAbsoluteFile()); } @Override