GithubHelp home page GithubHelp logo

customlistviewdemo's Introduction

CustomListViewDemo

Demo the use of ListView with List Row data having a mixed of text and image.

Learning Objective

I want to do it the raw way without using any third party-libraries for image downloading to drive home some lessons on how ListView works. See Lessons Learned section for more on what I observed/learned.

Tools Used For Image Download

Each branch-name of this project repository represents the Image Download Library used in that respective branch to solve the said problem

  • Barebones without any Image Download Library: The source code for this is in the main branch of this repository. We did use okHttp for HTTP connections though.
  • Volley. Instead of building the jar from the project, you can simple download the jar directly from AndroidHive's website. I DID NOT USE THIS AS MY LEARNING OBJECTIVE CHANGED (see section above).
  • Picasso. Uber cool library with fluent interfaces makes the life of a developer so comfortable. Thank you Square.

Lessons Learned

  • ListView adaptor's getView() like crazy. It's out-rightly unpredictable. Thank you google for making thedeveloper's life hell :(
  • Writing a custom ListView adaptor. Then it's common to apply the ViewHolder Pattern to avoid calling findViewById() repetitively. For the number of times the adaptor's getView() getting called, it's a terrible idea to parse through the view hierarchy (albeit small) every single time.
  • The DownloadImageTask class should serve as a good reference for me if I were to implement a simple image download class again.
  • Here is the thing that makes life of a developer all the more miserable. There is no gurantee as to when getView() is invoked with null or non-null convertView/rowView parameter. This makes the current project with open bugs wherein not all images are displayed on scroll of ListView. Some images on new Rows in ListView don't show-up on scroll because getView() is invoked with not-null convertView/rowView parameter. This happens because of ListView adaptor's recycling views technique adopted by Google. But our code implementation downloads image only when the url of the ImageView matches with the url passed to it. For this technique to be adopted, getView() should be called without any convertView/rowView parameter.
  • Life is smoother and easier to choose a 3rd party library to solve this problem that re-invent the wheel on our own. I'd however like to continue to try solving this in my own way to quench my intellectual curiosity ;-)

NOTE: My above observations are based on running this project on GenyMotion's emulator.

References

customlistviewdemo's People

Contributors

karthiks 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.