Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/angeloavv/recyclerviewflipper
A custom ViewFlipper to dinamically add views at runtime without render-loss time
https://github.com/angeloavv/recyclerviewflipper
Last synced: about 2 months ago
JSON representation
A custom ViewFlipper to dinamically add views at runtime without render-loss time
- Host: GitHub
- URL: https://github.com/angeloavv/recyclerviewflipper
- Owner: AngeloAvv
- Created: 2015-06-04T18:03:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-09T17:54:04.000Z (almost 6 years ago)
- Last Synced: 2024-05-21T06:32:09.715Z (7 months ago)
- Language: Java
- Size: 250 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RecyclerViewFlipper
A custom ViewFlipper to dinamically add views at runtime without render-loss timeThe RecyclerViewFlipper is a Custom ViewFlipper that allows you to scroll between an infinite number of Views without render-loss time. The component stores a double-ended queue (deque) in order to pre-load the views that need to be shown. In this way, you could dinamically add an infinite (we suppose to!) odd number of views without wasting your time in pre-rendering phases while scrolling.
The RecyclerViewFlipper also supports animations as its superclass ViewFlipper, and distorts the way of seeing the views since they are handled as a stack, but stored as a deque.
This library also avoids OutOfMemory errors due to a lot of views loaded inside the ViewFlipper, because in this case the views are added at runtime with a fixed number of loaded views per time.## How to use it
In your layout:
and in your Java file:
View firstView = View.inflate(this, FIRST_VIEW, null);
View secondView = View.inflate(this, SECOND_VIEW, null);
View thirdView = View.inflate(this, THIRD_VIEW, null);ArrayList views = new ArrayList<>();
views.add(firstView);
views.add(secondView);
views.add(thirdView);mRecyclerViewFlipper = (RecyclerViewFlipper) findViewById(ID_VIEWFLIPPER);
mRecyclerViewFlipper.initializeComponents(views);
mRecyclerViewFlipper.setRecycleViewFlipperRequest(this);your activity must implement
RecyclerViewFlipperRequest\
, where T could be a class that inherits from View and these two methods deal the runtime generation of the dynamic view@Override
public View requestLeftItem() {
View newView = View.inflate(this, SECOND_VIEW, null);
Button btn = (Button) newView.findViewById(R.id.btn);
btn.setText(String.valueOf(mCounter++));
return newView;
}@Override
public View requestRightItem() {
View newView = View.inflate(this, SECOND_VIEW, null);
Button btn = (Button) newView.findViewById(R.id.btn);
btn.setText(String.valueOf(mCounter--));
return newView;
}In this example I've inflated the same view changing the content of the button, but you can do it in very different ways, like putting it inside a Stack while you process it and so on.
Keep in mind that the preprocessing deque is defined when you callmRecyclerViewFlipper.initializeComponents(views);
the queue will keep a number of K views per time, where K is the size of the ListIf you want to see an example of the library in action, please [watch a demo here](https://youtu.be/jqfqNujkTfo)