Giter Club home page Giter Club logo

android-staggered-grid-demo's Introduction

Android Staggered Grid Demo

After writing a post about my first android app a reader asked me by email to share my implementation of the staggered grid view. So here it is. Keep in mind that it's NOT a library, just a quick and dirty demo.

Android 4.x screenshot

Screenshot

Android 2.x screenshot

Screenshot

So what's the difference between this demo and other existing implementations ?

Good question!, My implementation focus on:

  1. Optimizations for BIG staggered grids: under 10000 elements
  2. RAM efficiency. It is IMPOSSIBLE to run out of memory with this demo. Even with 10k+ images in the grid view.
  3. Lazy loading / unloading of images = Only images visible on screen are in memory
  4. Supports android 2.2+. Tested and runs very well on real 2.x and 4.x devices: 4. Android 2.2 | ZTE Blade ( 512 RAM | 600 MHz ARM 11 ) 5. Android 4.1 | GalaxyTab 2 10.1 ( 1G RAM | Dual-core 1 GHz Cortex-A9 )
  5. You must know aspect ratio of ALL images in your grid BEFORE you load them in order to compute scroll height. This is NOT a "pull to load" staggered grid view, it just loads while you scroll.
  6. It is NOT a library, so please read and understand the code before using it, it is very short and well commented.

Dependency #1

I am using a modified version of Android Smart Image View to load images. Long story short: android-smart-image-view has an internal cashing system that does NOT fit my usecase. The problem of the curent cashing sustem is that on old 2.x devices with weak RAM, your app will run out of memory... I found no way to disable caching, without updating android-smart-image-view library code... This is why i include it's source in this demo.

I changed changed 1 method: WebImage::getBitmap ;)

Dependency #2

Big thanks to lorempixel.com for delivering fast and awesome random images

Licence

MIT

android-staggered-grid-demo's People

Contributors

dchapkine avatar

Watchers

 avatar

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.