Comments (6)
Could you explain me how to simulate the animation performed on touch but automatically when I touch a button?
from android-pagecurl.
Please Harism comment the funcation which curl automatically on a button press
from android-pagecurl.
its really urgent
from android-pagecurl.
Oh, after a large amount of search and read, I have found the method to simulate the TouchEvent and it should be available to preform the automatic animation.
I will try to add the function to the commit later when I complete this task.
from android-pagecurl.
Can you provide the function for how to auto animate the page..
from android-pagecurl.
-
Firstly, change a little bit code in onTouch() function:
public boolean onTouch(View view, MotionEvent me) {
............
case MotionEvent.ACTION_UP:
if (mCurlState == CURL_LEFT || mCurlState == CURL_RIGHT) {
// Animation source is the point from where animation starts.
// Also it's handled in a way we actually simulate touch events
// meaning the output is exactly the same as if user drags the
// page to other side. While not producing the best looking
// result (which is easier done by altering curl position and/or
// direction directly), this is done in a hope it made code a
// bit more readable and easier to maintain.
mAnimationSource.set(mPointerPos.mPos);
mAnimationStartTime = System.currentTimeMillis();// Given the explanation, here we decide whether to simulate // drag to left or right end. if ((mViewMode == SHOW_ONE_PAGE && mPointerPos.mPos.x > (rightRect.left + rightRect.right) / 2) || mViewMode == SHOW_TWO_PAGES && mPointerPos.mPos.x > rightRect.left) { // On right side target is always right page's right border. if (isAutoCurl) mDragStartPos.x = 0; mAnimationTarget.set(mDragStartPos); mAnimationTarget.x = isAutoCurl ? mRenderer.getPageRect(CurlRenderer.PAGE_LEFT).left : mRenderer.getPageRect(CurlRenderer.PAGE_RIGHT).right; mAnimationTargetEvent = isAutoCurl ? SET_CURL_TO_LEFT : SET_CURL_TO_RIGHT; } else { // On left side target depends on visible pages. if (isAutoCurl) mDragStartPos.x = rightRect.right; mAnimationTarget.set(mDragStartPos); if (mCurlState == CURL_RIGHT || mViewMode == SHOW_TWO_PAGES) { mAnimationTarget.x = isAutoCurl ? rightRect.right : leftRect.left; } else { mAnimationTarget.x = rightRect.left; } mAnimationTargetEvent = isAutoCurl ? SET_CURL_TO_RIGHT : SET_CURL_TO_LEFT; } mAnimate = true; requestRender(); } break;
...........
}
-
Then create function call curlToNextPage():
public void curlToNextPage() {
int x = getWidth();
int y = getHeight() / 2;isAutoCurl = true; MotionEvent me = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y, 0); onTouch(this, me); for (int i = 0; i < getWidth() / 5; i++) { x += i;// restamos xq vamos pa la derecha me = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, x, y, 0); onTouch(this, me); try { Thread.sleep(10L); } catch (InterruptedException e) { e.printStackTrace(); } } me = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0); onTouch(this, me); isAutoCurl = false;
}
From now on, you can use this new function to curl page automatically
from android-pagecurl.
Related Issues (20)
- location ImageView location above curlview
- [suggestion] Move the drop shadow to the bottom of the cylinder
- left to right curleffect on SHOW_ONE_PAGE Viewmode HOT 1
- How to change the bitmap images with using the Button??
- How to update current page?
- Page-curl animation does not work properly when a page turns backwards HOT 2
- onRetainCustomNonConfigurationInstance() does not override method of superclass
- Change curl pages automatically without touch HOT 1
- does it support video?
- Images Limit
- show the content when font size is changed without any delay
- Page Curl transformation for ViewPager HOT 1
- Page changed
- how to add more then 5 images HOT 1
- How to curl or turn page from right to left HOT 1
- In Two Pages ViewMode front page shows same image as it but that front page back side show reverse of 2nd image.... HOT 1
- Is the flutter plug-in supported?
- Pinch to zoom HOT 1
- implementation
- Curl layout instead of Bitmap HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-pagecurl.