diff --git a/app/src/main/java/core/notevault/MainActivity.java b/app/src/main/java/core/notevault/MainActivity.java index d15ea25..d8fe049 100644 --- a/app/src/main/java/core/notevault/MainActivity.java +++ b/app/src/main/java/core/notevault/MainActivity.java @@ -294,5 +294,15 @@ public class MainActivity extends AppCompatActivity implements MetaDataDialog.On musicDB.musicNoteDao().updateSong(updatedSong); Log.d("MainActivity", "Updated Song: " + updatedSong.getTitle()); }).start(); + NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment_content_main); + Fragment currentFragment = navHostFragment != null ? navHostFragment.getChildFragmentManager().getFragments().get(0) : null; + + if(currentFragment instanceof HomeFragment) { + HomeFragment homeFragment = (HomeFragment) currentFragment; + homeFragment.updateSong(updatedSong); + } else if(currentFragment instanceof GalleryFragment) { + GalleryFragment galleryFragment = (GalleryFragment) currentFragment; + + } } } \ No newline at end of file diff --git a/app/src/main/java/core/notevault/ui/home/HomeFragment.java b/app/src/main/java/core/notevault/ui/home/HomeFragment.java index f749deb..3718a48 100644 --- a/app/src/main/java/core/notevault/ui/home/HomeFragment.java +++ b/app/src/main/java/core/notevault/ui/home/HomeFragment.java @@ -151,4 +151,8 @@ public class HomeFragment extends Fragment { public void addSong(MusicNote musicNote) { this.homeViewModel.addSong(musicNote); } + + public void updateSong(MusicNote song) { + this.homeViewModel.updateSong(song); + } } \ No newline at end of file diff --git a/app/src/main/java/core/notevault/ui/home/HomeViewModel.java b/app/src/main/java/core/notevault/ui/home/HomeViewModel.java index c668877..bb58cca 100644 --- a/app/src/main/java/core/notevault/ui/home/HomeViewModel.java +++ b/app/src/main/java/core/notevault/ui/home/HomeViewModel.java @@ -47,4 +47,17 @@ public class HomeViewModel extends ViewModel { noteTitles.setValue(currentSongs); } } + + public void updateSong(MusicNote updatedSong) { + List currentSongs = noteTitles.getValue(); + if(currentSongs != null) { + for(int i=0; i