Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.CoordinatorLayout;
Expand All @@ -28,6 +29,7 @@
*/
public class NearbyNoificationCardView extends CardView{

private static final float MINIMUM_THRESHOLD_FOR_SWIPE = 100;
private Context context;

private Button permissionRequestButton;
Expand Down Expand Up @@ -98,13 +100,14 @@ private void setActionListeners() {
this.setOnTouchListener(
(v, event) -> {
boolean isSwipe = false;
float deltaX=0.0f;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
x1 = event.getX();
break;
case MotionEvent.ACTION_UP:
x2 = event.getX();
float deltaX = x2 - x1;
deltaX = x2 - x1;
if (deltaX < 0) {
//Right to left swipe
isSwipe = true;
Expand All @@ -114,7 +117,7 @@ private void setActionListeners() {
}
break;
}
if (isSwipe) {
if (isSwipe && (pixelToDp(Math.abs(deltaX)) > MINIMUM_THRESHOLD_FOR_SWIPE)) {
v.setVisibility(GONE);
// Save shared preference for nearby card view accordingly
((MainActivity) context).prefs.edit()
Expand All @@ -126,6 +129,10 @@ private void setActionListeners() {
});
}

private float pixelToDp(float pixels) {
return (pixels / Resources.getSystem().getDisplayMetrics().density);
}

/**
* Sets permission request button visible and content layout invisible, then adds correct
* permission request actions to permission request button according to PermissionType enum
Expand Down