Cleanup models

pull/156/head
M66B 6 years ago
parent fec7c0f0f0
commit a60ded83dd

@ -67,8 +67,10 @@ public class ViewModelMessages extends ViewModel {
if (model == null || !model.args.equals(args)) {
Log.i("Creating model=" + viewType + " replace=" + (model != null));
if (model != null)
if (model != null) {
model.list.removeObservers(owner);
model.clear();
}
DB db = DB.getInstance(context);
@ -198,9 +200,11 @@ public class ViewModelMessages extends ViewModel {
private void remove(AdapterMessage.ViewType viewType) {
Model model = models.get(viewType);
if (model != null)
if (model != null) {
model.clear();
models.remove(viewType);
}
}
void observePrevNext(LifecycleOwner owner, final long id, final IPrevNext intf) {
Log.i("Observe prev/next model=" + last);

Loading…
Cancel
Save