Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change curl pages automatically without touch #114

Open
parinparikh-nv opened this issue Aug 1, 2017 · 1 comment
Open

Change curl pages automatically without touch #114

parinparikh-nv opened this issue Aug 1, 2017 · 1 comment

Comments

@parinparikh-nv
Copy link

It works awesome which you have made.I want to do a page change with curl effect automatically without touch interaction from centre of the screen.I want to create animation like flip-book which we saw when we are kids.So here i achieved the thing which you did by touch interaction but i want this in animated way.May you please help me for this?

@vsk-pvr
Copy link

vsk-pvr commented Aug 1, 2018

 private void loadNextPageWithFlipAnimation() {
        final int[] fromXPosition = {mCurlView.getRight()};
        final int fromYPosition = mCurlView.getTop();
        final int toXPosition = mCurlView.getLeft();
        final long downTime = SystemClock.uptimeMillis();
        final long eventTime = SystemClock.uptimeMillis();
        final MotionEvent[] me = {MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, fromXPosition[0], fromYPosition, 0)};
        mCurlView.dispatchTouchEvent(me[0]);
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                MotionEvent me = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, fromXPosition[0], fromYPosition, 0);
                mCurlView.dispatchTouchEvent(me);
                fromXPosition[0] = fromXPosition[0] - 10;
                if (fromXPosition[0] > toXPosition) {
                    handler.postDelayed(this, 5);
                } else {
                    me = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, fromXPosition[0], fromYPosition, 0);
                    mCurlView.dispatchTouchEvent(me);
                }
            }
        }, 5);
    }

Create a touch even and send

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants