diff --git a/app/src/main/java/com/psx/hiddedlinearlayout/DragWithSpringActivity.java b/app/src/main/java/com/psx/hiddedlinearlayout/DragWithSpringActivity.java index 1004532..260fb90 100644 --- a/app/src/main/java/com/psx/hiddedlinearlayout/DragWithSpringActivity.java +++ b/app/src/main/java/com/psx/hiddedlinearlayout/DragWithSpringActivity.java @@ -32,7 +32,7 @@ private void setupListnersOnViews() { hiddenLayoutView.setOverLayoutEventListener(view -> Toast.makeText(getApplicationContext(),"Pressed Revealed View "+view.getId(),Toast.LENGTH_SHORT).show()); hiddenLayoutView.setUnderLayoutEventListener(new AnimationUpdateListeners.UnderLayoutEventListener() { @Override - public void onUnderLayoutClickRecieved(View view) { + public void onUnderLayoutClickReceived(View view) { Toast.makeText(getApplicationContext(),"Pressed View hidden "+view.getId(),Toast.LENGTH_SHORT).show(); hiddenLayoutView.closeRightHiddenView(); } diff --git a/app/src/main/java/com/psx/hiddedlinearlayout/FlingActivity.java b/app/src/main/java/com/psx/hiddedlinearlayout/FlingActivity.java index c077c49..079f654 100644 --- a/app/src/main/java/com/psx/hiddedlinearlayout/FlingActivity.java +++ b/app/src/main/java/com/psx/hiddedlinearlayout/FlingActivity.java @@ -24,7 +24,7 @@ private void setupHiddenFlingView() { hiddenLayoutView.setOverLayoutEventListener(view -> Toast.makeText(getApplicationContext(),"Pressed Revealed View "+view.getId(),Toast.LENGTH_SHORT).show()); hiddenLayoutView.setUnderLayoutEventListener(new AnimationUpdateListeners.UnderLayoutEventListener() { @Override - public void onUnderLayoutClickRecieved(View view) { + public void onUnderLayoutClickReceived(View view) { Toast.makeText(getApplicationContext(),"Pressed View hidden "+view.getId(),Toast.LENGTH_SHORT).show(); hiddenLayoutView.closeRightHiddenView(); } diff --git a/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/HiddenLayoutView.java b/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/HiddenLayoutView.java index feebdb1..6507fa9 100644 --- a/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/HiddenLayoutView.java +++ b/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/HiddenLayoutView.java @@ -80,8 +80,8 @@ private void setupListeners() { }; overLayoutEventListener = view -> { }; - inflatedUnderLayout.setOnClickListener(v -> underLayoutEventListener.onUnderLayoutClickRecieved(v)); - inflatedOverLayout.setOnClickListener(v -> overLayoutEventListener.onOverLayoutClickRecieved(v)); + inflatedUnderLayout.setOnClickListener(v -> underLayoutEventListener.onUnderLayoutClickReceived(v)); + inflatedOverLayout.setOnClickListener(v -> overLayoutEventListener.onOverLayoutClickReceived(v)); } private void initListeners() { diff --git a/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/Interfaces/AnimationUpdateListeners.java b/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/Interfaces/AnimationUpdateListeners.java index 3fd1bb1..c896196 100644 --- a/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/Interfaces/AnimationUpdateListeners.java +++ b/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/Interfaces/AnimationUpdateListeners.java @@ -8,11 +8,11 @@ public interface AnimationUpdateListeners { interface OverLayoutEventListener { - void onOverLayoutClickRecieved(View view); + void onOverLayoutClickReceived(View view); } interface UnderLayoutEventListener { - void onUnderLayoutClickRecieved(View view); + void onUnderLayoutClickReceived(View view); } void onMaxSpringPull(); diff --git a/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/Utilities/FlingAnimationUtil.java b/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/Utilities/FlingAnimationUtil.java index 4556dfa..dc39fd9 100644 --- a/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/Utilities/FlingAnimationUtil.java +++ b/hiddenlinearlayoutview/src/main/java/com/psx/hiddenlinearlayoutview/Utilities/FlingAnimationUtil.java @@ -56,19 +56,19 @@ private void setSpeedForReverseAnimation() { Log.d(TAG, "pixels per second " + reverseAnimationStartVelocity + " \n pixels revealed " + pixelsRevealed); } - private void createFlingAnimationForHome(View v) { - flingAnimation = new FlingAnimation(v, DynamicAnimation.TRANSLATION_X) + private void createFlingAnimationForHome(View inflatedOverLayout) { + flingAnimation = new FlingAnimation(inflatedOverLayout, DynamicAnimation.TRANSLATION_X) .setFriction(friction) .setMinValue(-displayMetrics.widthPixels * minValue) .setMaxValue(0); - reverseFlingAnimation = new FlingAnimation(v, DynamicAnimation.TRANSLATION_X) + reverseFlingAnimation = new FlingAnimation(inflatedOverLayout, DynamicAnimation.TRANSLATION_X) .setFriction(frictionForReverseFling) .setMinValue(-displayMetrics.widthPixels * minValue) .setMaxValue(0) .setStartVelocity(reverseAnimationStartVelocity); gestureDetector = new GestureDetector(activityContext, prepareGestureDetectorListener()); initTouchListener(); - setTouchListenerOnView(v); + setTouchListenerOnView(inflatedOverLayout); } private void initTouchListener() { @@ -80,6 +80,10 @@ private void initTouchListener() { clickStart = Calendar.getInstance().getTimeInMillis(); pressedX = event.getX(); pressedY = event.getY(); + if (flingAnimation!=null) + flingAnimation.cancel(); + else if (reverseFlingAnimation!=null) + reverseFlingAnimation.cancel(); velocityTracker = VelocityTracker.obtain(); velocityTracker.addMovement(event); return true; @@ -124,7 +128,7 @@ private void initTouchListener() { } if (clickOccoured) { v.performClick(); - hiddenLayoutView.overLayoutEventListener.onOverLayoutClickRecieved(v); + hiddenLayoutView.overLayoutEventListener.onOverLayoutClickReceived(v); } else { gestureDetector.onTouchEvent(event); } @@ -132,17 +136,17 @@ private void initTouchListener() { }; } - private void setTouchListenerOnView(View v) { - if (v instanceof ViewGroup) { + private void setTouchListenerOnView(View inflatedOverLayout) { + if (inflatedOverLayout instanceof ViewGroup) { Log.d(TAG, "FOUND multiple children inside view"); - for (int i = 0; i < ((ViewGroup) v).getChildCount(); i++) { - View childView = ((ViewGroup) v).getChildAt(i); + for (int i = 0; i < ((ViewGroup) inflatedOverLayout).getChildCount(); i++) { + View childView = ((ViewGroup) inflatedOverLayout).getChildAt(i); childView.setOnTouchListener(onTouchListener); Log.d(TAG, " ID " + childView.getId() + " found at pos " + i); } } else { Log.d(TAG, "No Child views"); - v.setOnTouchListener(onTouchListener); + inflatedOverLayout.setOnTouchListener(onTouchListener); } }