|
|
@ -39,6 +39,9 @@ import kotlinx.android.synthetic.main.dialog_edit_text.view.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_bookshelf.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_bookshelf.* |
|
|
|
import kotlinx.android.synthetic.main.view_tab_layout.* |
|
|
|
import kotlinx.android.synthetic.main.view_tab_layout.* |
|
|
|
import kotlinx.android.synthetic.main.view_title_bar.* |
|
|
|
import kotlinx.android.synthetic.main.view_title_bar.* |
|
|
|
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -99,8 +102,13 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b |
|
|
|
bookGroupLiveData = App.db.bookGroupDao().liveDataAll() |
|
|
|
bookGroupLiveData = App.db.bookGroupDao().liveDataAll() |
|
|
|
bookGroupLiveData?.observe(viewLifecycleOwner, Observer { |
|
|
|
bookGroupLiveData?.observe(viewLifecycleOwner, Observer { |
|
|
|
viewModel.checkGroup(it) |
|
|
|
viewModel.checkGroup(it) |
|
|
|
|
|
|
|
launch { |
|
|
|
synchronized(this) { |
|
|
|
synchronized(this) { |
|
|
|
tab_layout.removeOnTabSelectedListener(this) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
withContext(IO) { |
|
|
|
|
|
|
|
synchronized(this@BookshelfFragment) { |
|
|
|
|
|
|
|
tab_layout.removeOnTabSelectedListener(this@BookshelfFragment) |
|
|
|
bookGroups.clear() |
|
|
|
bookGroups.clear() |
|
|
|
if (AppConfig.bookGroupAllShow) { |
|
|
|
if (AppConfig.bookGroupAllShow) { |
|
|
|
bookGroups.add(AppConst.bookGroupAll) |
|
|
|
bookGroups.add(AppConst.bookGroupAll) |
|
|
@ -111,10 +119,15 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b |
|
|
|
if (AppConfig.bookGroupAudioShow) { |
|
|
|
if (AppConfig.bookGroupAudioShow) { |
|
|
|
bookGroups.add(AppConst.bookGroupAudio) |
|
|
|
bookGroups.add(AppConst.bookGroupAudio) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (App.db.bookDao().noGroupSize > 0) { |
|
|
|
|
|
|
|
bookGroups.add(AppConst.bookGroupNone) |
|
|
|
|
|
|
|
} |
|
|
|
bookGroups.addAll(it) |
|
|
|
bookGroups.addAll(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
view_pager_bookshelf.adapter?.notifyDataSetChanged() |
|
|
|
view_pager_bookshelf.adapter?.notifyDataSetChanged() |
|
|
|
tab_layout.getTabAt(getPrefInt(PreferKey.saveTabPosition, 0))?.select() |
|
|
|
tab_layout.getTabAt(getPrefInt(PreferKey.saveTabPosition, 0))?.select() |
|
|
|
tab_layout.addOnTabSelectedListener(this) |
|
|
|
tab_layout.addOnTabSelectedListener(this@BookshelfFragment) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -129,10 +142,16 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun upGroup() { |
|
|
|
override fun upGroup() { |
|
|
|
synchronized(this) { |
|
|
|
launch { |
|
|
|
|
|
|
|
withContext(IO) { |
|
|
|
|
|
|
|
synchronized(this@BookshelfFragment) { |
|
|
|
bookGroups.remove(AppConst.bookGroupAll) |
|
|
|
bookGroups.remove(AppConst.bookGroupAll) |
|
|
|
bookGroups.remove(AppConst.bookGroupLocal) |
|
|
|
bookGroups.remove(AppConst.bookGroupLocal) |
|
|
|
bookGroups.remove(AppConst.bookGroupAudio) |
|
|
|
bookGroups.remove(AppConst.bookGroupAudio) |
|
|
|
|
|
|
|
bookGroups.remove(AppConst.bookGroupNone) |
|
|
|
|
|
|
|
if (App.db.bookDao().noGroupSize > 0) { |
|
|
|
|
|
|
|
bookGroups.add(0, AppConst.bookGroupNone) |
|
|
|
|
|
|
|
} |
|
|
|
if (AppConfig.bookGroupAudioShow) { |
|
|
|
if (AppConfig.bookGroupAudioShow) { |
|
|
|
bookGroups.add(0, AppConst.bookGroupAudio) |
|
|
|
bookGroups.add(0, AppConst.bookGroupAudio) |
|
|
|
} |
|
|
|
} |
|
|
@ -142,6 +161,8 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b |
|
|
|
if (AppConfig.bookGroupAllShow) { |
|
|
|
if (AppConfig.bookGroupAllShow) { |
|
|
|
bookGroups.add(0, AppConst.bookGroupAll) |
|
|
|
bookGroups.add(0, AppConst.bookGroupAll) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
view_pager_bookshelf.adapter?.notifyDataSetChanged() |
|
|
|
view_pager_bookshelf.adapter?.notifyDataSetChanged() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|