Skip to content

Commit

Permalink
{Fixed Typo and refactor} Fixes a typo in Interfaces.java and renames…
Browse files Browse the repository at this point in the history
… varaible in FlingAnimationUtil for better clarity
  • Loading branch information
psx95 committed Apr 20, 2018
1 parent 1c42714 commit 78239eb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
Expand Down Expand Up @@ -124,25 +128,25 @@ private void initTouchListener() {
}
if (clickOccoured) {
v.performClick();
hiddenLayoutView.overLayoutEventListener.onOverLayoutClickRecieved(v);
hiddenLayoutView.overLayoutEventListener.onOverLayoutClickReceived(v);
} else {
gestureDetector.onTouchEvent(event);
}
return true;
};
}

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);
}
}

Expand Down

0 comments on commit 78239eb

Please sign in to comment.