优化发现

pull/540/head
gedoor 4 years ago
parent c9b92a896e
commit 7666095b5b
  1. 2
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowViewModel.kt
  3. 9
      app/src/main/java/io/legado/app/ui/widget/recycler/LoadMoreView.kt
  4. 5
      app/src/main/res/layout/activity_explore_show.xml
  5. 1
      app/src/main/res/layout/view_load_more.xml

@ -1,7 +1,6 @@
package io.legado.app.ui.book.explore
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
@ -37,7 +36,6 @@ class ExploreShowActivity : VMBaseActivity<ActivityExploreShowBinding, ExploreSh
private fun initRecyclerView() {
adapter = ExploreShowAdapter(this, this)
binding.recyclerView.layoutManager = LinearLayoutManager(this)
binding.recyclerView.addItemDecoration(VerticalDivider(this))
binding.recyclerView.adapter = adapter
loadMoreView = LoadMoreView(this)

@ -14,6 +14,7 @@ import kotlinx.coroutines.Dispatchers.IO
class ExploreShowViewModel(application: Application) : BaseViewModel(application) {
val booksData = MutableLiveData<List<SearchBook>>()
val errorLiveData = MutableLiveData<String>()
private var bookSource: BookSource? = null
private val variableBook = SearchBook()
private var exploreUrl: String? = null
@ -42,7 +43,7 @@ class ExploreShowViewModel(application: Application) : BaseViewModel(application
page++
}.onError {
it.printStackTrace()
toast(it.msg)
errorLiveData.postValue(it.msg)
}
}
}

@ -35,7 +35,7 @@ class LoadMoreView(context: Context, attrs: AttributeSet? = null) : FrameLayout(
binding.tvText.invisible()
binding.rotateLoading.show()
}
fun noMore(msg: String? = null) {
hasMore = false
binding.rotateLoading.hide()
@ -47,4 +47,11 @@ class LoadMoreView(context: Context, attrs: AttributeSet? = null) : FrameLayout(
binding.tvText.visible()
}
fun error(msg: String) {
hasMore = false
binding.rotateLoading.hide()
binding.tvText.text = msg
binding.tvText.visible()
}
}

@ -25,8 +25,9 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_search" />
</io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout>

@ -25,6 +25,7 @@
android:textSize="14sp"
android:background="?attr/selectableItemBackground"
android:visibility="invisible"
android:singleLine="true"
tools:text="加载状态"
tools:visibility="visible" />

Loading…
Cancel
Save