Skip to content

Commit

Permalink
Fix drag issue on NONE mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sujithkanna committed May 31, 2017
1 parent 32273e2 commit 586a773
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions smilerating/src/main/java/com/hsalf/smilerating/SmileRating.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.util.Log;
import android.view.MotionEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.OvershootInterpolator;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -62,6 +63,7 @@ public class SmileRating extends BaseRating {
private ValueAnimator mValueAnimator = new ValueAnimator();
private FloatEvaluator mFloatEvaluator = new FloatEvaluator();
private ArgbEvaluator mColorEvaluator = new ArgbEvaluator();
private OvershootInterpolator mInterpolator = new OvershootInterpolator();
private ClickAnalyser mClickAnalyser;
private Matrix mScaleMatrix = new Matrix();
private RectF mScaleRect = new RectF();
Expand Down Expand Up @@ -311,7 +313,8 @@ protected void onDraw(Canvas canvas) {
.evaluate(mSmileyAlpha, mPlaceHolderCirclePaint.getColor(), mNormalColor));
mScaleMatrix.reset();
mSmilePath.computeBounds(mScaleRect, true);
float nonSelectedScale = mFloatEvaluator.evaluate(mSmileyAlpha, getScale(NONE), 1f);
float nonSelectedScale = mFloatEvaluator.evaluate(
mInterpolator.getInterpolation(mSmileyAlpha), getScale(NONE), 1f);
mScaleMatrix.setScale(nonSelectedScale, nonSelectedScale,
mScaleRect.centerX(), mScaleRect.centerY());
mDummyDrawPah.reset();
Expand Down Expand Up @@ -439,11 +442,14 @@ public boolean onTouchEvent(MotionEvent event) {
}

private void positionSmile() {
if (NONE == mSelectedSmile) {
return;
}
float currentPosition = mFaceCenter.x;
float distance = Integer.MAX_VALUE;
Point point = null;
@Smiley
int smile = GREAT;
int smile = NONE;
for (Integer s : mTouchPoints.keySet()) {
Point p = mTouchPoints.get(s);
float d = Math.abs(p.x - currentPosition);
Expand Down

0 comments on commit 586a773

Please sign in to comment.