|
|
@@ -30,7 +30,7 @@ import kr.co.zumo.app.lifeplus.view.IEventListener;
|
|
|
* @since 2018. 10. 15.
|
|
|
*/
|
|
|
public class MainContentsCategoryHolder extends MainContentsHolder {
|
|
|
-
|
|
|
+ private String direction = TouchEventWithDirection.DIRECTION_NONE;
|
|
|
private RecyclerView recyclerView;
|
|
|
private MainCategoryContentsAdapter adapter;
|
|
|
private TextView textView;
|
|
|
@@ -160,6 +160,8 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ TouchEventWithDirection touchEventWithDirection = new TouchEventWithDirection(50);
|
|
|
+
|
|
|
if (index == 1) {
|
|
|
recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
|
|
|
@Override
|
|
|
@@ -172,7 +174,7 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
|
|
|
* 스크롤 시킬 조건
|
|
|
* - 1번 카테고리가 화면에서 벗어나 있을 때, (아래 쪽이 잘렸을 때)
|
|
|
*/
|
|
|
- if (DIRECTION_LEFT.equals(direction) || DIRECTION_RIGHT.equals(direction)) {
|
|
|
+ if (TouchEventWithDirection.DIRECTION_LEFT.equals(direction) || TouchEventWithDirection.DIRECTION_RIGHT.equals(direction)) {
|
|
|
listener.onEvent(new Event.Builder(Event.SCROLL).index(index).build());
|
|
|
}
|
|
|
break;
|
|
|
@@ -180,7 +182,7 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- direction = getDirection(e);
|
|
|
+ direction = touchEventWithDirection.getDirection(e);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -200,55 +202,6 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
|
|
|
// recyclerView.getLayoutManager().onRestoreInstanceState(state);
|
|
|
}
|
|
|
|
|
|
- int oldX;
|
|
|
- int oldY;
|
|
|
- String direction;
|
|
|
-
|
|
|
- private static final String DIRECTION_NONE = "none";
|
|
|
- private static final String DIRECTION_UP = "up";
|
|
|
- private static final String DIRECTION_DOWN = "down";
|
|
|
- private static final String DIRECTION_RIGHT = "right";
|
|
|
- private static final String DIRECTION_LEFT = "left";
|
|
|
-
|
|
|
- private String getDirection(MotionEvent e) {
|
|
|
- String direction = DIRECTION_NONE;
|
|
|
- int action = e.getAction();
|
|
|
- switch (action) {
|
|
|
- case MotionEvent.ACTION_DOWN:
|
|
|
- oldX = (int) e.getX();
|
|
|
- oldY = (int) e.getY();
|
|
|
- break;
|
|
|
- case MotionEvent.ACTION_MOVE:
|
|
|
- int newX = (int) e.getX();
|
|
|
- int newY = (int) e.getY();
|
|
|
-
|
|
|
- int dx = oldX - newX;
|
|
|
- int dy = oldY - newY;
|
|
|
-
|
|
|
- // Use dx and dy to determine the direction of the move
|
|
|
- if (Math.abs(dx) > Math.abs(dy)) {
|
|
|
- if (dx > 0) {
|
|
|
- direction = DIRECTION_RIGHT;
|
|
|
- }
|
|
|
- else {
|
|
|
- direction = DIRECTION_LEFT;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- if (dy > 0) {
|
|
|
- direction = DIRECTION_DOWN;
|
|
|
- }
|
|
|
- else {
|
|
|
- direction = DIRECTION_UP;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- // nothing
|
|
|
- break;
|
|
|
- }
|
|
|
- return direction;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public void dispose() {
|