diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-05-04 20:18:17 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-05-04 20:18:17 -0600 |
commit | 50dfc57c61a01dc20a42129246b458bf90e26154 (patch) | |
tree | 4c9e38c1fb4130b566b9393b317b7c7c104a51ba /app/src/main/java/com/example/wiimmterfaceandroid/viewmodel | |
parent | 99643e5be84af7e8da217ed48597ceb3c9d3bc85 (diff) | |
download | wiimmfi-watcher-50dfc57c61a01dc20a42129246b458bf90e26154.tar wiimmfi-watcher-50dfc57c61a01dc20a42129246b458bf90e26154.tar.gz wiimmfi-watcher-50dfc57c61a01dc20a42129246b458bf90e26154.tar.bz2 |
getting closer to implementing the recycler view
Diffstat (limited to 'app/src/main/java/com/example/wiimmterfaceandroid/viewmodel')
-rw-r--r-- | app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java b/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java index cf31868..ac039ff 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java +++ b/app/src/main/java/com/example/wiimmterfaceandroid/viewmodel/FriendCodeViewModel.java @@ -25,7 +25,7 @@ public class FriendCodeViewModel extends AndroidViewModel { public FriendCodeViewModel(Application app) { super(app); saving.setValue(false); - db = Room.databaseBuilder(app, AppDatabase.class, "fc-database").build(); + db = Room.databaseBuilder(app, AppDatabase.class, "friend-codes-db").build(); new Thread(() -> { try { Thread.sleep(1000); @@ -56,17 +56,12 @@ public class FriendCodeViewModel extends AndroidViewModel { saving.setValue(true); new Thread(() -> { if (currentEntry.getValue() != null) { - FriendCode current = currentEntry.getValue(); - current.name = name; - current.friendCode = friendCode; - db.getFriendCodeDao().update(current); - int index = entries.indexOf(current); - entries.set(index, current); + } else { FriendCode newEntry = new FriendCode(); newEntry.name = name; newEntry.friendCode = friendCode; - entries.add(newEntry); + db.getFriendCodeDao().insert(newEntry); } saving.postValue(false); |