Comments (8)
FlipViewController.sideBufferSize is designed to control the number of preloaded pages. The default value is 1, which means 1 previous page, the current page and 1 next page are loaded after flipping to a page.
Unfortunately in your scenario, the lazily loaded content may not be visible during animation as the screenshot of the page was took before they're ready.
I think we may need an API to notify FlipViewController to update the screenshot on demand.
from android-flip.
Indeed.
Do you think you can make it re-use Bitmaps?
from android-flip.
@murimons I implemented a rough solution. The key idea is to use FlipViewController.refreshPage(View pageView) to make the animation reload content of an updated page.
The codes are developed in a new branch: feature/api-content-update
Please let me know if it meets your requirement. I'll merge it back to the main branch later
from android-flip.
Two new methods are added to support refreshing a page manually:
FlipViewController.refreshPage(View pageView)
FlipViewController.refreshPage(int pageIndex)
from android-flip.
Excelent!
This meets my requirement indeed!
question:
In the docs you say that for an active page this would be an expensive operation. Do you mean a page that is being viewed at that moment or flipped? So when i flip to a page which is still in the middle of lazy loading my image and when that finishes (and i'm still looking at it) , i refresh the screenshot, this would be a heavy operation? in terms of memory?
thanks!
from android-flip.
An active page is the one of which content is involved in animation. You can treat the current page and its next one be the active pages as both of them are needed to render the animation.
The refreshing routine is no more heavier than manually flipping page. It triggers the following operations for the active pages:
- Makes the page draw in a bitmap in the UI thread to get a screenshot. (The memory consumed is corresponding to the size of the page, but normally it would be fine and it doesn't trigger large GC pause as bitmap doesn't store data in VM heap.)
- Binds the bitmap to an OpenGL texture in GL thread, and recycles it.
The first step is "heavy" as it asks the page to re-draw itself, which could be a bit slow for a very complex view hierarchy.
My suggestion in the doc is a note for the potential cost. For example, if you are rendering a view animation in a page, then it better not to call refreshPage() for each frame of the animation.
from android-flip.
I understood that It doesn't store pixels in the heap but the Bitmap memory does get accounted against the heap. So if a refresh allocates a native Bitmap it also uses up the memory in the Java heap. But GC could still be fast because the Bitmap object in the heap is small. (Is GC speed related to object size?)
I'm still having issues with Bitmaps in my app causing OOM exceptions because of this (Not related to android-flip). I'm now trying to find a way to re-use Bitmap objects.
from android-flip.
The native memory occupied by bitmap instances can lead to OOM as the VM budget is constrained by the sum of heap memory and native memory.
Please check out gclog.py if you want to check the real memory usage of your app.
from android-flip.
Related Issues (20)
- Fatal signal 11 (SIGSEGV) at 0x00000123 (code=1), thread 21865 (Thread-354) HOT 2
- flipImage inside flipView
- Two different Layout throw error HOT 4
- FlipViewController contain a ScrollView ,How can i scroll ScrollVeiw to bottom? HOT 1
- Dependency
- Flash imageview when page fliping HOT 7
- Navigation drawer appears below the FlipViewController HOT 3
- Flipping first to last, from right to left, is it possible?
- cannot resolved symbol static sin? HOT 2
- Flip Animation on Click Event instead of gesture HOT 1
- next and back page using buttons HOT 1
- Compression of FlipView layouts during flipping animation HOT 2
- Using .png file HOT 1
- First and Second card show the content of the card behind it as you start to flip HOT 1
- how to add pull to refresh for FlipViewController View?
- While flipping page content flash and changed by wrong index.
- Action Bar is not visible
- API24 has no method of FloatMath
- Android Flip Available for Android Studio? HOT 3
- Image/color is brigtened when flipping
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-flip.