Attempt to view notes
This commit is contained in:
parent
d3b94fdcb3
commit
d3d1f482a8
@ -0,0 +1,27 @@
|
||||
package core.notevault.ui.home;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ImageView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import core.notevault.R;
|
||||
|
||||
public class FullScreenImageActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_full_screen_image); // Erstelle eine Layout-Datei
|
||||
|
||||
ImageView imageView = findViewById(R.id.fullscreen_image_view); // Angenommen, du hast ein ImageView
|
||||
|
||||
// Die URI aus dem Intent erhalten
|
||||
Intent intent = getIntent();
|
||||
String imageUriString = intent.getStringExtra("imageUri");
|
||||
if (imageUriString != null) {
|
||||
Uri imageUri = Uri.parse(imageUriString);
|
||||
imageView.setImageURI(imageUri); // Setze die URI in das ImageView
|
||||
}
|
||||
}
|
||||
}
|
@ -49,7 +49,6 @@ public class HomeFragment extends Fragment {
|
||||
|
||||
RecyclerView recyclerView = root.findViewById(R.id.note_recycler_view);
|
||||
noteSongAdapter = new NoteSongAdapter();
|
||||
recyclerView.setAdapter(noteSongAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
new LoadSongTitlesTask().execute();
|
||||
@ -57,23 +56,17 @@ public class HomeFragment extends Fragment {
|
||||
return root;
|
||||
}
|
||||
|
||||
private class LoadSongTitlesTask extends AsyncTask<Void, Void, List<String>> {
|
||||
private class LoadSongTitlesTask extends AsyncTask<Void, Void, List<MusicNote>> {
|
||||
|
||||
@Override
|
||||
protected List<String> doInBackground(Void... voids) {
|
||||
protected List<MusicNote> doInBackground(Void... voids) {
|
||||
MusicDatabase db = MusicDatabase.getDatabase(getContext());
|
||||
MusicNoteDAO musicNoteDAO = db.musicNoteDao();
|
||||
List<MusicNote> songs = musicNoteDAO.getAllNotes();
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
for (MusicNote song : songs) {
|
||||
result.add(song.getTitle());
|
||||
}
|
||||
return result;
|
||||
return musicNoteDAO.getAllNotes();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<String> songTitles) {
|
||||
protected void onPostExecute(List<MusicNote> songTitles) {
|
||||
noteSongAdapter.updateSongTitles(songTitles); // Aktualisiere den Adapter mit den Titeln
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package core.notevault.ui.home;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -7,15 +8,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<NoteSongAdapter.NoteViewHolder> {
|
||||
|
||||
private final List<String> noteTitles;
|
||||
private List<MusicNote> noteTitles;
|
||||
|
||||
public NoteSongAdapter(List<String> noteTitles) {
|
||||
public NoteSongAdapter(List<MusicNote> noteTitles) {
|
||||
this.noteTitles = noteTitles;
|
||||
}
|
||||
|
||||
@ -33,7 +35,7 @@ public class NoteSongAdapter extends RecyclerView.Adapter<NoteSongAdapter.NoteVi
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull NoteViewHolder holder, int position) {
|
||||
holder.titleTextView.setText(noteTitles.get(position));
|
||||
holder.titleTextView.setText(noteTitles.get(position).getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,18 +43,29 @@ public class NoteSongAdapter extends RecyclerView.Adapter<NoteSongAdapter.NoteVi
|
||||
return noteTitles.size();
|
||||
}
|
||||
|
||||
public void updateSongTitles(List<String> songTitles) {
|
||||
public void updateSongTitles(List<MusicNote> songTitles) {
|
||||
this.noteTitles.clear();
|
||||
this.noteTitles.addAll(songTitles);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
static class NoteViewHolder extends RecyclerView.ViewHolder {
|
||||
public class NoteViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView titleTextView;
|
||||
|
||||
NoteViewHolder(View itemView) {
|
||||
public NoteViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
titleTextView = itemView.findViewById(R.id.note_title);
|
||||
|
||||
titleTextView.setOnClickListener(v -> {
|
||||
int position = getAdapterPosition();
|
||||
if(position != RecyclerView.NO_POSITION) {
|
||||
MusicNote song = noteTitles.get(position);
|
||||
|
||||
Intent intent = new Intent(itemView.getContext(), FullScreenImageActivity.class);
|
||||
intent.putExtra("imageUri", song.getFilePath());
|
||||
itemView.getContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
app/src/main/res/layout/activity_full_screen_image.xml
Normal file
12
app/src/main/res/layout/activity_full_screen_image.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/fullscreen_image_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitCenter" /> <!-- Optional: fitCenter, centerCrop, etc. -->
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user