Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sundeepk/asyncbackgroundviewpager

Load and display a background image to a ViewPager asynchronously, with automatic disk caching.
https://github.com/sundeepk/asyncbackgroundviewpager

Last synced: 2 months ago
JSON representation

Load and display a background image to a ViewPager asynchronously, with automatic disk caching.

Awesome Lists containing this project

README

        

AsyncBackgroundViewPager
==============

Simple way to load a large background image that spans across a ViewPager widget. Scrolling between tabs automatiacally scrolls the background for you to. It also handels disk caching so that the same images will be loaded into memory much more efficiently rather than downloading them again. It also provides a away of automatically calculating the optimal image size for you as well :). This widget makes heavy use of the [Simple Image Cache](https://github.com/SundeepK/SIC/blob/master/README.md) for code reuse. I will be commiting a version with out the SIC once it is finished.

**Layout code**

Simply define a AsyncBackgroundViewPager:

``` xml


```

``` java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button but = (Button) findViewById(R.id.buttonChangeImage);

_viewPage = (AsyncBackgroundViewPager) findViewById(R.id.viewPager);
_viewPage.setAdapter(new TestAdapter(getSupportFragmentManager()));
_viewPage.setExternalStorageDir("/storage/sdcard0/Pictures/test", 5);
try {
_viewPage.loadImage(
new URI("someurlToAImage.com/image.jpeg")
, 1, false);
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
```