Removed swipe left. Fixed rate us dismiss listener.
This commit is contained in:
parent
574ba29ac1
commit
04b8f0fb7a
2 changed files with 5 additions and 38 deletions
|
@ -5,8 +5,6 @@ import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v4.view.ViewCompat;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -49,7 +47,7 @@ public class DashRateUsFragment extends DashBaseFragment {
|
||||||
new PositiveButtonListener(header, subheader, positiveButton, negativeButton));
|
new PositiveButtonListener(header, subheader, positiveButton, negativeButton));
|
||||||
negativeButton.setOnClickListener(
|
negativeButton.setOnClickListener(
|
||||||
new NegativeButtonListener(header, subheader, positiveButton, negativeButton));
|
new NegativeButtonListener(header, subheader, positiveButton, negativeButton));
|
||||||
mRateUsDismissListener = new RateUsDismissListener(getParentView(), dashboard, TAG, view, settings);
|
mRateUsDismissListener = new RateUsDismissListener(dashboard, settings);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,50 +226,19 @@ public class DashRateUsFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RateUsDismissListener implements DismissListener {
|
private static class RateUsDismissListener implements DismissListener {
|
||||||
private View parentView;
|
|
||||||
private DashboardOnMap dashboardOnMap;
|
private DashboardOnMap dashboardOnMap;
|
||||||
private String fragmentTag;
|
|
||||||
private View fragmentView;
|
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private int exNumberOfRuns;
|
public RateUsDismissListener(DashboardOnMap dashboardOnMap, OsmandSettings settings) {
|
||||||
private long exLastDisplayTime;
|
|
||||||
public RateUsDismissListener(View parentView, DashboardOnMap dashboardOnMap,
|
|
||||||
String fragmentTag, View fragmentView, OsmandSettings settings) {
|
|
||||||
this.parentView = parentView;
|
|
||||||
this.dashboardOnMap = dashboardOnMap;
|
this.dashboardOnMap = dashboardOnMap;
|
||||||
this.fragmentTag = fragmentTag;
|
|
||||||
this.fragmentView = fragmentView;
|
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss() {
|
public void onDismiss() {
|
||||||
dashboardOnMap.hideFragmentByTag(fragmentTag);
|
|
||||||
ViewCompat.setTranslationX(fragmentView, 0);
|
|
||||||
ViewCompat.setAlpha(fragmentView, 1);
|
|
||||||
Snackbar.make(parentView, dashboardOnMap.getMyApplication().getResources()
|
|
||||||
.getString(R.string.shared_string_card_was_hidden), Snackbar.LENGTH_LONG)
|
|
||||||
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
RateUsDismissListener.this.onUndo(exNumberOfRuns, exLastDisplayTime);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
settings.RATE_US_STATE.set(RateUsState.IGNORED);
|
settings.RATE_US_STATE.set(RateUsState.IGNORED);
|
||||||
exNumberOfRuns = settings.NUMBER_OF_APPLICATION_STARTS.get();
|
|
||||||
settings.NUMBER_OF_APPLICATION_STARTS.set(0);
|
settings.NUMBER_OF_APPLICATION_STARTS.set(0);
|
||||||
exLastDisplayTime = settings.LAST_DISPLAY_TIME.get();
|
|
||||||
settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis());
|
settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis());
|
||||||
}
|
dashboardOnMap.refreshDashboardFragments();
|
||||||
|
|
||||||
public void onUndo(int numberOfRuns, long lastDisplayTime) {
|
|
||||||
dashboardOnMap.unhideFragmentByTag(fragmentTag);
|
|
||||||
ViewCompat.setTranslationX(fragmentView, 0);
|
|
||||||
ViewCompat.setAlpha(fragmentView, 1);
|
|
||||||
settings.NUMBER_OF_APPLICATION_STARTS.set(numberOfRuns);
|
|
||||||
settings.LAST_DISPLAY_TIME.set(lastDisplayTime);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class SwipeDismissTouchListener implements View.OnTouchListener {
|
||||||
dismiss = (velocityX < 0) == (deltaX < 0);
|
dismiss = (velocityX < 0) == (deltaX < 0);
|
||||||
dismissRight = mVelocityTracker.getXVelocity() > 0;
|
dismissRight = mVelocityTracker.getXVelocity() > 0;
|
||||||
}
|
}
|
||||||
if (dismiss) {
|
if (dismiss && dismissRight) {
|
||||||
// dismiss
|
// dismiss
|
||||||
final boolean finalDismissRight = dismissRight;
|
final boolean finalDismissRight = dismissRight;
|
||||||
ViewCompat.animate(mView)
|
ViewCompat.animate(mView)
|
||||||
|
@ -210,7 +210,7 @@ public class SwipeDismissTouchListener implements View.OnTouchListener {
|
||||||
mVelocityTracker.addMovement(motionEvent);
|
mVelocityTracker.addMovement(motionEvent);
|
||||||
float deltaX = motionEvent.getRawX() - mDownX;
|
float deltaX = motionEvent.getRawX() - mDownX;
|
||||||
float deltaY = motionEvent.getRawY() - mDownY;
|
float deltaY = motionEvent.getRawY() - mDownY;
|
||||||
if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
|
if (deltaX > mSlop && Math.abs(deltaY) < deltaX / 2) {
|
||||||
mSwiping = true;
|
mSwiping = true;
|
||||||
mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop);
|
mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop);
|
||||||
mView.getParent().requestDisallowInterceptTouchEvent(true);
|
mView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
|
|
Loading…
Reference in a new issue