优化
This commit is contained in:
@@ -40,6 +40,7 @@ class RemoteBookActivity : VMBaseActivity<ActivityRemoteBookBinding,RemoteBookVi
|
|||||||
binding.recyclerView.layoutManager = LinearLayoutManager(this)
|
binding.recyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
binding.recyclerView.adapter = adapter
|
binding.recyclerView.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initData() {
|
private fun initData() {
|
||||||
binding.refreshProgressBar.isAutoLoading = true
|
binding.refreshProgressBar.isAutoLoading = true
|
||||||
launch {
|
launch {
|
||||||
|
|||||||
@@ -34,22 +34,22 @@ class RemoteBookAdapter (context: Context, val callBack: CallBack) :
|
|||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
binding.run {
|
binding.run {
|
||||||
//Todo:需要判断书籍是否已经加入书架,来改变“下载”按钮的文本,暂时还没有比较好的方案
|
|
||||||
tvName.text = item.filename.substringBeforeLast(".")
|
tvName.text = item.filename.substringBeforeLast(".")
|
||||||
tvContentType.text = item.contentType
|
tvContentType.text = item.contentType
|
||||||
tvSize.text = ConvertUtils.formatFileSize(item.size)
|
tvSize.text = ConvertUtils.formatFileSize(item.size)
|
||||||
tvDate.text = LocalDateTimeUtil.format(LocalDateTimeUtil.of(item.lastModify), "yyyy-MM-dd")
|
tvDate.text = LocalDateTimeUtil.format(LocalDateTimeUtil.of(item.lastModify), "yyyy-MM-dd")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun registerListener(holder: ItemViewHolder, binding: ItemRemoteBookBinding) {
|
override fun registerListener(holder: ItemViewHolder, binding: ItemRemoteBookBinding) {
|
||||||
|
|
||||||
binding.btnDownload.setOnClickListener {
|
binding.btnDownload.setOnClickListener {
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.addToBookshelf(it)
|
callBack.addToBookshelf(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CallBack {
|
interface CallBack {
|
||||||
|
|||||||
@@ -98,11 +98,12 @@
|
|||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<TextView
|
<io.legado.app.ui.widget.text.AccentStrokeTextView
|
||||||
android:id="@+id/btn_download"
|
android:id="@+id/btn_download"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
|
android:padding="8dp"
|
||||||
android:text="@string/nb_file_add_shelf"
|
android:text="@string/nb_file_add_shelf"
|
||||||
tools:text="加入书架" />
|
tools:text="加入书架" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user