Closed Bug 963046 Opened 10 years ago Closed 10 years ago

Implement image loading infrastructure for panel views

Categories

(Firefox for Android Graveyard :: Awesomescreen, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 30

People

(Reporter: lucasr, Assigned: lucasr)

References

Details

Attachments

(5 files)

We can't use the Favicons API as is because we'll have to support different types of images. For instance, some layouts will have larger images per item such as thumbnails. 

A few possible options:
1. Generalize part of the Favicons framework to handle other types of images.
2. Use something like Smoothie associated with some sort image disk/mem cache.
Comment on attachment 8368255 [details] [diff] [review]
Add Picasso image loading library to the tree (r=nalexander)

Picasso (https://github.com/square/picasso/), created by the Square team, is a pretty solid (and popular) open source image loading library for Android. What it gives us:
- Image memory and disk cache (the sizes of these caches are dynamically defined at runtime depending on the device. We can always tweak them if we need to)
- Off main thread image loading (from disk, memory and url)
- View recycling handling i.e. auto-cancels requests for recycled views
- Highly configurable framework i.e. we can implement our own cache, downloader, thread executor, and more if we need to.

All this behind a pretty simple API. The library is released under the Apache License, Version 2.0 which is compatible with our stuff (we already have several pieces of code under the same license in our tree btw).

I considered using Smoothie but that would means implementing the mem/disk/ caching and download routines on our own. I'd prefer to lean on more proven code so that we focus more on the home panel-specific features.

For now, I'm not implementing any custom bits for the Picasso framework and simply sticking with the defaults (see following patches).

Requesting feedback from Nick for the build system parts.
Attachment #8368255 - Flags: review?(margaret.leibovic)
Attachment #8368255 - Flags: feedback?(nalexander)
Comment on attachment 8368256 [details] [diff] [review]
Use HomeItems DB constract in PanelListRow (r=margaret)

We shouldn't be using URLColumns stuff on dynamic panel views anymore.
Attachment #8368256 - Flags: review?(margaret.leibovic)
Comment on attachment 8368257 [details] [diff] [review]
Add image_url column to HomeProvider's fake items (r=margaret)

So that we can test image loading stuff with fake items.
Attachment #8368257 - Flags: review?(margaret.leibovic)
Comment on attachment 8368258 [details] [diff] [review]
Use Picasso to load images in PanelListRow and PanelGridItemView (r=margaret)

Yep, it's that simple. Any configuration and custom components associated with Picasso should be encapsulated behind ImageLoader. For consistency, I stuck with the same API from Picasso to get a singleton instance (i.e. the with() method).
Attachment #8368258 - Flags: review?(margaret.leibovic)
Comment on attachment 8368259 [details] [diff] [review]
Remove unused imports from PanelListRow (r=margaret)

Quick cleanup.
Attachment #8368259 - Flags: review?(margaret.leibovic)
Attachment #8368256 - Flags: review?(margaret.leibovic) → review+
Attachment #8368257 - Flags: review?(margaret.leibovic) → review+
Comment on attachment 8368258 [details] [diff] [review]
Use Picasso to load images in PanelListRow and PanelGridItemView (r=margaret)

Review of attachment 8368258 [details] [diff] [review]:
-----------------------------------------------------------------

Sweet.
Attachment #8368258 - Flags: review?(margaret.leibovic) → review+
Attachment #8368259 - Flags: review?(margaret.leibovic) → review+
Comment on attachment 8368255 [details] [diff] [review]
Add Picasso image loading library to the tree (r=nalexander)

Review of attachment 8368255 [details] [diff] [review]:
-----------------------------------------------------------------

You were right, this was a simple review.  In fact, I'm buoyed by how simple this is.  It will be even cleaner when we move building the thirdparty jars to mobile/android/thirdparty/moz.build.

One thing to note: this uses a *third* (or fourth?) HTTP stack (Gecko is one, Background Services another).  More proxies, more problems.

::: mobile/android/base/Makefile.in
@@ +61,5 @@
>  ALL_JARS = \
>    gecko-browser.jar \
>    gecko-mozglue.jar \
>    gecko-util.jar \
> +  squareup-picasso.jar \

nit, open to discussion: version the JAR?

::: mobile/android/base/moz.build
@@ +400,5 @@
>  gbjar.generated_sources += sync_generated_java_files
>  gbjar.extra_jars = [
>      'gecko-mozglue.jar',
>      'gecko-util.jar',
> +    'squareup-picasso.jar',

nit: version?

@@ +440,5 @@
> +    'com/squareup/picasso/Transformation.java',
> +    'com/squareup/picasso/UrlConnectionDownloader.java',
> +    'com/squareup/picasso/Utils.java',
> +] ]
> +#spjar.javac_flags += ['-Xlint:all']

nit: I always prefer to ratchet the Xlint flags as high as possible, although it's less of an issue with thirdparty source.
Attachment #8368255 - Flags: feedback?(nalexander) → feedback+
Comment on attachment 8368255 [details] [diff] [review]
Add Picasso image loading library to the tree (r=nalexander)

Review of attachment 8368255 [details] [diff] [review]:
-----------------------------------------------------------------

I feel like nalexander is more of an expert than me here, but I can give this my rubber stamp :)
Attachment #8368255 - Flags: review?(margaret.leibovic) → review+
Blocks: 968897
(In reply to Nick Alexander :nalexander from comment #12)
> Comment on attachment 8368255 [details] [diff] [review]
> Add Picasso image loading library to the tree (r=nalexander)
> 
> Review of attachment 8368255 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> You were right, this was a simple review.  In fact, I'm buoyed by how simple
> this is.  It will be even cleaner when we move building the thirdparty jars
> to mobile/android/thirdparty/moz.build.
> 
> One thing to note: this uses a *third* (or fourth?) HTTP stack (Gecko is
> one, Background Services another).  More proxies, more problems.

The default "Downloader" implementation uses HttpUrlConnection which uses default HTTP stack on the Android. I filed bug 968897 to implement a Downloader that uses the same HTTP stack than, say, the Favicons framework (assuming this is the stack we've agreed to use on the Java side).

> ::: mobile/android/base/Makefile.in
> @@ +61,5 @@
> >  ALL_JARS = \
> >    gecko-browser.jar \
> >    gecko-mozglue.jar \
> >    gecko-util.jar \
> > +  squareup-picasso.jar \
> 
> nit, open to discussion: version the JAR?

Not sure I want to stick with specific versions as that might get misleading if, in the future, we land some hot fixes directly in our tree or cherry pick patches from upstream.

> ::: mobile/android/base/moz.build
> @@ +400,5 @@
> >  gbjar.generated_sources += sync_generated_java_files
> >  gbjar.extra_jars = [
> >      'gecko-mozglue.jar',
> >      'gecko-util.jar',
> > +    'squareup-picasso.jar',
> 
> nit: version?

Ditto.

> @@ +440,5 @@
> > +    'com/squareup/picasso/Transformation.java',
> > +    'com/squareup/picasso/UrlConnectionDownloader.java',
> > +    'com/squareup/picasso/Utils.java',
> > +] ]
> > +#spjar.javac_flags += ['-Xlint:all']
> 
> nit: I always prefer to ratchet the Xlint flags as high as possible,
> although it's less of an issue with thirdparty source.

Yeah, that should be fine for something like Picasso (I can tweak that if that becomes a problem in the future).
Depends on: 970702
Depends on: 973137
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: