优化
This commit is contained in:
@@ -70,6 +70,23 @@ class RemoteBookActivity : VMBaseActivity<ActivityRemoteBookBinding, RemoteBookV
|
||||
return super.onCompatOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun finish() {
|
||||
if (viewModel.dirList.isEmpty()) {
|
||||
super.finish()
|
||||
} else {
|
||||
viewModel.dirList.removeLastOrNull()
|
||||
val remoteBook = viewModel.dirList.lastOrNull()
|
||||
viewModel.dataCallback?.clear()
|
||||
if (remoteBook != null) {
|
||||
binding.titleBar.title = remoteBook.filename
|
||||
viewModel.loadRemoteBookList(remoteBook.path)
|
||||
} else {
|
||||
binding.titleBar.setTitle(R.string.remote_book)
|
||||
viewModel.loadRemoteBookList(RemoteBookWebDav.rootBookUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun openDir(remoteBook: RemoteBook) {
|
||||
viewModel.dirList.add(remoteBook)
|
||||
binding.titleBar.title = remoteBook.filename
|
||||
|
||||
@@ -14,8 +14,8 @@ import io.legado.app.utils.ConvertUtils
|
||||
* 适配器
|
||||
* @author qianfanguojin
|
||||
*/
|
||||
class RemoteBookAdapter (context: Context, val callBack: CallBack) :
|
||||
RecyclerAdapter<RemoteBook, ItemRemoteBookBinding>(context){
|
||||
class RemoteBookAdapter(context: Context, val callBack: CallBack) :
|
||||
RecyclerAdapter<RemoteBook, ItemRemoteBookBinding>(context) {
|
||||
|
||||
override fun getViewBinding(parent: ViewGroup): ItemRemoteBookBinding {
|
||||
return ItemRemoteBookBinding.inflate(inflater, parent, false)
|
||||
@@ -47,17 +47,18 @@ class RemoteBookAdapter (context: Context, val callBack: CallBack) :
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemRemoteBookBinding) {
|
||||
|
||||
binding.btnDownload.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
if (it.isDir) {
|
||||
callBack.openDir(it)
|
||||
} else {
|
||||
callBack.addToBookshelf(it)
|
||||
}
|
||||
binding.root.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
if (it.isDir) {
|
||||
callBack.openDir(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.btnDownload.setOnClickListener {
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.addToBookshelf(it)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface CallBack {
|
||||
|
||||
Reference in New Issue
Block a user