diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt b/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt index 867872e8d..b62fa6f49 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt +++ b/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt @@ -1,8 +1,12 @@ package io.legado.app.ui.chapterlist import io.legado.app.R -import io.legado.app.base.BaseFragment +import io.legado.app.base.VMBaseFragment +import io.legado.app.utils.getViewModelOfActivity + +class BookmarkFragment : VMBaseFragment(R.layout.fragment_bookmark) { + override val viewModel: ChapterListViewModel + get() = getViewModelOfActivity(ChapterListViewModel::class.java) -class BookmarkFragment : BaseFragment(R.layout.fragment_bookmark) { } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt index e77642729..dc3553754 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt +++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt @@ -8,16 +8,19 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter import io.legado.app.R -import io.legado.app.base.BaseActivity +import io.legado.app.base.VMBaseActivity import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.primaryTextColor +import io.legado.app.utils.getViewModel import io.legado.app.utils.gone import io.legado.app.utils.visible import kotlinx.android.synthetic.main.activity_chapter_list.* import kotlinx.android.synthetic.main.view_tab_layout.* import kotlinx.android.synthetic.main.view_title_bar.* -class ChapterListActivity : BaseActivity(R.layout.activity_chapter_list) { +class ChapterListActivity : VMBaseActivity(R.layout.activity_chapter_list) { + override val viewModel: ChapterListViewModel + get() = getViewModel(ChapterListViewModel::class.java) private var searchView: SearchView? = null diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt index 1e6dd3870..f88f0dbb6 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt +++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt @@ -1,8 +1,13 @@ package io.legado.app.ui.chapterlist import io.legado.app.R -import io.legado.app.base.BaseFragment +import io.legado.app.base.VMBaseFragment +import io.legado.app.utils.getViewModelOfActivity + +class ChapterListFragment : VMBaseFragment(R.layout.fragment_chapter_list) { + override val viewModel: ChapterListViewModel + get() = getViewModelOfActivity(ChapterListViewModel::class.java) + -class ChapterListFragment : BaseFragment(R.layout.fragment_chapter_list) { } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListViewModel.kt b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListViewModel.kt new file mode 100644 index 000000000..3b41d0a73 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListViewModel.kt @@ -0,0 +1,8 @@ +package io.legado.app.ui.chapterlist + +import io.legado.app.App +import io.legado.app.base.BaseViewModel + +class ChapterListViewModel : BaseViewModel(App.INSTANCE) { + +} \ No newline at end of file