Skip to content

Commit

Permalink
Add example bookmarks only if there are no existing bookmarks in db #…
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Jul 15, 2021
1 parent ec37d08 commit 741cf57
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions app/src/main/java/net/bible/service/common/CommonUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import net.bible.android.activity.BuildConfig.GitHash
import net.bible.android.activity.R
import net.bible.android.database.WorkspaceEntities
import net.bible.android.database.bookmarks.BookmarkEntities
import net.bible.android.database.bookmarks.BookmarkSortOrder
import net.bible.android.database.bookmarks.BookmarkType
import net.bible.android.database.bookmarks.KJVA
import net.bible.android.database.bookmarks.LabelType
Expand Down Expand Up @@ -864,16 +865,19 @@ object CommonUtils {
)
val salvationLabel = BookmarkEntities.Label(name = application.getString(R.string.label_salvation), type = LabelType.EXAMPLE, color = Color.argb(255, 255, 0, 255))
highlightIds = bookmarkDao.insertLabels(highlightLabels)
val salvationId = bookmarkDao.insert(salvationLabel)

listOf("Gen.1.1", "Joh.3.16", "Joh.3.3", "Tit.3.3-Tit.3.7", "Rom.3.23-Rom.3.24", "Rom.4.3", "1Tim.1.15", "Eph.2.8-Eph.2.9", "Isa.6.3", "Rev.4.8", "Exo.20.2-Exo.2.17")
.map { VerseRangeFactory.fromString(KJVA, it) }
.map {
BookmarkEntities.Bookmark(it, textRange = null, wholeVerse = true, book = null).apply { type = BookmarkType.EXAMPLE }
}.forEach {
val bid = bookmarkDao.insert(it)
bookmarkDao.insert(BookmarkEntities.BookmarkToLabel(bid, salvationId))
}

if(bookmarkDao.allBookmarks(BookmarkSortOrder.ORDER_NUMBER).isEmpty()) {
val salvationId = bookmarkDao.insert(salvationLabel)

listOf("Gen.1.1", "Joh.3.16", "Joh.3.3", "Tit.3.3-Tit.3.7", "Rom.3.23-Rom.3.24", "Rom.4.3", "1Tim.1.15", "Eph.2.8-Eph.2.9", "Isa.6.3", "Rev.4.8", "Exo.20.2-Exo.2.17")
.map { VerseRangeFactory.fromString(KJVA, it) }
.map {
BookmarkEntities.Bookmark(it, textRange = null, wholeVerse = true, book = null).apply { type = BookmarkType.EXAMPLE }
}.forEach {
val bid = bookmarkDao.insert(it)
bookmarkDao.insert(BookmarkEntities.BookmarkToLabel(bid, salvationId))
}
}
}

val ws = workspaceDao.allWorkspaces()
Expand Down

0 comments on commit 741cf57

Please sign in to comment.