|
|
|
@ -12,7 +12,6 @@ import io.legado.app.base.VMBaseActivity |
|
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
|
import io.legado.app.ui.book.info.BookInfoActivity |
|
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
|
import io.legado.app.utils.gone |
|
|
|
|
import kotlinx.android.synthetic.main.activity_explore_show.* |
|
|
|
|
import kotlinx.android.synthetic.main.view_load_more.view.* |
|
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
@ -41,37 +40,21 @@ class ExploreShowActivity : VMBaseActivity<ExploreShowViewModel>(R.layout.activi |
|
|
|
|
loadMoreView = |
|
|
|
|
LayoutInflater.from(this).inflate(R.layout.view_load_more, recycler_view, false) |
|
|
|
|
adapter.addFooterView(loadMoreView) |
|
|
|
|
recycler_view.addOnScrollListener(object : RecyclerView.OnScrollListener() { |
|
|
|
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { |
|
|
|
|
super.onScrolled(recyclerView, dx, dy) |
|
|
|
|
if (!recyclerView.canScrollVertically(1)) { |
|
|
|
|
scrollToBottom() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun scrollToBottom() { |
|
|
|
|
adapter.let { |
|
|
|
|
if (it.getActualItemCount() > 0 && hasMore) { |
|
|
|
|
loadMoreView.rotate_loading.show() |
|
|
|
|
viewModel.explore() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun upData(books: List<SearchBook>) { |
|
|
|
|
if (books.isEmpty() && adapter.isEmpty()) { |
|
|
|
|
hasMore = false |
|
|
|
|
loadMoreView.rotate_loading.gone() |
|
|
|
|
loadMoreView.rotate_loading.hide(View.INVISIBLE) |
|
|
|
|
loadMoreView.tv_text.text = "空" |
|
|
|
|
} else if (books.isEmpty()) { |
|
|
|
|
hasMore = false |
|
|
|
|
loadMoreView.rotate_loading.gone() |
|
|
|
|
loadMoreView.rotate_loading.hide(View.INVISIBLE) |
|
|
|
|
loadMoreView.tv_text.text = "我是有底线的" |
|
|
|
|
} else if (adapter.getItems().contains(books.first()) && adapter.getItems().contains(books.last())) { |
|
|
|
|
hasMore = false |
|
|
|
|
loadMoreView.rotate_loading.gone() |
|
|
|
|
loadMoreView.rotate_loading.hide(View.INVISIBLE) |
|
|
|
|
loadMoreView.tv_text.text = "我是有底线的" |
|
|
|
|
} else { |
|
|
|
|
adapter.addItems(books) |
|
|
|
|