From 7612e6f8cdce89dea8350d9a697d57c7e6a29e13 Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 26 Sep 2017 09:48:50 +0200 Subject: [PATCH] - Bug & Crash fixes --- .../cameraroll/adapter/main/RecyclerViewAdapter.java | 2 +- .../java/us/koller/cameraroll/data/Settings.java | 8 +++++++- .../cameraroll/data/provider/MediaProvider.java | 2 +- .../java/us/koller/cameraroll/ui/ItemActivity.java | 1 + .../koller/cameraroll/ui/widget/CropImageView.java | 12 +++++++----- .../java/us/koller/cameraroll/util/ExifUtil.java | 1 - .../koller/cameraroll/util/animators/ColorFade.java | 6 ++++++ 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/us/koller/cameraroll/adapter/main/RecyclerViewAdapter.java b/app/src/main/java/us/koller/cameraroll/adapter/main/RecyclerViewAdapter.java index 9fbfc1d3..e0097849 100644 --- a/app/src/main/java/us/koller/cameraroll/adapter/main/RecyclerViewAdapter.java +++ b/app/src/main/java/us/koller/cameraroll/adapter/main/RecyclerViewAdapter.java @@ -151,7 +151,7 @@ public SelectorModeManager getSelectorManager() { @Override public int getItemCount() { - return albums.size(); + return albums != null ? albums.size() : 0; } public boolean onBackPressed() { diff --git a/app/src/main/java/us/koller/cameraroll/data/Settings.java b/app/src/main/java/us/koller/cameraroll/data/Settings.java index dd664831..913835ea 100644 --- a/app/src/main/java/us/koller/cameraroll/data/Settings.java +++ b/app/src/main/java/us/koller/cameraroll/data/Settings.java @@ -30,6 +30,7 @@ public class Settings { private boolean cameraShortcut; private Uri removableStorageTreeUri; private boolean virtualDirectories; + private boolean fadeImages = false; private static Settings instance; @@ -173,7 +174,7 @@ public void setColumnCount(int columnCount) { this.columnCount = columnCount; } - public static int getDefaultStyleColumnCount(Context context, int style) { + private static int getDefaultStyleColumnCount(Context context, int style) { Resources res = context.getResources(); if (style == res.getInteger(R.integer.STYLE_PARALLAX_VALUE)) { return res.getInteger(R.integer.STYLE_PARALLAX_COLUMN_COUNT); @@ -244,12 +245,17 @@ public boolean getVirtualDirectories() { return virtualDirectories; } + @SuppressWarnings("unused") public void setVirtualDirectories(Context context, boolean virtualDirectories) { this.virtualDirectories = virtualDirectories; saveBoolean(context, context.getString(R.string.pref_key_virtual_directories), virtualDirectories); } + public boolean fadeImages() { + return fadeImages; + } + public void setRemovableStorageTreeUri(Context context, Uri removableStorageTreeUri) { this.removableStorageTreeUri = removableStorageTreeUri; saveString(context, diff --git a/app/src/main/java/us/koller/cameraroll/data/provider/MediaProvider.java b/app/src/main/java/us/koller/cameraroll/data/provider/MediaProvider.java index d9695e46..1f51477b 100644 --- a/app/src/main/java/us/koller/cameraroll/data/provider/MediaProvider.java +++ b/app/src/main/java/us/koller/cameraroll/data/provider/MediaProvider.java @@ -89,7 +89,7 @@ public void onMediaLoaded(ArrayList albums) { //if (!hiddenFolders) { //remove excluded albums for (int i = albums.size() - 1; i >= 0; i--) { - if (albums.get(i).excluded) { + if (albums.get(i) == null || albums.get(i).excluded) { albums.remove(i); } } diff --git a/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java b/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java index c1441919..f29483f6 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java @@ -12,6 +12,7 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.FileUriExposedException; import android.os.Handler; import android.support.annotation.NonNull; import android.support.annotation.Nullable; diff --git a/app/src/main/java/us/koller/cameraroll/ui/widget/CropImageView.java b/app/src/main/java/us/koller/cameraroll/ui/widget/CropImageView.java index 86429ec7..516e26bc 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/widget/CropImageView.java +++ b/app/src/main/java/us/koller/cameraroll/ui/widget/CropImageView.java @@ -15,8 +15,6 @@ import android.graphics.RectF; import android.net.Uri; import android.os.AsyncTask; -import android.os.Handler; -import android.os.Looper; import android.support.v4.content.ContextCompat; import android.util.AttributeSet; import android.view.MotionEvent; @@ -107,8 +105,8 @@ public static class State extends ImageViewState { private int[] cropRect; - State(ImageViewState imageViewState, Rect cropRect) { - super(imageViewState.getScale(), imageViewState.getCenter(), imageViewState.getOrientation()); + State(float scale, PointF center, int orientation, Rect cropRect) { + super(scale, center, orientation); this.cropRect = new int[]{ cropRect.left, cropRect.top, cropRect.right, cropRect.bottom}; @@ -704,7 +702,11 @@ private void drawGuidelines(Canvas canvas) { } public State getCropImageViewState() { - return new State(getState(), cropRect); + ImageViewState state = getState(); + if (state != null) { + return new State(state.getScale(), state.getCenter(), state.getOrientation(), cropRect); + } + return null; } private ProgressBar getProgressBar() { diff --git a/app/src/main/java/us/koller/cameraroll/util/ExifUtil.java b/app/src/main/java/us/koller/cameraroll/util/ExifUtil.java index 6e240c83..74b7fe91 100644 --- a/app/src/main/java/us/koller/cameraroll/util/ExifUtil.java +++ b/app/src/main/java/us/koller/cameraroll/util/ExifUtil.java @@ -3,7 +3,6 @@ import android.content.Context; import android.net.Uri; import android.support.media.ExifInterface; -import android.widget.Toast; import java.io.IOException; import java.io.InputStream; diff --git a/app/src/main/java/us/koller/cameraroll/util/animators/ColorFade.java b/app/src/main/java/us/koller/cameraroll/util/animators/ColorFade.java index 6eaeff48..78872b7f 100644 --- a/app/src/main/java/us/koller/cameraroll/util/animators/ColorFade.java +++ b/app/src/main/java/us/koller/cameraroll/util/animators/ColorFade.java @@ -16,6 +16,8 @@ import android.widget.ImageView; import android.widget.TextView; +import us.koller.cameraroll.data.Settings; + public class ColorFade { private static AnimatorSet toolbarTitleAnimSet; @@ -62,6 +64,10 @@ private static int getAnimatedValue(int start, int end, float animatedValue) { // imageView saturation fade public static void fadeSaturation(final ImageView imageView) { + if (!Settings.getInstance(imageView.getContext()).fadeImages()) { + return; + } + // code from: https://github.com/nickbutcher/plaid/blob/master/app/src/main/java/io/plaidapp/ui/FeedAdapter.java imageView.setHasTransientState(true); final AnimUtils.ObservableColorMatrix matrix = new AnimUtils.ObservableColorMatrix();