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 new file mode 100644 index 000000000..867872e8d --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt @@ -0,0 +1,8 @@ +package io.legado.app.ui.chapterlist + +import io.legado.app.R +import io.legado.app.base.BaseFragment + +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 89aa188c5..b4ff2583b 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 @@ -1,13 +1,44 @@ package io.legado.app.ui.chapterlist import android.os.Bundle +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.utils.visible +import kotlinx.android.synthetic.main.activity_chapter_list.* +import kotlinx.android.synthetic.main.view_title_bar.* class ChapterListActivity : BaseActivity(R.layout.activity_chapter_list) { override fun onActivityCreated(savedInstanceState: Bundle?) { - + setSupportActionBar(toolbar) + tab_layout.visible() + view_pager.adapter = TabFragmentPageAdapter(supportFragmentManager) + tab_layout.setupWithViewPager(view_pager) } + + private inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager) : + FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { + override fun getItem(position: Int): Fragment { + return when (position) { + 1 -> BookmarkFragment() + else -> ChapterListFragment() + } + } + + override fun getCount(): Int { + return 2 + } + + override fun getPageTitle(position: Int): CharSequence? { + return when (position) { + 1 -> getString(R.string.bookmark) + else -> getString(R.string.chapter_list) + } + } + + } } \ No newline at end of file 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 new file mode 100644 index 000000000..1e6dd3870 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt @@ -0,0 +1,8 @@ +package io.legado.app.ui.chapterlist + +import io.legado.app.R +import io.legado.app.base.BaseFragment + +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/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 0b014304a..814947fe2 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -24,6 +24,7 @@ import io.legado.app.lib.dialogs.yesButton import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.bookshelf.BookshelfActivity +import io.legado.app.ui.read.ReadActivity import io.legado.app.ui.search.SearchActivity import io.legado.app.utils.* import kotlinx.android.synthetic.main.dialog_edittext.view.* @@ -34,7 +35,8 @@ import org.jetbrains.anko.textColor class BookshelfFragment : VMBaseFragment(R.layout.fragment_bookshelf), SearchView.OnQueryTextListener, - BookGroupAdapter.CallBack { + BookGroupAdapter.CallBack, + BookshelfAdapter.CallBack { override val viewModel: BookshelfViewModel get() = getViewModel(BookshelfViewModel::class.java) @@ -87,6 +89,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b rv_bookshelf.addItemDecoration(DividerItemDecoration(rv_bookshelf.context, LinearLayoutManager.VERTICAL)) bookshelfAdapter = BookshelfAdapter() rv_bookshelf.adapter = bookshelfAdapter + bookshelfAdapter.callBack = this } private fun initBookGroupData() { @@ -108,6 +111,14 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b } } + override fun open(book: Book) { + context?.startActivity() + } + + override fun search() { + + } + override fun onQueryTextSubmit(query: String?): Boolean { context?.startActivity(Pair("key", query)) return false diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 5c23674e2..d64f3c6f0 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -6,7 +6,7 @@ import android.view.MenuItem import android.view.View import io.legado.app.R import io.legado.app.base.BaseFragment -import io.legado.app.ui.read.ReadActivity +import io.legado.app.ui.chapterlist.ChapterListActivity import io.legado.app.utils.startActivity import kotlinx.android.synthetic.main.view_title_bar.* @@ -26,7 +26,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) { override fun onCompatOptionsItemSelected(item: MenuItem) { when (item.itemId) { - R.id.action_settings -> startActivity() + R.id.action_settings -> startActivity() } } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_chapter_list.xml b/app/src/main/res/layout/activity_chapter_list.xml index d829e291c..94bb27054 100644 --- a/app/src/main/res/layout/activity_chapter_list.xml +++ b/app/src/main/res/layout/activity_chapter_list.xml @@ -4,4 +4,14 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_bookmark.xml b/app/src/main/res/layout/fragment_bookmark.xml new file mode 100644 index 000000000..d829e291c --- /dev/null +++ b/app/src/main/res/layout/fragment_bookmark.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_chapter_list.xml b/app/src/main/res/layout/fragment_chapter_list.xml new file mode 100644 index 000000000..d829e291c --- /dev/null +++ b/app/src/main/res/layout/fragment_chapter_list.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_title_bar.xml b/app/src/main/res/layout/view_title_bar.xml index 051bbc03d..5200ed5e8 100644 --- a/app/src/main/res/layout/view_title_bar.xml +++ b/app/src/main/res/layout/view_title_bar.xml @@ -15,4 +15,10 @@ android:imeOptions="actionSearch" app:defaultQueryHint="搜索" /> + +