Refactoring code

This commit is contained in:
J-Jamet committed 2020-08-25 12:27:43 +02:00
1 parent a793b0bb42
commit 9cf59b8d73
4 files changed
+4 -17

No files matched your search

@@ -214,7 +214,7 @@ class EntryActivity : LockingActivity() {
registerProgressTask()
onActionTaskListener = object : AttachmentFileNotificationService.ActionTaskListener {
override fun onAttachmentAction(fileUri: Uri, entryAttachmentState: EntryAttachmentState) {
entryContentsView?.updateAttachmentDownloadProgress(entryAttachmentState)
entryContentsView?.putAttachment(entryAttachmentState)
}
}
}
@@ -311,14 +311,11 @@ class EntryEditActivity : LockingActivity(),
mAttachmentFileBinderManager?.removeAttachmentAction(entryAttachmentState)
}
AttachmentState.ERROR -> {
// TODO error
mDatabase?.removeAttachmentIfNotUsed(entryAttachmentState.entryAttachment)
mAttachmentFileBinderManager?.removeAttachmentAction(entryAttachmentState)
entryEditContentsView?.removeAttachment(entryAttachmentState)
}
else -> {
// TODO progress
}
else -> {}
}
}
}
@@ -110,16 +110,6 @@ class EntryAttachmentsItemsAdapter(context: Context)
}
}
fun updateProgress(entryAttachment: EntryAttachmentState) {
val indexEntryAttachment = itemsList.indexOfLast { current ->
current.entryAttachment == entryAttachment.entryAttachment
}
if (indexEntryAttachment != -1) {
itemsList[indexEntryAttachment] = entryAttachment
notifyItemChanged(indexEntryAttachment)
}
}
class EntryBinariesViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var binaryFileTitle: TextView = itemView.findViewById(R.id.item_attachment_title)
@@ -327,8 +327,8 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
}
}
fun updateAttachmentDownloadProgress(attachmentToDownload: EntryAttachmentState) {
attachmentsAdapter.updateProgress(attachmentToDownload)
fun putAttachment(attachmentToDownload: EntryAttachmentState) {
attachmentsAdapter.putItem(attachmentToDownload)
}
/* -------------