Fix remove entry for databaseV1

This commit is contained in:
J-Jamet
2019-08-19 15:17:00 +02:00
parent b22333fda5
commit 94e5988794
4 changed files with 17 additions and 16 deletions

View File

@@ -258,7 +258,7 @@ class NodeAdapter
if (subNode.type == Type.GROUP) {
if (showNumberEntries) {
holder.numberChildren?.apply {
text = (subNode as GroupVersioned).getChildEntries().size.toString()
text = (subNode as GroupVersioned).getChildEntries(true).size.toString()
textSize = infoTextSize
visibility = View.VISIBLE
}

View File

@@ -304,14 +304,12 @@ class Database {
val searchResult = search(query, SearchDbHelper.MAX_SEARCH_ENTRY)
if (searchResult != null) {
for (entry in searchResult.getChildEntries()) {
if (!entry.isMetaStream) { // TODO metastream
entry.pwEntryV3?.let {
cursorV3?.addEntry(it)
}
entry.pwEntryV4?.let {
cursorV4?.addEntry(it)
}
for (entry in searchResult.getChildEntries(true)) {
entry.pwEntryV3?.let {
cursorV3?.addEntry(it)
}
entry.pwEntryV4?.let {
cursorV4?.addEntry(it)
}
}
}

View File

@@ -179,10 +179,16 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
}
override fun getChildEntries(): MutableList<EntryVersioned> {
return getChildEntries(false)
}
fun getChildEntries(withoutMetaStream: Boolean): MutableList<EntryVersioned> {
val children = ArrayList<EntryVersioned>()
pwGroupV3?.getChildEntries()?.forEach {
children.add(EntryVersioned(it))
val entryToAddAsChild = EntryVersioned(it)
if (!withoutMetaStream || (withoutMetaStream && !entryToAddAsChild.isMetaStream))
children.add(entryToAddAsChild)
}
pwGroupV4?.getChildEntries()?.forEach {
children.add(EntryVersioned(it))
@@ -200,14 +206,11 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
children.addAll(getChildGroups())
pwGroupV3?.let {
if (withoutMetaStream)
children.addAll(getChildEntries().filter { !it.isMetaStream })
else
children.addAll(getChildEntries())
children.addAll(getChildEntries(withoutMetaStream))
}
pwGroupV4?.let {
// No MetasStream in V4
children.addAll(getChildEntries())
children.addAll(getChildEntries(withoutMetaStream))
}
return children

View File

@@ -4,7 +4,7 @@ interface NodeVersioned: PwNodeInterface<GroupVersioned> {
val nodePositionInParent: Int
get() {
parent?.getChildren(false)?.let { children ->
parent?.getChildren(true)?.let { children ->
for ((i, child) in children.withIndex()) {
if (child == this)
return i