diff --git a/app/src/main/java/com/quran/labs/androidquran/model/bookmark/BookmarkJsonModel.kt b/app/src/main/java/com/quran/labs/androidquran/model/bookmark/BookmarkJsonModel.kt index 1c8608017b..617d51e8ad 100644 --- a/app/src/main/java/com/quran/labs/androidquran/model/bookmark/BookmarkJsonModel.kt +++ b/app/src/main/java/com/quran/labs/androidquran/model/bookmark/BookmarkJsonModel.kt @@ -23,7 +23,7 @@ internal class BookmarkJsonModel @Inject constructor() { @Throws(IOException::class) fun toCSV(sink: BufferedSink, bookmarks: BookmarkData) { - toCSV(sink, bookmarks) + com.quran.labs.androidquran.model.bookmark.toCSV(sink, bookmarks) } @Throws(IOException::class) diff --git a/common/bookmark/src/main/java/com/quran/mobile/bookmark/model/BookmarksDaoImpl.kt b/common/bookmark/src/main/java/com/quran/mobile/bookmark/model/BookmarksDaoImpl.kt index 039d1b70d5..98680f91f8 100644 --- a/common/bookmark/src/main/java/com/quran/mobile/bookmark/model/BookmarksDaoImpl.kt +++ b/common/bookmark/src/main/java/com/quran/mobile/bookmark/model/BookmarksDaoImpl.kt @@ -12,7 +12,6 @@ import com.quran.mobile.bookmark.mapper.convergeCommonlyTagged import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext import javax.inject.Inject @@ -75,7 +74,12 @@ class BookmarksDaoImpl @Inject constructor( override suspend fun togglePageBookmark(page: Int): Boolean { return withContext(Dispatchers.IO) { - val bookmarkId = bookmarkQueries.getBookmarkIdForPage(page).executeAsOneOrNull() + val bookmarkIds = bookmarkQueries.getBookmarkIdForPage(page).executeAsList() + if (bookmarkIds.size > 1) { + bookmarkIds.drop(1).forEach { deleteBookmarkById(it) } + } + + val bookmarkId = bookmarkIds.firstOrNull() if (bookmarkId != null) { deleteBookmarkById(bookmarkId) false diff --git a/feature/linebyline/src/main/java/com/quran/labs/androidquran/extra/feature/linebyline/presenter/QuranLineByLinePresenter.kt b/feature/linebyline/src/main/java/com/quran/labs/androidquran/extra/feature/linebyline/presenter/QuranLineByLinePresenter.kt index 46a03d4b50..63cc5509af 100644 --- a/feature/linebyline/src/main/java/com/quran/labs/androidquran/extra/feature/linebyline/presenter/QuranLineByLinePresenter.kt +++ b/feature/linebyline/src/main/java/com/quran/labs/androidquran/extra/feature/linebyline/presenter/QuranLineByLinePresenter.kt @@ -304,15 +304,17 @@ class QuranLineByLinePresenter @Inject constructor( val lines = mutableListOf() val whence = quranFileManager.quranImagesDirectory() for (lineNumber in 1..15) { + val file = File(File(whence, page.toString()), "$lineNumber.png") try { - val fileName = File(File(whence, page.toString()), "$lineNumber.png").toString() + val fileName = file.toString() val sourceBitmap = BitmapFactory.decodeFile(fileName, options) val bitmap = sourceBitmap.extractAlpha() sourceBitmap.recycle() lines.add(LineModel(lineNumber - 1, bitmap.asImageBitmap())) } catch (exception: Exception) { + val status = if (file.exists()) { "exists" } else { "missing" } // make sure to add the line number and page to the crash metadata - crashReporter.log("Failed to load line $lineNumber for page $page") + crashReporter.log("Failed to load line $lineNumber for page $page - file $status") throw exception } }