use try with resources. remove unused methods
This commit is contained in:
parent
3534c619fb
commit
48f8c1a6a0
|
@ -186,11 +186,6 @@ public class FileBackend {
|
|||
return paint;
|
||||
}
|
||||
|
||||
private static String getTakePhotoPath() {
|
||||
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
|
||||
+ "/Camera/";
|
||||
}
|
||||
|
||||
public static Uri getUriForUri(Context context, Uri uri) {
|
||||
if ("file".equals(uri.getScheme())) {
|
||||
return getUriForFile(context, new File(uri.getPath()));
|
||||
|
@ -474,19 +469,6 @@ public class FileBackend {
|
|||
return bitmap;
|
||||
}
|
||||
|
||||
private void createNoMedia(File diretory) {
|
||||
final File noMedia = new File(diretory, ".nomedia");
|
||||
if (!noMedia.exists()) {
|
||||
try {
|
||||
if (!noMedia.createNewFile()) {
|
||||
Log.d(Config.LOGTAG, "created nomedia file " + noMedia.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d(Config.LOGTAG, "could not create nomedia file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMediaScanner(File file) {
|
||||
updateMediaScanner(file, null);
|
||||
}
|
||||
|
@ -724,28 +706,18 @@ public class FileBackend {
|
|||
copyFileToPrivateStorage(mXmppConnectionService.getFileBackend().getFile(message), uri);
|
||||
}
|
||||
|
||||
private String getExtensionFromUri(Uri uri) {
|
||||
String[] projection = {MediaStore.MediaColumns.DATA};
|
||||
private String getExtensionFromUri(final Uri uri) {
|
||||
final String[] projection = {MediaStore.MediaColumns.DATA};
|
||||
String filename = null;
|
||||
Cursor cursor;
|
||||
try {
|
||||
cursor =
|
||||
mXmppConnectionService
|
||||
.getContentResolver()
|
||||
.query(uri, projection, null, null, null);
|
||||
} catch (IllegalArgumentException e) {
|
||||
cursor = null;
|
||||
}
|
||||
if (cursor != null) {
|
||||
try {
|
||||
if (cursor.moveToFirst()) {
|
||||
filename = cursor.getString(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
filename = null;
|
||||
} finally {
|
||||
cursor.close();
|
||||
try (final Cursor cursor =
|
||||
mXmppConnectionService
|
||||
.getContentResolver()
|
||||
.query(uri, projection, null, null, null)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
filename = cursor.getString(0);
|
||||
}
|
||||
} catch (final SecurityException | IllegalArgumentException e) {
|
||||
filename = null;
|
||||
}
|
||||
if (filename == null) {
|
||||
final List<String> segments = uri.getPathSegments();
|
||||
|
@ -753,7 +725,7 @@ public class FileBackend {
|
|||
filename = segments.get(segments.size() - 1);
|
||||
}
|
||||
}
|
||||
int pos = filename == null ? -1 : filename.lastIndexOf('.');
|
||||
final int pos = filename == null ? -1 : filename.lastIndexOf('.');
|
||||
return pos > 0 ? filename.substring(pos + 1) : null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue