aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-04-07 15:22:22 +0200
committerSamuel Tardieu <sam@rfc1149.net>2014-04-07 15:40:11 +0200
commit2b2269c2e9a00580280b5bb95c4f238c515c8411 (patch)
treeb57842fef06dc3cfcfc6df72ad7135438e7a01f8 /main/src/cgeo/geocaching/ui
parent97b1702b841653a0b158adfcce848c7590830052 (diff)
downloadcgeo-2b2269c2e9a00580280b5bb95c4f238c515c8411.zip
cgeo-2b2269c2e9a00580280b5bb95c4f238c515c8411.tar.gz
cgeo-2b2269c2e9a00580280b5bb95c4f238c515c8411.tar.bz2
fix #3739: long click in list also triggers short click
Diffstat (limited to 'main/src/cgeo/geocaching/ui')
-rw-r--r--main/src/cgeo/geocaching/ui/CacheListAdapter.java39
1 files changed, 14 insertions, 25 deletions
diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
index ca4e825..254749e 100644
--- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java
+++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
@@ -379,6 +379,7 @@ public class CacheListAdapter extends ArrayAdapter<Geocache> {
final TouchListener touchListener = new TouchListener(cache, v);
v.setOnClickListener(touchListener);
+ v.setOnLongClickListener(touchListener);
v.setOnTouchListener(touchListener);
holder.checkbox.setVisibility(selectMode ? View.VISIBLE : View.GONE);
@@ -535,11 +536,10 @@ public class CacheListAdapter extends ArrayAdapter<Geocache> {
}
}
- private class TouchListener implements View.OnClickListener, View.OnTouchListener {
+ private class TouchListener implements View.OnClickListener, View.OnLongClickListener, View.OnTouchListener {
- private boolean touch = true;
- private final GestureDetector gestureDetector;
private final Geocache cache;
+ private final GestureDetector gestureDetector;
public TouchListener(final Geocache cache, final View view) {
this.cache = cache;
@@ -547,33 +547,28 @@ public class CacheListAdapter extends ArrayAdapter<Geocache> {
gestureDetector = new GestureDetector(getContext(), dGesture);
}
- // tap on item
@Override
- public void onClick(View view) {
- if (!touch) {
- touch = true;
- return;
- }
-
+ public void onClick(final View view) {
if (isSelectMode()) {
cache.setStatusChecked(!cache.isStatusChecked());
notifyDataSetChanged();
- return;
+ } else {
+ CacheDetailActivity.startActivity(getContext(), cache.getGeocode(), cache.getName());
}
+ }
- // load cache details
- CacheDetailActivity.startActivity(getContext(), cache.getGeocode(), cache.getName());
+ // long tap on item
+ @Override
+ public boolean onLongClick(final View view) {
+ view.showContextMenu();
+ return true;
}
// swipe on item
@Override
- public boolean onTouch(View view, MotionEvent event) {
- if (gestureDetector.onTouchEvent(event)) {
- touch = false;
- return true;
- }
+ public boolean onTouch(final View view, final MotionEvent event) {
+ return gestureDetector.onTouchEvent(event);
- return false;
}
}
@@ -587,12 +582,6 @@ public class CacheListAdapter extends ArrayAdapter<Geocache> {
this.view = view;
}
- // long tap on item
- @Override
- public void onLongPress(MotionEvent e) {
- view.showContextMenu();
- }
-
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {