2

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)

Community
  • 1
  • 1
lucignolo
  • 223
  • 2
  • 12

2 Answers2

1

Put this in action up:

case MotionEvent.ACTION_UP : {
            mPrevAngle = mCurrAngle = 0;
            animate(mPrevAngle, mCurrAngle,0);
            break;
        }
Guilherme Gregores
  • 1,050
  • 2
  • 10
  • 27
  • yes now is working! I try to change also 0 up to 10000 (durationMillis?) thiking to get back rotation to initial view slowly, but always image rotates back immediately – lucignolo Jan 24 '13 at 18:08
1

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

lucignolo
  • 223
  • 2
  • 12