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

Commit

Permalink
- updated gradle-plugin to 3.0.0
Browse files Browse the repository at this point in the history
- minor changes
- tests for issue #71
  • Loading branch information
kollerlukas committed Oct 25, 2017
1 parent d54b784 commit 4cf5fe6
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
Expand Down Expand Up @@ -88,7 +87,9 @@ protected void onHandleIntent(Intent workIntent) {
startForeground(NOTIFICATION_ID, notification);
NotificationManager manager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ID, notification);
if (manager != null) {
manager.notify(NOTIFICATION_ID, notification);
}

ContentObserver.selfChange = true;

Expand Down Expand Up @@ -133,7 +134,9 @@ private void createNotificationChannel() {
getString(R.string.file_op_channel_name),
NotificationManager.IMPORTANCE_LOW);
mChannel.setDescription(getString(R.string.file_op_channel_description));
mNotificationManager.createNotificationChannel(mChannel);
if (mNotificationManager != null) {
mNotificationManager.createNotificationChannel(mChannel);
}
}

private NotificationCompat.Builder getNotificationBuilder() {
Expand Down Expand Up @@ -206,7 +209,9 @@ public void onProgress(final int progress, final int totalNumber) {
notifBuilder.setProgress(0, 0, true);
NotificationManager manager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ID, notifBuilder.build());
if (manager != null) {
manager.notify(NOTIFICATION_ID, notifBuilder.build());
}
}

public void showToast(final String message) {
Expand Down Expand Up @@ -421,7 +426,68 @@ private static void scanPaths(final Context context, final String[] paths, final
toastWeakReference = null;
}

String[] mimeTypes = new String[paths.length];

for (int i = 0; i < paths.length; i++) {
String path = paths[i];
if (MediaType.isMedia(path)) {
Uri contentUri = MediaStore.Files.getContentUri("external");
ContentResolver resolver = context.getContentResolver();
if (new File(path).exists()) {
AlbumItem albumItem = AlbumItem.getInstance(path);
ContentValues values = new ContentValues();
if (albumItem instanceof Video) {
values.put(MediaStore.Video.Media.DATA, path);
values.put(MediaStore.Video.Media.MIME_TYPE, MediaType.getMimeType(path));
} else {
values.put(MediaStore.Images.Media.DATA, path);
values.put(MediaStore.Images.Media.MIME_TYPE, MediaType.getMimeType(path));
try {
ExifInterface exif = new ExifInterface(path);
Locale locale = us.koller.cameraroll.util.Util.getLocale(context);
String dateString = String.valueOf(ExifUtil.getCastValue(exif, ExifInterface.TAG_DATETIME));
try {
Date date = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", locale).parse(dateString);
long dateTaken = date.getTime();
values.put(MediaStore.Images.Media.DATE_TAKEN, dateTaken);
} catch (ParseException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
resolver.insert(contentUri, values);
} else {
resolver.delete(contentUri,
MediaStore.MediaColumns.DATA + "='" + path + "'",
null);
}
}

if (showToast) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast toast = toastWeakReference.get();
if (toast != null) {
toastWeakReference.get().show();
}
}
});
}

}

if (callback != null) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
callback.onAllPathsScanned();
}
});
}

/*String[] mimeTypes = new String[paths.length];
for (int i = 0; i < paths.length; i++) {
mimeTypes[i] = MediaType.getMimeType(paths[i]);
}
Expand Down Expand Up @@ -494,7 +560,7 @@ public void run() {
});
}
}
});
});*/
}

public static String getParentPath(String path) {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,9 @@ protected void onDestroy() {

@Override
public boolean canSwipeBack(int dir) {
return SwipeBackCoordinatorLayout.canSwipeBackForThisView(recyclerView, dir) && !pick_photos;
RecyclerViewAdapter adapter = (RecyclerViewAdapter) recyclerView.getAdapter();
return !adapter.isSelectorModeActive() &&
SwipeBackCoordinatorLayout.canSwipeBackForThisView(recyclerView, dir) && !pick_photos;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta7'
classpath 'com.android.tools.build:gradle:3.0.0'
}
}

Expand Down

0 comments on commit 4cf5fe6

Please sign in to comment.