Compare commits
1 commit
master
...
jump_swipe
Author | SHA1 | Date | |
---|---|---|---|
|
eaf9e83701 |
2 changed files with 74 additions and 9 deletions
|
@ -54,6 +54,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.ColorDialogs;
|
import net.osmand.plus.helpers.ColorDialogs;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
||||||
|
import net.osmand.plus.mapcontextmenu.other.OnSwipeTouchListener;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||||
import net.osmand.plus.track.ColorsCard;
|
import net.osmand.plus.track.ColorsCard;
|
||||||
|
@ -134,6 +135,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
||||||
.inflate(R.layout.point_editor_fragment_new, container, false);
|
.inflate(R.layout.point_editor_fragment_new, container, false);
|
||||||
AndroidUtils.addStatusBarPadding21v(getActivity(), view);
|
AndroidUtils.addStatusBarPadding21v(getActivity(), view);
|
||||||
|
|
||||||
|
|
||||||
final PointEditor editor = getEditor();
|
final PointEditor editor = getEditor();
|
||||||
if (editor == null) {
|
if (editor == null) {
|
||||||
return view;
|
return view;
|
||||||
|
@ -176,6 +178,13 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scrollView.setOnTouchListener(new OnSwipeTouchListener(getContext()) {
|
||||||
|
@Override
|
||||||
|
public void onSwipeLeft() {
|
||||||
|
showExitDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
final int activeColorResId = getActiveColorRes();
|
final int activeColorResId = getActiveColorRes();
|
||||||
ImageView toolbarAction = view.findViewById(R.id.toolbar_action);
|
ImageView toolbarAction = view.findViewById(R.id.toolbar_action);
|
||||||
view.findViewById(R.id.background_layout).setBackgroundResource(nightMode
|
view.findViewById(R.id.background_layout).setBackgroundResource(nightMode
|
||||||
|
@ -371,14 +380,14 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
||||||
createShapeSelector();
|
createShapeSelector();
|
||||||
updateColorSelector(selectedColor, view);
|
updateColorSelector(selectedColor, view);
|
||||||
updateShapeSelector(selectedShape, view);
|
updateShapeSelector(selectedShape, view);
|
||||||
scrollView.setOnTouchListener(new View.OnTouchListener() {
|
// scrollView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
// public boolean onTouch(View v, MotionEvent event) {
|
||||||
descriptionEdit.getParent().requestDisallowInterceptTouchEvent(false);
|
// descriptionEdit.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
descriptionEdit.setOnTouchListener(new View.OnTouchListener() {
|
descriptionEdit.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
|
||||||
|
@ -646,13 +655,19 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
||||||
iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter);
|
iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter);
|
||||||
iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||||
horizontalSelectionAdapter.notifyDataSetChanged();
|
horizontalSelectionAdapter.notifyDataSetChanged();
|
||||||
iconCategoriesRecyclerView.smoothScrollToPosition(horizontalSelectionAdapter.getItemPositionByTitle(selectedIconCategory));
|
iconCategoriesRecyclerView.scrollToPosition(horizontalSelectionAdapter.getItemPositionByTitle(selectedIconCategory));
|
||||||
for (String name : iconNameList) {
|
for (String name : iconNameList) {
|
||||||
int minimalPaddingBetweenIcon = app.getResources().getDimensionPixelSize(R.dimen.favorites_select_icon_button_right_padding);
|
int minimalPaddingBetweenIcon = app.getResources().getDimensionPixelSize(R.dimen.favorites_select_icon_button_right_padding);
|
||||||
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(minimalPaddingBetweenIcon, 0));
|
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(minimalPaddingBetweenIcon, 0));
|
||||||
selectIcon.setHorizontalAutoSpacing(true);
|
selectIcon.setHorizontalAutoSpacing(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
selectIcon.setOnTouchListener(new OnSwipeTouchListener(getContext()) {
|
||||||
|
@Override
|
||||||
|
public void onSwipeLeft() {
|
||||||
|
showExitDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createIconItemView(final String iconName, final ViewGroup rootView) {
|
private View createIconItemView(final String iconName, final ViewGroup rootView) {
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package net.osmand.plus.mapcontextmenu.other;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.GestureDetector;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class OnSwipeTouchListener implements View.OnTouchListener {
|
||||||
|
|
||||||
|
private final GestureDetector gestureDetector;
|
||||||
|
|
||||||
|
public OnSwipeTouchListener(Context context) {
|
||||||
|
gestureDetector = new GestureDetector(context, new GestureListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSwipeLeft() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSwipeRight() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
return gestureDetector.onTouchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class GestureListener extends GestureDetector.SimpleOnGestureListener {
|
||||||
|
|
||||||
|
private static final int SWIPE_DISTANCE_THRESHOLD = 100;
|
||||||
|
private static final int SWIPE_VELOCITY_THRESHOLD = 100;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onDown(MotionEvent e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||||
|
float distanceX = e2.getX() - e1.getX();
|
||||||
|
float distanceY = e2.getY() - e1.getY();
|
||||||
|
if (Math.abs(distanceX) > Math.abs(distanceY) && Math.abs(distanceX) > SWIPE_DISTANCE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
|
||||||
|
if (distanceX > 0)
|
||||||
|
onSwipeRight();
|
||||||
|
else
|
||||||
|
onSwipeLeft();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue