Switch to new Fragment "Concert Details"
This commit is contained in:
parent
22ad507745
commit
252320d07b
@ -19,26 +19,22 @@ import java.util.List;
|
||||
public class ConcertAdapter extends RecyclerView.Adapter<ConcertAdapter.ConcertViewHolder> {
|
||||
|
||||
private final List<Concert> concertList;
|
||||
private final OnConcertDeleteListener deleteListener;
|
||||
private final OnOpenConcertEditorListener editorListener;
|
||||
private final OnConcertClickListener concertClickListener;
|
||||
|
||||
public interface OnConcertDeleteListener {
|
||||
public interface OnConcertClickListener {
|
||||
void onDeleteConcert(Concert concert);
|
||||
}
|
||||
|
||||
public interface OnOpenConcertEditorListener {
|
||||
void onOpenConcertEditor(Concert concert);
|
||||
void onConcertClick(Concert concert);
|
||||
}
|
||||
|
||||
public ConcertAdapter(List<Concert> concertList, OnConcertDeleteListener deleteListener, OnOpenConcertEditorListener editorListener) {
|
||||
|
||||
public ConcertAdapter(List<Concert> concertList, OnConcertClickListener concertClickListener) {
|
||||
this.concertList = concertList;
|
||||
this.deleteListener = deleteListener;
|
||||
this.editorListener = editorListener;
|
||||
this.concertClickListener = concertClickListener;
|
||||
}
|
||||
|
||||
public ConcertAdapter(OnConcertDeleteListener deleteListener, OnOpenConcertEditorListener editorListener) {
|
||||
this.deleteListener = deleteListener;
|
||||
this.editorListener = editorListener;
|
||||
public ConcertAdapter(OnConcertClickListener onConcertClickListener) {
|
||||
this.concertClickListener = onConcertClickListener;
|
||||
this.concertList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@ -47,9 +43,9 @@ public class ConcertAdapter extends RecyclerView.Adapter<ConcertAdapter.ConcertV
|
||||
holder.concertTitleView.setText(concertList.get(position).getTitle());
|
||||
holder.dateHolder.setText(concertList.get(position).getConcertDate());
|
||||
|
||||
holder.deleteButton.setOnClickListener(v -> deleteListener.onDeleteConcert(concertList.get(position)));
|
||||
holder.editButton.setOnClickListener(v -> editorListener.onOpenConcertEditor(concertList.get(position)));
|
||||
|
||||
holder.deleteButton.setOnClickListener(v -> concertClickListener.onDeleteConcert(concertList.get(position)));
|
||||
holder.editButton.setOnClickListener(v -> concertClickListener.onOpenConcertEditor(concertList.get(position)));
|
||||
holder.itemView.setOnClickListener(v -> concertClickListener.onConcertClick(concertList.get(position)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,9 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.NavDirections;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -41,7 +44,29 @@ public class GalleryFragment extends Fragment {
|
||||
View root = binding.getRoot();
|
||||
|
||||
RecyclerView recyclerView = root.findViewById(R.id.concert_recycler_view);
|
||||
concertAdapter = new ConcertAdapter(this::deleteConcert, this::editConcert);
|
||||
concertAdapter = new ConcertAdapter(new ConcertAdapter.OnConcertClickListener() {
|
||||
@Override
|
||||
public void onDeleteConcert(Concert concert) {
|
||||
deleteConcert(concert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenConcertEditor(Concert concert) {
|
||||
editConcert(concert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConcertClick(Concert concert) {
|
||||
Log.d("GalleryFragment", "Clicked on Concert: " + concert.getTitle());
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("concertID", concert.getId());
|
||||
bundle.putString("concertTitle", concert.getTitle());
|
||||
bundle.putString("concertDate", concert.getConcertDate());
|
||||
|
||||
NavController navController = Navigation.findNavController(getActivity(), R.id.nav_host_fragment_content_main);
|
||||
navController.navigate(R.id.concertDetailFragment, bundle);
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(concertAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
package core.notevault.ui.gallery.detail;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class ConcertDetailFragment extends Fragment {
|
||||
}
|
11
app/src/main/res/layout/fragment_concert_detail.xml
Normal file
11
app/src/main/res/layout/fragment_concert_detail.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:text="TextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/textView2" tools:layout_editor_absoluteY="313dp"
|
||||
tools:layout_editor_absoluteX="372dp"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -22,4 +22,10 @@
|
||||
android:name="core.notevault.ui.slideshow.SlideshowFragment"
|
||||
android:label="@string/menu_slideshow"
|
||||
tools:layout="@layout/fragment_slideshow"/>
|
||||
<!-- Concert Detail Fragment -->
|
||||
<fragment
|
||||
android:id="@+id/concertDetailFragment"
|
||||
android:name="core.notevault.ui.gallery.detail.ConcertDetailFragment"
|
||||
android:label="Concert Details"
|
||||
tools:layout="@layout/fragment_concert_detail"/>
|
||||
</navigation>
|
Loading…
Reference in New Issue
Block a user