Skip to content

Commit 6375ddb

Browse files
committed
feat: artwork cover fallback
1 parent d618eac commit 6375ddb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

app/src/main/java/io/compactd/client/models/CompactdArtwork.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,20 @@ public InputStream getImage (ArtworkSize size) {
6565
Database db = this.mManager.getDatabase(databaseName());
6666
Document doc = db.getDocument(getId());
6767
Revision rev = doc.getCurrentRevision();
68-
Attachment att = rev.getAttachment(size.getSize());
69-
if (att != null) {
70-
return att.getContent();
68+
if (rev != null) {
69+
Attachment att = rev.getAttachment(size.getSize());
70+
if (att != null) {
71+
return att.getContent();
72+
}
7173
}
7274
} catch (CouchbaseLiteException ignored) {
7375
}
74-
return null;
76+
try {
77+
return ((AndroidContext) mManager.getContext()).getWrappedContext().getResources().getAssets().open("album_fallback.jpg");
78+
} catch (IOException e) {
79+
e.printStackTrace();
80+
return null;
81+
}
7582
}
7683

7784
}

0 commit comments

Comments
 (0)