aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-09-03 20:31:32 +0200
committerChristian Schneppe <christian@pix-art.de>2019-09-03 20:31:32 +0200
commitbe82ac563323ed83427b3ad692650c8283ce5338 (patch)
tree53dfcd82ec65e0b523c3790c3b57539a2aa0442b /src/main/java/de/pixart/messenger/persistance
parent4aa24e84c49348f8d96c273f77a636557dbb40a2 (diff)
fix some crashes
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java12
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java20
2 files changed, 23 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
index afffa388f..e9f7c0576 100644
--- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
@@ -1009,12 +1009,14 @@ public class DatabaseBackend extends SQLiteOpenHelper {
private List<Account> getAccounts(SQLiteDatabase db) {
List<Account> list = new ArrayList<>();
- Cursor cursor = db.query(Account.TABLENAME, null, null, null, null,
- null, null);
- while (cursor.moveToNext()) {
- list.add(Account.fromCursor(cursor));
+ try (Cursor cursor = db.query(Account.TABLENAME, null, null, null, null,
+ null, null)) {
+ while (cursor.moveToNext()) {
+ list.add(Account.fromCursor(cursor));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
- cursor.close();
return list;
}
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 962496dcb..235547c1d 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -719,7 +719,10 @@ public class FileBackend {
frame = metadataRetriever.getFrameAtTime(0);
metadataRetriever.release();
frame = resize(frame, size);
- } catch (IOException | RuntimeException e) {
+ } catch (IOException e) {
+ frame = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
+ frame.eraseColor(0xff000000);
+ } catch (RuntimeException e) {
frame = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
frame.eraseColor(0xff000000);
}
@@ -880,7 +883,9 @@ public class FileBackend {
avatar.width = options.outWidth;
avatar.type = options.outMimeType;
return avatar;
- } catch (NoSuchAlgorithmException | IOException e) {
+ } catch (NoSuchAlgorithmException e) {
+ return null;
+ } catch (IOException e) {
return null;
} finally {
close(is);
@@ -934,7 +939,11 @@ public class FileBackend {
return false;
}
avatar.size = bytes.length;
- } catch (IllegalArgumentException | IOException | NoSuchAlgorithmException e) {
+ } catch (IllegalArgumentException e) {
+ return false;
+ } catch (IOException e) {
+ return false;
+ } catch (NoSuchAlgorithmException e) {
return false;
} finally {
close(os);
@@ -970,7 +979,10 @@ public class FileBackend {
input = rotate(input, getRotation(image));
return cropCenterSquare(input, size);
}
- } catch (FileNotFoundException | SecurityException e) {
+ } catch (FileNotFoundException e) {
+ Log.d(Config.LOGTAG, "unable to open file " + image.toString(), e);
+ return null;
+ } catch (SecurityException e) {
Log.d(Config.LOGTAG, "unable to open file " + image.toString(), e);
return null;
} finally {