Skip to content

Commit

Permalink
Fixed issue of inserting duplicate data
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorModi committed Feb 9, 2024
1 parent 5054f90 commit 5fecd1c
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions app/src/main/java/statusbar/finder/LyricsDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,18 @@ public boolean insertLyricIntoDatabase(ILrcProvider.LyricResult lyricResult, ILr
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction();
if (lyricResult == null) {
try {
if (searchLyricFromDatabase(originMediaInfo) != null) return true;
try {
if (lyricResult == null) {
db.execSQL(query, new Object[]{originMediaInfo.getTitle(), originMediaInfo.getArtist(), originMediaInfo.getAlbum(),
packageName, originMediaInfo.getDuration(), -1, null, null, null, null, null, null, 0});
db.setTransactionSuccessful();
return true;
} catch (Exception e) {
e.fillInStackTrace();
return false;
} finally {
db.endTransaction();
} else {
db.execSQL(query, new Object[]{originMediaInfo.getTitle(), originMediaInfo.getArtist(), originMediaInfo.getAlbum(),
packageName, originMediaInfo.getDuration(), lyricResult.mDistance, lyricResult.resultInfo.getTitle()
, lyricResult.resultInfo.getArtist(), lyricResult.resultInfo.getAlbum(), lyricResult.mLyric, lyricResult.mTranslatedLyric,
lyricResult.mSource, 0});
}
}
try {
db.execSQL(query, new Object[]{originMediaInfo.getTitle(), originMediaInfo.getArtist(), originMediaInfo.getAlbum(),
packageName, originMediaInfo.getDuration(), lyricResult.mDistance, lyricResult.resultInfo.getTitle()
, lyricResult.resultInfo.getArtist(), lyricResult.resultInfo.getAlbum(), lyricResult.mLyric, lyricResult.mTranslatedLyric,
lyricResult.mSource, 0});
db.setTransactionSuccessful();
db.setTransactionSuccessful();
return true;
} catch (Exception e) {
e.fillInStackTrace();
Expand Down

0 comments on commit 5fecd1c

Please sign in to comment.