Skip to content
forked from lucasr/smoothie

Easy async loading for Android's ListView/GridView

Notifications You must be signed in to change notification settings

lgx0955/smoothie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NOTE: Smoothie is currently just a draft API. Although the library is fairly funcional, this is still alpha-quality code. Do not rely on it for production code. Feedback is very welcome!

What is it?

Easy async loading for Android's ListView/GridView.

Features

  • Tiny API to implement asynchonous loading of items in Android's ListView and GridView.
  • Tight integration between user interaction and async loading of items i.e. stops loading items on fling, enables loading when panning with finger down, etc.
  • Prefetch items beyond the currently visible items to reduce the number of placeholder-type items while scrolling.

How do I use it?

  1. Add Smoothie's jar as a dependency to your project.

  2. Implement an ItemEngine. You're only required to override two methods: loadItem() and displayItem(). You can override more methods if you want to handle loading items from memory, preloading items, resetting item views, etc.

  3. On Activity/Fragment creation, attach an ItemManager instance to your ListView/GridView:

    ItemManager.Builder builder = new ItemManager.Builder(yourListOrGridView, yourItemEngine);
    builder.setPreloadItemsEnabled(true).setPreloadItemsCount(5);
    builder.setThreadPoolSize(4);
    ItemManager s = builder.build();
  4. On your adapter's getView(), call ItemManager's loadItem() passing the item view and the parameters necessary to load the item asynchronously.

The sample app has an example of an ItemEngine powered by Android-BitmapCache that fades images in as they finish loading on a ListView.

Want to help?

File new issues to discuss specific aspects of the API and to propose new features.

License

Copyright 2012 Lucas Rocha

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Easy async loading for Android's ListView/GridView

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%