|
|
@ -36,6 +36,7 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileHolder> im
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void removeKey(KeyProfile profile) {
|
|
|
|
public void removeKey(KeyProfile profile) {
|
|
|
|
|
|
|
|
profile = getKeyByID(profile.getEntry().getID());
|
|
|
|
int position = _keyProfiles.indexOf(profile);
|
|
|
|
int position = _keyProfiles.indexOf(profile);
|
|
|
|
_keyProfiles.remove(position);
|
|
|
|
_keyProfiles.remove(position);
|
|
|
|
notifyItemRemoved(position);
|
|
|
|
notifyItemRemoved(position);
|
|
|
@ -47,12 +48,16 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileHolder> im
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void replaceKey(KeyProfile newProfile) {
|
|
|
|
public void replaceKey(KeyProfile newProfile) {
|
|
|
|
for (KeyProfile oldProfile : _keyProfiles) {
|
|
|
|
KeyProfile oldProfile = getKeyByID(newProfile.getEntry().getID());
|
|
|
|
if (oldProfile.getEntry().getID() == newProfile.getEntry().getID()) {
|
|
|
|
int position = _keyProfiles.indexOf(oldProfile);
|
|
|
|
int position = _keyProfiles.indexOf(oldProfile);
|
|
|
|
_keyProfiles.set(position, newProfile);
|
|
|
|
_keyProfiles.set(position, newProfile);
|
|
|
|
notifyItemChanged(position);
|
|
|
|
notifyItemChanged(position);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
private KeyProfile getKeyByID(long id) {
|
|
|
|
|
|
|
|
for (KeyProfile profile : _keyProfiles) {
|
|
|
|
|
|
|
|
if (profile.getEntry().getID() == id) {
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new AssertionError("no key profile found with the same id");
|
|
|
|
throw new AssertionError("no key profile found with the same id");
|
|
|
|