-
Notifications
You must be signed in to change notification settings - Fork 493
Added tap speed check for example card onClick #1228
Conversation
0d16b77
to
9a8d037
Compare
analytics.clickedOnIndividualExample(getString(model.getTitle()), loggedIn); | ||
analytics.viewedScreen(getString(model.getTitle()), loggedIn); | ||
// Prevents rapid double click. | ||
if (SystemClock.elapsedRealtime() - clickTimeOfLastSelectedExample > CLICK_SPEED_THRESHOLD_MS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to me like a device-dependent way to resolve the issue. How about leveraging onPause
/onResume
to remove/add recycler click listener? Is the timing of those lifecycle callbacks correct?
9a8d037
to
1dae115
Compare
MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java
Outdated
Show resolved
Hide resolved
MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java
Outdated
Show resolved
Hide resolved
1304eae
to
d06740a
Compare
First of all, there's a bug in the Lines 34 to 43 in 3dadd83
Calling Currently, it can be worked around by removing the listener itself instead of the view:
Locally I can confirm that this resolved the issue. |
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
Log.d(TAG, "onPause: "); | ||
ItemClickSupport.removeFrom(recyclerView); | ||
itemClickSupport.setOnItemClickListener(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this enough to resolve the issue? I was testing with this invocation in onItemClicked
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Override
protected void onPause() {
super.onPause();
itemClickSupport.setOnItemClickListener(null);
}
is working 💯 for me
61e9d15
to
6678f8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
} | ||
}); | ||
itemClickSupport = ItemClickSupport.addTo(recyclerView); | ||
itemClickSupport.setOnItemClickListener(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Since we are always setting the listener in the onResume
, this is redundant.
6678f8f
to
1ff7cf2
Compare
Resolves #1227 by adding a check of the tap speed on a single example card. Right now on
master
, tapping quickly will open a duplicate activity.Before:
After: