From 01d23aacf1e9b43aabcab1918b03192a1dc0ae91 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 8 Jun 2019 13:08:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/main/booksource/BookSourceFragment.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt index 7ace4bfce..760920011 100644 --- a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.Menu import android.view.MenuItem import android.view.View +import androidx.appcompat.widget.SearchView import androidx.lifecycle.LiveData import androidx.lifecycle.Observer import androidx.paging.LivePagedListBuilder @@ -11,7 +12,6 @@ import androidx.paging.PagedList import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseFragment @@ -24,7 +24,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.jetbrains.anko.startActivity -class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSourceAdapter.CallBack { +class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSourceAdapter.CallBack, SearchView.OnQueryTextListener { private lateinit var adapter: BookSourceAdapter private var bookSourceLiveDate: LiveData>? = null @@ -65,6 +65,7 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour search_view.onActionViewExpanded() search_view.queryHint = getString(R.string.search_book_source) search_view.clearFocus() + search_view.setOnQueryTextListener(this) } private fun initDataObservers() { @@ -73,6 +74,14 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour bookSourceLiveDate?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) }) } + override fun onQueryTextChange(newText: String?): Boolean { + return false + } + + override fun onQueryTextSubmit(query: String?): Boolean { + return false + } + override fun del(bookSource: BookSource) { GlobalScope.launch { App.db.bookSourceDao().delete(bookSource) } }