|
|
@ -4,6 +4,7 @@ import android.os.Bundle |
|
|
|
import android.view.Menu |
|
|
|
import android.view.Menu |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
|
|
|
|
import androidx.appcompat.widget.SearchView |
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
import androidx.lifecycle.Observer |
|
|
|
import androidx.lifecycle.Observer |
|
|
|
import androidx.paging.LivePagedListBuilder |
|
|
|
import androidx.paging.LivePagedListBuilder |
|
|
@ -11,7 +12,6 @@ import androidx.paging.PagedList |
|
|
|
import androidx.recyclerview.widget.DividerItemDecoration |
|
|
|
import androidx.recyclerview.widget.DividerItemDecoration |
|
|
|
import androidx.recyclerview.widget.ItemTouchHelper |
|
|
|
import androidx.recyclerview.widget.ItemTouchHelper |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.BaseFragment |
|
|
|
import io.legado.app.base.BaseFragment |
|
|
@ -24,7 +24,7 @@ import kotlinx.coroutines.GlobalScope |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
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 lateinit var adapter: BookSourceAdapter |
|
|
|
private var bookSourceLiveDate: LiveData<PagedList<BookSource>>? = null |
|
|
|
private var bookSourceLiveDate: LiveData<PagedList<BookSource>>? = null |
|
|
@ -65,6 +65,7 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour |
|
|
|
search_view.onActionViewExpanded() |
|
|
|
search_view.onActionViewExpanded() |
|
|
|
search_view.queryHint = getString(R.string.search_book_source) |
|
|
|
search_view.queryHint = getString(R.string.search_book_source) |
|
|
|
search_view.clearFocus() |
|
|
|
search_view.clearFocus() |
|
|
|
|
|
|
|
search_view.setOnQueryTextListener(this) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun initDataObservers() { |
|
|
|
private fun initDataObservers() { |
|
|
@ -73,6 +74,14 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour |
|
|
|
bookSourceLiveDate?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) }) |
|
|
|
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) { |
|
|
|
override fun del(bookSource: BookSource) { |
|
|
|
GlobalScope.launch { App.db.bookSourceDao().delete(bookSource) } |
|
|
|
GlobalScope.launch { App.db.bookSourceDao().delete(bookSource) } |
|
|
|
} |
|
|
|
} |
|
|
|