Show dialog before removing download label

This commit is contained in:
FooIbar authored and tarsin committed 2023-01-11 13:24:33 +08:00
1 parent f036774e07
commit 4e8d41b145
3 files changed
+21 -9

No files matched your search

@@ -834,7 +834,9 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe
RenameLabelDialogHelper(builder, dialog, label)
}
}
holder.option.visibility = View.VISIBLE
} else {
holder.edit.visibility = View.GONE
holder.option.visibility = View.GONE
}
}
@@ -1169,16 +1171,24 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
val position = viewHolder.bindingAdapterPosition
if (mDownloadManager == null) return
lifecycleScope.launchIO {
if (position != 0) {
val label = mLabels[position]
mDownloadManager!!.deleteLabel(label)
}
mLabels.removeAt(position)
withUIContext {
mLabelAdapter!!.notifyItemRemoved(position)
}
if (position == 0) {
mLabelAdapter!!.notifyItemChanged(position)
return
}
val label = mLabels[position]
BaseDialogBuilder(context!!)
.setMessage(getString(R.string.delete_label, label))
.setPositiveButton(R.string.delete) { _, _ ->
lifecycleScope.launchIO {
mDownloadManager!!.deleteLabel(label)
mLabels.removeAt(position)
withUIContext {
mLabelAdapter!!.notifyItemRemoved(position)
}
}
}.setNegativeButton(android.R.string.cancel) { _, _ ->
mLabelAdapter!!.notifyItemChanged(position)
}.show()
}
}
@@ -306,6 +306,7 @@
<string name="label_text_is_invalid">“默认”是无效标签</string>
<string name="label_text_exist">标签已存在</string>
<string name="rename_label_title">重命名标签</string>
<string name="delete_label">删除标签“%s”?</string>
<!-- History -->
<string name="no_history">这里是阅读历史</string>
+1
View File
@@ -352,6 +352,7 @@
<string name="label_text_is_invalid">\"Default\" is an invalid label</string>
<string name="label_text_exist">Label exists</string>
<string name="rename_label_title">Rename label</string>
<string name="delete_label">Delete label \"%s\"?</string>
<!-- History -->
<string name="no_history">Viewed galleries will be shown here</string>