Code Monkey home page Code Monkey logo

Comments (5)

eschao avatar eschao commented on June 3, 2024

I don't think we can set image during page flipping, that is because the image need to be sent to OpenGL as drawing texture ahead and OpenGL will memorize it in its cache and draw it on screen during animation.
So the only possible way I can come up with is that you can set a default image which express the loading is ongoing to OpenGL if the image has not been completed loading before animating and then set the real image after the animation is finished. Hope it is useful for you. Thanks!

from android-pageflip.

ursusursus avatar ursusursus commented on June 3, 2024

I forked your project, here is what I came up with, can you take a look at it please? https://github.com/ursusursus/android-PageFlip/blob/master/Sample/src/main/java/com/eschao/android/widget/sample/pageflip/SinglePageRender.java

Somehow this feels very brittle, the pageNo indexes in your singlepagerender dont change in "one place" but all over the code, so Im not sure if I refactored the code correctly

from android-pageflip.

eschao avatar eschao commented on June 3, 2024

Simply had a look you codes, it seems ok. But I don't know how long the following codes will take:

page.isSecondaryBitmapLoading() && LoadBitmapTask.get(mContext).getBitmap(mPageNo + 1) != null

Before you do any changes, you need to understand why my original sample codes always prepare the next or pre bitmap ahead. The major reason is that we want to provide a smooth page flipping to user and don't let user feel some delay. If you start loading next bitmap when user trigger a page flip by finger movement or other actions, you'd better set a blank or default bitmap as the first or second texture here since the loading normally need some time to finish. If you do not, in terms of your codes, I think user will feel obvious delay during page flipping. You can try and see what it will happen.

from android-pageflip.

ursusursus avatar ursusursus commented on June 3, 2024

what I tried to do in onPageChanged is to load 3 bitmaps, pageNo - 1, pageNo and pageNo + 1 ... getBitmap() just queries it from cache, if there is none, then just draws color onto canvas

from android-pageflip.

eschao avatar eschao commented on June 3, 2024

Yes, you can do like what you said. Only one thing we need to remember is that make sure the animation is smooth as could as we can whatever we do during page flipping . If some actions take too long time to make the animation smooth to user, we should consider an alternative way to eliminate it. Of course, any changes is up to your codes and your usage. Try and get a good balance for your app.

from android-pageflip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.