mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Solve bug of update
This commit is contained in:
@@ -228,8 +228,10 @@ public abstract class ListNodesActivity extends LockCloseListActivity
|
||||
if (newNode != null) {
|
||||
if (resultCode == EntryEditActivity.ADD_ENTRY_RESULT_CODE)
|
||||
mAdapter.addNode(newNode);
|
||||
if (resultCode == EntryEditActivity.UPDATE_ENTRY_RESULT_CODE)
|
||||
mAdapter.updateLastNodeRegister();
|
||||
if (resultCode == EntryEditActivity.UPDATE_ENTRY_RESULT_CODE) {
|
||||
//mAdapter.updateLastNodeRegister(newNode);
|
||||
mAdapter.rebuildList(mCurrentGroup);
|
||||
}
|
||||
} else {
|
||||
Log.e(this.getClass().getName(), "New node can be retrieve in Activity Result");
|
||||
}
|
||||
|
||||
@@ -124,12 +124,18 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
* Update the last Node register in the list
|
||||
* Work if only registerANodeToUpdate(PwNode node) is called before
|
||||
*/
|
||||
public void updateLastNodeRegister() {
|
||||
public void updateLastNodeRegister(PwNode node) {
|
||||
// Don't really update here, sorted list knows each original ref, so we just notify a change
|
||||
try {
|
||||
notifyItemChanged(nodePositionToUpdate);
|
||||
nodeSortedList.recalculatePositionOfItemAt(nodePositionToUpdate);
|
||||
nodePositionToUpdate = -1;
|
||||
if (nodePositionToUpdate != -1) {
|
||||
// Don't know why but there is a bug to remove a node after this update
|
||||
nodeSortedList.updateItemAt(nodePositionToUpdate, node);
|
||||
nodeSortedList.recalculatePositionOfItemAt(nodePositionToUpdate);
|
||||
nodePositionToUpdate = -1;
|
||||
}
|
||||
else {
|
||||
Log.e(NodeAdapter.class.getName(), "registerANodeToUpdate must be called before updateLastNodeRegister");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
Log.e(NodeAdapter.class.getName(), e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user