WIP list context menu
This commit is contained in:
parent
e89ce8e7da
commit
bac3639c3f
@ -23,7 +23,9 @@ package it.danieleverducci.nextcloudmaps.activity.main;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
import android.view.ContextMenu;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
@ -141,7 +143,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GeofavoriteViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
class GeofavoriteViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnCreateContextMenuListener {
|
||||||
TextView tv_title, tv_content;
|
TextView tv_title, tv_content;
|
||||||
ImageView bt_context_menu;
|
ImageView bt_context_menu;
|
||||||
ImageView bt_share;
|
ImageView bt_share;
|
||||||
@ -178,6 +180,12 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
|||||||
itemClickListener.onItemClick(view, getAdapterPosition());
|
itemClickListener.onItemClick(view, getAdapterPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||||
|
MenuInflater menuInflater = new MenuInflater(context);
|
||||||
|
menuInflater.inflate(R.menu.list_context_menu, menu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performSort() {
|
private void performSort() {
|
||||||
@ -189,6 +197,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openContextMenu(View v) {
|
private void openContextMenu(View v) {
|
||||||
|
v.showContextMenu();
|
||||||
//.showContextMenuForChild(v);
|
//.showContextMenuForChild(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
|
|||||||
|
|
||||||
private MainPresenter presenter;
|
private MainPresenter presenter;
|
||||||
private GeofavoriteAdapter geofavoriteAdapter;
|
private GeofavoriteAdapter geofavoriteAdapter;
|
||||||
private ItemClickListener itemClickListener;
|
private ItemClickListener rvItemClickListener;
|
||||||
|
|
||||||
NavigationAdapter navigationCommonAdapter;
|
NavigationAdapter navigationCommonAdapter;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
|
|||||||
|
|
||||||
presenter = new MainPresenter(this);
|
presenter = new MainPresenter(this);
|
||||||
|
|
||||||
itemClickListener = new ItemClickListener() {
|
rvItemClickListener = new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(View view, int position) {
|
public void onItemClick(View view, int position) {
|
||||||
Geofavorite geofavorite = geofavoriteAdapter.get(position);
|
Geofavorite geofavorite = geofavoriteAdapter.get(position);
|
||||||
@ -127,11 +127,12 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
geofavoriteAdapter = new GeofavoriteAdapter(getApplicationContext(), itemClickListener);
|
geofavoriteAdapter = new GeofavoriteAdapter(getApplicationContext(), rvItemClickListener);
|
||||||
recyclerView.setAdapter(geofavoriteAdapter);
|
recyclerView.setAdapter(geofavoriteAdapter);
|
||||||
|
|
||||||
geofavoriteAdapter.setSortRule(sortRule);
|
geofavoriteAdapter.setSortRule(sortRule);
|
||||||
|
|
||||||
|
registerForContextMenu(recyclerView);
|
||||||
|
|
||||||
swipeRefresh = findViewById(R.id.swipe_refresh);
|
swipeRefresh = findViewById(R.id.swipe_refresh);
|
||||||
swipeRefresh.setOnRefreshListener(() -> presenter.getGeofavorites());
|
swipeRefresh.setOnRefreshListener(() -> presenter.getGeofavorites());
|
||||||
|
|
||||||
|
12
app/src/main/res/menu/list_context_menu.xml
Normal file
12
app/src/main/res/menu/list_context_menu.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<!-- Detail button -->
|
||||||
|
<item
|
||||||
|
android:id="@+id/list_context_menu_detail"
|
||||||
|
android:title="@string/list_context_menu_detail"/>
|
||||||
|
<!-- Delete button -->
|
||||||
|
<item
|
||||||
|
android:id="@+id/list_context_menu_delete"
|
||||||
|
android:title="@string/list_context_menu_delete"/>
|
||||||
|
</menu>
|
@ -31,6 +31,8 @@
|
|||||||
<string name="search_in_all">Search by name</string>
|
<string name="search_in_all">Search by name</string>
|
||||||
<string name="share_via">Share via</string>
|
<string name="share_via">Share via</string>
|
||||||
<string name="share_message">Check out this place: {lat}°N, {lng}°E</string>
|
<string name="share_message">Check out this place: {lat}°N, {lng}°E</string>
|
||||||
|
<string name="list_context_menu_detail">Details</string>
|
||||||
|
<string name="list_context_menu_delete">Delete</string>
|
||||||
|
|
||||||
<!-- Sort dialog -->
|
<!-- Sort dialog -->
|
||||||
<string name="sort_by">Sort by</string>
|
<string name="sort_by">Sort by</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user