From 9cf59b8d7331f7af65a550e9001a628afd97fac4 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Tue, 25 Aug 2020 12:27:43 +0200 Subject: [PATCH] Refactoring code --- .../com/kunzisoft/keepass/activities/EntryActivity.kt | 2 +- .../kunzisoft/keepass/activities/EntryEditActivity.kt | 5 +---- .../keepass/adapters/EntryAttachmentsItemsAdapter.kt | 10 ---------- .../com/kunzisoft/keepass/view/EntryContentsView.kt | 4 ++-- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt index eef8fe978..c3b03ba40 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt @@ -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) } } } diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/EntryEditActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/EntryEditActivity.kt index 4d082b2f5..b0abb3db1 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/EntryEditActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/EntryEditActivity.kt @@ -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 -> {} } } } diff --git a/app/src/main/java/com/kunzisoft/keepass/adapters/EntryAttachmentsItemsAdapter.kt b/app/src/main/java/com/kunzisoft/keepass/adapters/EntryAttachmentsItemsAdapter.kt index e432bc43c..257223e09 100644 --- a/app/src/main/java/com/kunzisoft/keepass/adapters/EntryAttachmentsItemsAdapter.kt +++ b/app/src/main/java/com/kunzisoft/keepass/adapters/EntryAttachmentsItemsAdapter.kt @@ -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) diff --git a/app/src/main/java/com/kunzisoft/keepass/view/EntryContentsView.kt b/app/src/main/java/com/kunzisoft/keepass/view/EntryContentsView.kt index 5c068ef06..86e37f473 100644 --- a/app/src/main/java/com/kunzisoft/keepass/view/EntryContentsView.kt +++ b/app/src/main/java/com/kunzisoft/keepass/view/EntryContentsView.kt @@ -327,8 +327,8 @@ class EntryContentsView @JvmOverloads constructor(context: Context, } } - fun updateAttachmentDownloadProgress(attachmentToDownload: EntryAttachmentState) { - attachmentsAdapter.updateProgress(attachmentToDownload) + fun putAttachment(attachmentToDownload: EntryAttachmentState) { + attachmentsAdapter.putItem(attachmentToDownload) } /* -------------