|
|
@ -1,17 +1,23 @@ |
|
|
|
package io.legado.app.ui.chapterlist |
|
|
|
package io.legado.app.ui.chapterlist |
|
|
|
|
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
|
|
|
|
import android.view.Menu |
|
|
|
|
|
|
|
import androidx.appcompat.widget.SearchView |
|
|
|
|
|
|
|
import androidx.core.view.isGone |
|
|
|
import androidx.fragment.app.Fragment |
|
|
|
import androidx.fragment.app.Fragment |
|
|
|
import androidx.fragment.app.FragmentManager |
|
|
|
import androidx.fragment.app.FragmentManager |
|
|
|
import androidx.fragment.app.FragmentPagerAdapter |
|
|
|
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.gone |
|
|
|
import io.legado.app.utils.visible |
|
|
|
import io.legado.app.utils.visible |
|
|
|
import kotlinx.android.synthetic.main.activity_chapter_list.* |
|
|
|
import kotlinx.android.synthetic.main.activity_chapter_list.* |
|
|
|
import kotlinx.android.synthetic.main.view_title_bar.* |
|
|
|
import kotlinx.android.synthetic.main.view_title_bar.* |
|
|
|
|
|
|
|
|
|
|
|
class ChapterListActivity : BaseActivity(R.layout.activity_chapter_list) { |
|
|
|
class ChapterListActivity : BaseActivity(R.layout.activity_chapter_list) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var searchView: SearchView? = null |
|
|
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
setSupportActionBar(toolbar) |
|
|
|
setSupportActionBar(toolbar) |
|
|
|
tab_layout.visible() |
|
|
|
tab_layout.visible() |
|
|
@ -19,6 +25,28 @@ class ChapterListActivity : BaseActivity(R.layout.activity_chapter_list) { |
|
|
|
tab_layout.setupWithViewPager(view_pager) |
|
|
|
tab_layout.setupWithViewPager(view_pager) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { |
|
|
|
|
|
|
|
menuInflater.inflate(R.menu.search_view, menu) |
|
|
|
|
|
|
|
val search = menu.findItem(R.id.action_search) |
|
|
|
|
|
|
|
searchView = search.actionView as SearchView |
|
|
|
|
|
|
|
searchView?.maxWidth = resources.displayMetrics.widthPixels |
|
|
|
|
|
|
|
searchView?.onActionViewCollapsed() |
|
|
|
|
|
|
|
searchView?.setOnCloseListener { |
|
|
|
|
|
|
|
tab_layout.visible() |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
searchView?.setOnSearchClickListener { tab_layout.gone() } |
|
|
|
|
|
|
|
searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener { |
|
|
|
|
|
|
|
override fun onQueryTextSubmit(query: String): Boolean { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onQueryTextChange(newText: String): Boolean { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return super.onCompatCreateOptionsMenu(menu) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager) : |
|
|
|
private inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager) : |
|
|
|
FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { |
|
|
|
FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { |
|
|
@ -41,4 +69,13 @@ class ChapterListActivity : BaseActivity(R.layout.activity_chapter_list) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onBackPressed() { |
|
|
|
|
|
|
|
if (tab_layout.isGone) { |
|
|
|
|
|
|
|
searchView?.onActionViewCollapsed() |
|
|
|
|
|
|
|
tab_layout.visible() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
super.onBackPressed() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |