Skip to content
This repository has been archived by the owner on Sep 8, 2019. It is now read-only.

Commit

Permalink
- Bug & Crash fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kollerlukas committed Sep 26, 2017
1 parent 07b0229 commit 7612e6f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public SelectorModeManager getSelectorManager() {

@Override
public int getItemCount() {
return albums.size();
return albums != null ? albums.size() : 0;
}

public boolean onBackPressed() {
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/us/koller/cameraroll/data/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Settings {
private boolean cameraShortcut;
private Uri removableStorageTreeUri;
private boolean virtualDirectories;
private boolean fadeImages = false;

private static Settings instance;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void onMediaLoaded(ArrayList<Album> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/us/koller/cameraroll/util/ExifUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7612e6f

Please sign in to comment.