I'm trying this code
https://stackoverflow.com/a/14297097/1907593
is working well, but on ACTION_UP nothing happens, I would like on ACTION_UP to reset the image to the initial view (not rotated)
I'm trying this code
https://stackoverflow.com/a/14297097/1907593
is working well, but on ACTION_UP nothing happens, I would like on ACTION_UP to reset the image to the initial view (not rotated)
Put this in action up:
case MotionEvent.ACTION_UP : {
mPrevAngle = mCurrAngle = 0;
animate(mPrevAngle, mCurrAngle,0);
break;
}
I solved with this code
private double mCurrAngle = 0;
private double mPrevAngle = 0;
private long durationMillis;
case MotionEvent.ACTION_UP : {
mPrevAngle = Math.toDegrees(Math.atan2(x - xc, yc - y));
mCurrAngle = 0;
durationMillis = 1000;
animate(mPrevAngle, mCurrAngle,durationMillis);
break;
case MotionEvent.ACTION_MOVE: {
mPrevAngle = mCurrAngle;
mCurrAngle = Math.toDegrees(Math.atan2(x - xc, yc - y));
animate(mPrevAngle, mCurrAngle, 0);
if (mCurrAngle>0);{mCurrAngle = mCurrAngle-360;}
break;
now the problem is that myCurrAngle don't take a value of degree from 0 to -360 but from 0 to 180 and from -1 to -180. I'm trying to convert to 0-360 values with the code above but now I've value from -180 to -360 and from -360 to -540. My final goal is to automatic return to 0°(ACTION_UP code) when I reached -240° with ACTION_MOVE