pull/433/head
gedoor 4 years ago
parent 39d824b9f1
commit b2d6249cfc
  1. 25
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  3. 14
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  4. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt

@ -45,7 +45,30 @@ abstract class AppDatabase: RoomDatabase() {
private val dbCallback = object : Callback() {
override fun onOpen(db: SupportSQLiteDatabase) {
db.execSQL(
"""
insert into book_groups(groupId, groupName, 'order') select -1, '全部', -10
where not exists (select * from book_groups where groupId = -1)
"""
)
db.execSQL(
"""
insert into book_groups(groupId, groupName, 'order') select -2, '本地', -9
where not exists (select * from book_groups where groupId = -2)
"""
)
db.execSQL(
"""
insert into book_groups(groupId, groupName, 'order') select -3, '音频', -8
where not exists (select * from book_groups where groupId = -3)
"""
)
db.execSQL(
"""
insert into book_groups(groupId, groupName, 'order') select -4, '未分组', -7
where not exists (select * from book_groups where groupId = -4)
"""
)
}
}

@ -195,14 +195,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean {
if (srcPosition < 4 || targetPosition < 4) {
return true
}
Collections.swap(
getItems(),
srcPosition - getHeaderCount(),
targetPosition - getHeaderCount()
)
Collections.swap(getItems(), srcPosition, targetPosition)
notifyItemMoved(srcPosition, targetPosition)
isMoved = true
return true

@ -12,11 +12,9 @@ import com.google.android.material.tabs.TabLayout
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.VMBaseFragment
import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.BookGroup
import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.customView
import io.legado.app.lib.dialogs.noButton
@ -126,18 +124,6 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
@Synchronized
private fun upGroup(data: List<BookGroup>) {
bookGroups.clear()
if (AppConfig.bookGroupAllShow) {
bookGroups.add(AppConst.bookGroupAll)
}
if (AppConfig.bookGroupLocalShow) {
bookGroups.add(AppConst.bookGroupLocal)
}
if (AppConfig.bookGroupAudioShow) {
bookGroups.add(AppConst.bookGroupAudio)
}
if (AppConfig.bookGroupNoneShow) {
bookGroups.add(AppConst.bookGroupNone)
}
bookGroups.addAll(data)
adapter.notifyDataSetChanged()
selectLastTab()

@ -64,7 +64,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
fun checkGroup(groups: List<BookGroup>) {
groups.forEach { group ->
if (group.groupId and (group.groupId - 1) != 0L) {
if (group.groupId > 0 && group.groupId and (group.groupId - 1) != 0L) {
var id = 1L
val idsSum = App.db.bookGroupDao().idsSum
while (id and idsSum != 0L) {

Loading…
Cancel
Save