From 9c83707bfcaf5b66cbe4a02031978da1215e6390 Mon Sep 17 00:00:00 2001 From: Daniele Date: Tue, 7 Sep 2021 20:52:37 +0200 Subject: [PATCH] Working context menu callbacks --- .idea/misc.xml | 4 ++ .../activity/main/GeofavoriteAdapter.java | 56 +++++++++++++------ .../activity/main/MainActivity.java | 16 ++++-- 3 files changed, 56 insertions(+), 20 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 0256570..94a953d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,11 @@ diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/GeofavoriteAdapter.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/GeofavoriteAdapter.java index 1d7be0d..8dcb1c5 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/GeofavoriteAdapter.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/GeofavoriteAdapter.java @@ -23,14 +23,18 @@ package it.danieleverducci.nextcloudmaps.activity.main; import android.content.Context; import android.content.Intent; import android.text.Html; +import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; +import android.view.Menu; import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Filter; import android.widget.Filterable; import android.widget.ImageView; +import android.widget.PopupMenu; import android.widget.TextView; import androidx.annotation.NonNull; @@ -46,6 +50,8 @@ import it.danieleverducci.nextcloudmaps.model.Geofavorite; public class GeofavoriteAdapter extends RecyclerView.Adapter implements Filterable { + public static final String TAG = "GeofavoriteAdapter"; + public static final int SORT_BY_TITLE = 0; public static final int SORT_BY_CREATED = 1; @@ -56,6 +62,9 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter geofavoriteListFiltered = new ArrayList<>(); private int sortRule = SORT_BY_CREATED; + // Contains the position of the element containing the overflow menu clicked + private int overflowMenuSelectedPosition = -1; + public GeofavoriteAdapter(Context context, ItemClickListener itemClickListener) { this.context = context; this.itemClickListener = itemClickListener; @@ -143,7 +152,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter presenter.getGeofavorites());