Change containsAttachment method

This commit is contained in:
J-Jamet
2020-08-26 23:35:16 +02:00
parent e987d6647e
commit 6953da4d9a
4 changed files with 7 additions and 12 deletions

View File

@@ -339,8 +339,7 @@ class NodeAdapter (private val context: Context)
} }
holder.attachmentIcon?.visibility = holder.attachmentIcon?.visibility =
if (entry.getAttachments(mDatabase.binaryPool).isNotEmpty()) if (entry.containsAttachment()) View.VISIBLE else View.GONE
View.VISIBLE else View.GONE
mDatabase.stopManageEntry(entry) mDatabase.stopManageEntry(entry)
} }

View File

@@ -336,9 +336,9 @@ class Entry : Node, EntryVersionedInterface<Group> {
return attachments return attachments
} }
fun containsAttachment(attachment: Attachment, binaryPool: BinaryPool): Boolean { fun containsAttachment(): Boolean {
return entryKDB?.containsAttachment(attachment) == true return entryKDB?.containsAttachment() == true
|| entryKDBX?.containsAttachment(attachment, binaryPool) == true || entryKDBX?.containsAttachment() == true
} }
fun putAttachment(attachment: Attachment, binaryPool: BinaryPool) { fun putAttachment(attachment: Attachment, binaryPool: BinaryPool) {

View File

@@ -145,7 +145,7 @@ class EntryKDB : EntryVersioned<Int, UUID, GroupKDB, EntryKDB>, NodeKDBInterface
} }
} }
fun containsAttachment(attachment: Attachment): Boolean { fun containsAttachment(): Boolean {
return binaryData != null return binaryData != null
} }

View File

@@ -293,12 +293,8 @@ class EntryKDBX : EntryVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInte
return entryAttachmentList return entryAttachmentList
} }
fun containsAttachment(attachment: Attachment, binaryPool: BinaryPool): Boolean { fun containsAttachment(): Boolean {
for ((_, poolId) in binaries) { return binaries.isNotEmpty()
if (binaryPool[poolId] == attachment.binaryAttachment)
return true
}
return false
} }
fun putAttachment(attachment: Attachment, binaryPool: BinaryPool) { fun putAttachment(attachment: Attachment, binaryPool: BinaryPool) {