pull/32/head
kunfei 5 years ago
parent 0eff3e98d4
commit 95f9f0376a
  1. 8
      app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt
  2. 33
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt
  3. 8
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt
  4. 13
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  5. 4
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  6. 10
      app/src/main/res/layout/activity_chapter_list.xml
  7. 7
      app/src/main/res/layout/fragment_bookmark.xml
  8. 7
      app/src/main/res/layout/fragment_chapter_list.xml
  9. 6
      app/src/main/res/layout/view_title_bar.xml

@ -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) {
}

@ -1,13 +1,44 @@
package io.legado.app.ui.chapterlist package io.legado.app.ui.chapterlist
import android.os.Bundle 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.R
import io.legado.app.base.BaseActivity 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) { class ChapterListActivity : BaseActivity(R.layout.activity_chapter_list) {
override fun onActivityCreated(savedInstanceState: Bundle?) { 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)
}
}
}
} }

@ -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) {
}

@ -24,6 +24,7 @@ import io.legado.app.lib.dialogs.yesButton
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.bookshelf.BookshelfActivity 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.ui.search.SearchActivity
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.android.synthetic.main.dialog_edittext.view.* import kotlinx.android.synthetic.main.dialog_edittext.view.*
@ -34,7 +35,8 @@ import org.jetbrains.anko.textColor
class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_bookshelf), class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_bookshelf),
SearchView.OnQueryTextListener, SearchView.OnQueryTextListener,
BookGroupAdapter.CallBack { BookGroupAdapter.CallBack,
BookshelfAdapter.CallBack {
override val viewModel: BookshelfViewModel override val viewModel: BookshelfViewModel
get() = getViewModel(BookshelfViewModel::class.java) get() = getViewModel(BookshelfViewModel::class.java)
@ -87,6 +89,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
rv_bookshelf.addItemDecoration(DividerItemDecoration(rv_bookshelf.context, LinearLayoutManager.VERTICAL)) rv_bookshelf.addItemDecoration(DividerItemDecoration(rv_bookshelf.context, LinearLayoutManager.VERTICAL))
bookshelfAdapter = BookshelfAdapter() bookshelfAdapter = BookshelfAdapter()
rv_bookshelf.adapter = bookshelfAdapter rv_bookshelf.adapter = bookshelfAdapter
bookshelfAdapter.callBack = this
} }
private fun initBookGroupData() { private fun initBookGroupData() {
@ -108,6 +111,14 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
} }
} }
override fun open(book: Book) {
context?.startActivity<ReadActivity>()
}
override fun search() {
}
override fun onQueryTextSubmit(query: String?): Boolean { override fun onQueryTextSubmit(query: String?): Boolean {
context?.startActivity<SearchActivity>(Pair("key", query)) context?.startActivity<SearchActivity>(Pair("key", query))
return false return false

@ -6,7 +6,7 @@ import android.view.MenuItem
import android.view.View import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseFragment 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 io.legado.app.utils.startActivity
import kotlinx.android.synthetic.main.view_title_bar.* 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) { override fun onCompatOptionsItemSelected(item: MenuItem) {
when (item.itemId) { when (item.itemId) {
R.id.action_settings -> startActivity<ReadActivity>() R.id.action_settings -> startActivity<ChapterListActivity>()
} }
} }
} }

@ -4,4 +4,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout> </LinearLayout>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>

@ -15,4 +15,10 @@
android:imeOptions="actionSearch" android:imeOptions="actionSearch"
app:defaultQueryHint="搜索" /> app:defaultQueryHint="搜索" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</androidx.appcompat.widget.Toolbar> </androidx.appcompat.widget.Toolbar>

Loading…
Cancel
Save