0

This code will work on a phone with 2.3.5 but not on a tablet with 4.0.3:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.setContentView(R.layout.rotate_image);

    mRotator = (ImageView) findViewById(R.id.rotateImage_image_rotator);

    mGDetector = new GestureDetector(getApplicationContext(), this);

    findViewById(R.id.rotateImage_background).setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return mGDetector.onTouchEvent(event);
        }
    });
}
@Override
public boolean onDown(MotionEvent e) {
    // TODO Auto-generated method stub
    return true;
}


@Override
public boolean onFling(MotionEvent start, MotionEvent finish, float velocityX, float velocityY) {   
    return false;
}


@Override
public void onLongPress(MotionEvent e) {
    // TODO Auto-generated method stub

}


@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
        float distanceY) {
    if(e2.getHistorySize() == 0){

    }
    else{
            if(e2.getX() > e2.getHistoricalX(e2.getHistorySize() -1)){

                updateRotation(true);
            }
            else{
                updateRotation(false);
            }

        }
    return true;
}


@Override
public void onShowPress(MotionEvent e) {
    // TODO Auto-generated method stub

}


@Override
public boolean onSingleTapUp(MotionEvent e) {
    // TODO Auto-generated method stub
    return false;
}

Is there some kind of bug that tablets have or something? I mean, its the same code, it works perfectly on the phone, but it wont register on the tablet. Is it becaose of the android version, or because it is a tablet?

EDIT: To be more specific, for some reason, the function onScroll does not get called on a tablet or gets called only once, but works like a charm on a phone

M364M4N cro
  • 680
  • 2
  • 10
  • 23
  • What exactly doesn't work? As far as I see the only function is in `onScroll` the `updateRotation`?! Be aware that to get `getHistorySize` a *very* fast motion might be needed, maybe that's the problem on the tablet (if so use a log output here). – j.holetzeck May 22 '13 at 20:15
  • sorry, i should have been clearer. For some reason, on a tablet, the onScroll function does not get called or it gets called only once, while on the phone it works like a charm – M364M4N cro May 23 '13 at 08:54
  • turns out, the problem was with getHistorySize – M364M4N cro May 24 '13 at 14:00
  • Put my comment as answer so answer can be accepted – j.holetzeck May 24 '13 at 16:24

1 Answers1

1

As far as I see the only function is in onScroll the updateRotation?! Be aware that to get getHistorySize a very fast motion might be needed, maybe that's the problem on the tablet (if so use a log output here).

j.holetzeck
  • 4,048
  • 2
  • 21
  • 29
  • Tablets must work differently than phones, cuz even on a phone with android 4.1 it worked, but the problem is fixed now, thanks – M364M4N cro May 25 '13 at 12:45