|
|
|
@ -95,16 +95,6 @@ class CacheActivity : VMBaseActivity<CacheViewModel>(R.layout.activity_download) |
|
|
|
|
R.id.menu_log -> { |
|
|
|
|
TextListDialog.show(supportFragmentManager, getString(R.string.log), CacheBook.logs) |
|
|
|
|
} |
|
|
|
|
R.id.menu_no_group -> { |
|
|
|
|
title_bar.subtitle = getString(R.string.no_group) |
|
|
|
|
groupId = AppConst.bookGroupNoneId |
|
|
|
|
initBookData() |
|
|
|
|
} |
|
|
|
|
R.id.menu_all -> { |
|
|
|
|
title_bar.subtitle = item.title |
|
|
|
|
groupId = AppConst.bookGroupAllId |
|
|
|
|
initBookData() |
|
|
|
|
} |
|
|
|
|
else -> if (item.groupId == R.id.menu_group) { |
|
|
|
|
title_bar.subtitle = item.title |
|
|
|
|
groupId = App.db.bookGroupDao().getByName(item.title.toString())?.groupId ?: 0 |
|
|
|
@ -124,6 +114,8 @@ class CacheActivity : VMBaseActivity<CacheViewModel>(R.layout.activity_download) |
|
|
|
|
booksLiveData?.removeObservers(this) |
|
|
|
|
booksLiveData = when (groupId) { |
|
|
|
|
AppConst.bookGroupAllId -> App.db.bookDao().observeAll() |
|
|
|
|
AppConst.bookGroupLocalId -> App.db.bookDao().observeLocal() |
|
|
|
|
AppConst.bookGroupAudioId -> App.db.bookDao().observeAudio() |
|
|
|
|
AppConst.bookGroupNoneId -> App.db.bookDao().observeNoGroup() |
|
|
|
|
else -> App.db.bookDao().observeByGroup(groupId) |
|
|
|
|
} |
|
|
|
|