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 ce58354..84f798c 100644 --- a/app/src/main/java/core/notevault/ui/home/HomeFragment.java +++ b/app/src/main/java/core/notevault/ui/home/HomeFragment.java @@ -57,24 +57,18 @@ public class HomeFragment extends Fragment { return root; } - private class LoadSongTitlesTask extends AsyncTask> { + private class LoadSongTitlesTask extends AsyncTask> { @Override - protected List doInBackground(Void... voids) { + protected List doInBackground(Void... voids) { MusicDatabase db = MusicDatabase.getDatabase(getContext()); MusicNoteDAO musicNoteDAO = db.musicNoteDao(); - List songs = musicNoteDAO.getAllNotes(); - - List result = new ArrayList<>(); - for (MusicNote song : songs) { - result.add(song.getTitle()); - } - return result; + return musicNoteDAO.getAllNotes(); } @Override - protected void onPostExecute(List songTitles) { - noteSongAdapter.updateSongTitles(songTitles); // Aktualisiere den Adapter mit den Titeln + protected void onPostExecute(List songs) { + noteSongAdapter.updateSongTitles(songs); // Aktualisiere den Adapter mit den Titeln } } diff --git a/app/src/main/java/core/notevault/ui/home/NoteSongAdapter.java b/app/src/main/java/core/notevault/ui/home/NoteSongAdapter.java index 5330b92..9cb8ab9 100644 --- a/app/src/main/java/core/notevault/ui/home/NoteSongAdapter.java +++ b/app/src/main/java/core/notevault/ui/home/NoteSongAdapter.java @@ -7,15 +7,16 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import core.notevault.R; +import core.notevault.data.MusicNote; import java.util.ArrayList; import java.util.List; public class NoteSongAdapter extends RecyclerView.Adapter { - private final List noteTitles; + private final List noteTitles; - public NoteSongAdapter(List noteTitles) { + public NoteSongAdapter(List noteTitles) { this.noteTitles = noteTitles; } @@ -33,7 +34,7 @@ public class NoteSongAdapter extends RecyclerView.Adapter songTitles) { + public void updateSongTitles(List songs) { this.noteTitles.clear(); - this.noteTitles.addAll(songTitles); + this.noteTitles.addAll(songs); notifyDataSetChanged(); }