Closed
Bug 980152
Opened 12 years ago
Closed 12 years ago
Panning on grid panes can be painful with large images
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 31
People
(Reporter: wesj, Assigned: wesj)
Details
Attachments
(2 files, 4 obsolete files)
|
7.35 KB,
patch
|
lucasr
:
review+
|
Details | Diff | Splinter Review |
|
7.47 KB,
patch
|
lucasr
:
review+
|
Details | Diff | Splinter Review |
I was writing this little weather add-on that added weather panes in Firefox Hub. It pulls down random "weather" images from jpg.to, some of which I assume can be huge. Scrolling in the pane can be extremely slow sometimes, but because the images are random it can be a bit hard to detect...
I'm guessing that extremely large images cause issues. I wonder if we need to resize them in Picasso?
Addon:
people.mozilla.com/~wjohnston/weather.xpi
Comment 1•12 years ago
|
||
(In reply to Wesley Johnston (:wesj) from comment #0)
> I was writing this little weather add-on that added weather panes in Firefox
> Hub. It pulls down random "weather" images from jpg.to, some of which I
> assume can be huge. Scrolling in the pane can be extremely slow sometimes,
> but because the images are random it can be a bit hard to detect...
>
> I'm guessing that extremely large images cause issues. I wonder if we need
> to resize them in Picasso?
>
> Addon:
> people.mozilla.com/~wjohnston/weather.xpi
What do you mean by 'slow' here? The images take too long to download? Scrolling is not smooth?
Picasso has a fit() option:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/thirdparty/com/squareup/picasso/RequestCreator.java#109
Could you patch a local build to see if it helps?
| Assignee | ||
Comment 2•12 years ago
|
||
This forces Picasso to resize these images. cropCenter makes it maintain the aspect ratio. The images won't have a size initially, so we force a minimum. I picked 160dp because that seemed like a reasonable halfwidth for the screen. There may be better options though. i.e. maybe we have a dimen that's good for this?
Attachment #8387458 -
Flags: review?(lucasr.at.mozilla)
Comment 3•12 years ago
|
||
Comment on attachment 8387458 [details] [diff] [review]
Patch
Review of attachment 8387458 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/base/home/PanelItemView.java
@@ +72,5 @@
> if (hasImageUrl) {
> Picasso.with(getContext())
> .load(imageUrl)
> + .resize(Math.max(mImage.getWidth(), minSize),
> + Math.max(mImage.getHeight(), minSize))
You can use the panel_grid_view_column_width dimen but that should only apply to ImageItemViews when used in a PanelGridView. Maybe you could add APIs to PanelItemView that allows the caller to set the target image size or something. If target image size is not explicitly defined, fallback to mImage's width/height (Picasso's fit() behaviour?).
Attachment #8387458 -
Flags: review?(lucasr.at.mozilla) → review-
| Assignee | ||
Comment 4•12 years ago
|
||
This does what you suggested. I had to modify the Adapater to pass the width/height through.
Attachment #8387458 -
Attachment is obsolete: true
Attachment #8390844 -
Flags: review?(lucasr.at.mozilla)
Comment 5•12 years ago
|
||
Comment on attachment 8390844 [details] [diff] [review]
Patch
Review of attachment 8390844 [details] [diff] [review]:
-----------------------------------------------------------------
Nice, just want to see an updated version before giving r+.
::: mobile/android/base/home/PanelGridView.java
@@ +35,5 @@
>
> mViewConfig = viewConfig;
> mUrlHandler = new PanelViewUrlHandler(viewConfig);
>
> mAdapter = new PanelViewAdapter(context, viewConfig.getItemType());
Technically, PanelGridView can contain ARTICLE panel views too. You should only apply the target size when mViewConfig.getItemType() is IMAGE.
::: mobile/android/base/home/PanelItemView.java
@@ +26,5 @@
> private final TextView mDescription;
> private final ImageView mImage;
> private final LinearLayout mTitleDescContainer;
> + private int targetWidth;
> + private int targetHeight;
You should keep the coding style consistent with the rest of the file. Only use the new coding style for new files.
Initialize with 0 for extra clarity.
@@ +38,5 @@
> mImage = (ImageView) findViewById(R.id.image);
> mTitleDescContainer = (LinearLayout) findViewById(R.id.title_desc_container);
> }
>
> + // Allows setting the size that images are resized to explicitly
nit: Use javadoc style comment.
@@ +76,5 @@
> + RequestCreator picasso = Picasso.with(getContext())
> + .load(imageUrl);
> +
> + if (targetWidth == 0 || targetHeight == 0) {
> + picasso.fit();
Is this necessary? Make sure fit() doesn't cause any visible delay to display the images. I'd avoid using it if possible.
::: mobile/android/base/home/PanelViewAdapter.java
@@ +14,5 @@
> import android.view.ViewGroup;
>
> class PanelViewAdapter extends CursorAdapter {
> private final Context mContext;
> private final ItemType mItemType;
Replace these tabs with spaces while at it?
@@ +39,3 @@
> @Override
> public View newView(Context context, Cursor cursor, ViewGroup parent) {
> + PanelItemView item = PanelItemView.create(mContext, mItemType);
final
@@ +40,5 @@
> public View newView(Context context, Cursor cursor, ViewGroup parent) {
> + PanelItemView item = PanelItemView.create(mContext, mItemType);
> + if (targetWidth > 0 && targetHeight > 0) {
> + item.setTargetImageSize(targetWidth, targetHeight);
> + }
nit: add empty line here.
Attachment #8390844 -
Flags: review?(lucasr.at.mozilla) → feedback+
| Assignee | ||
Comment 6•12 years ago
|
||
This is just moving things to the new style/fixing the tabs-spaces err.
Attachment #8390844 -
Attachment is obsolete: true
Attachment #8391349 -
Flags: review?(lucasr.at.mozilla)
| Assignee | ||
Comment 7•12 years ago
|
||
And this is the picasso fix. I removed the .fit() call. I only added it because you suggested it before, but since the consumers don't really know the image size we want, I don't think its fair to force them into an aspect ratio...
Attachment #8391353 -
Flags: review?(lucasr.at.mozilla)
Comment 8•12 years ago
|
||
Comment on attachment 8391353 [details] [diff] [review]
Patch 2/2
Review of attachment 8391353 [details] [diff] [review]:
-----------------------------------------------------------------
Looks great but still needs to fix the issue in PanelGridView.
::: mobile/android/base/home/PanelGridView.java
@@ +39,5 @@
> adapter = new PanelViewAdapter(context, viewConfig.getItemType());
> + Resources res = getResources();
> + int size = res.getDimensionPixelSize(R.dimen.panel_grid_view_column_width);
> + // Gridview images are square
> + adapter.setTargetImageSize(size, size);
It seems you forgot to cover my previous review comment here:
Technically, PanelGridView can contain ARTICLE panel views too. You should only apply the target size when mViewConfig.getItemType() is IMAGE.
::: mobile/android/base/home/PanelItemView.java
@@ +26,5 @@
> private final TextView description;
> private final ImageView image;
> private final LinearLayout titleDescContainer;
> + private int targetWidth;
> + private int targetHeight;
nit: init with 0 for extra clarity.
::: mobile/android/base/home/PanelViewAdapter.java
@@ +16,5 @@
> class PanelViewAdapter extends CursorAdapter {
> private final Context context;
> private final ItemType itemType;
> + private int targetWidth;
> + private int targetHeight;
nit: Init with 0 for extra clarity.
Attachment #8391353 -
Flags: review?(lucasr.at.mozilla) → feedback+
Comment 9•12 years ago
|
||
Comment on attachment 8391349 [details] [diff] [review]
Patch 1/2 - Cleanup
Review of attachment 8391349 [details] [diff] [review]:
-----------------------------------------------------------------
Slightly mixed about this change as it makes these classes inconsistent with the rest of the home package. But I'll survive.
Attachment #8391349 -
Flags: review?(lucasr.at.mozilla) → review+
| Assignee | ||
Comment 10•12 years ago
|
||
| Assignee | ||
Comment 11•12 years ago
|
||
grr. didn't unbitrot this right from the folders stuff. backed out part 2:
https://hg.mozilla.org/integration/fx-team/rev/b3f3c802372a
will ask for re-review since this has changed a bunch.
| Assignee | ||
Comment 12•12 years ago
|
||
This seems right for me. All that's changed is the folder view support.
Attachment #8391353 -
Attachment is obsolete: true
Attachment #8396655 -
Flags: review?(lucasr.at.mozilla)
| Assignee | ||
Comment 13•12 years ago
|
||
Attachment #8396655 -
Attachment is obsolete: true
Attachment #8396655 -
Flags: review?(lucasr.at.mozilla)
Attachment #8396658 -
Flags: review?(lucasr.at.mozilla)
Comment 14•12 years ago
|
||
Comment on attachment 8396658 [details] [diff] [review]
Patch
Review of attachment 8396658 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good with the suggested changes.
::: mobile/android/base/home/PanelGridView.java
@@ +41,5 @@
> adapter = new PanelViewAdapter(context, viewConfig);
> + Resources res = getResources();
> + int size = res.getDimensionPixelSize(R.dimen.panel_grid_view_column_width);
> + // Gridview images are square
> + adapter.setTargetImageSize(size, size);
This should be:
if (viewConfig.getItemType() == ItemType.IMAGE) {
final Resources res = getResources();
final int size = res.getDimensionPixelSize(R.dimen.panel_grid_view_column_width);
// Gridview images are square. This will ensure the images are resized to the
// expected size in the grid.
adapter.setTargetImageSize(size);
}
::: mobile/android/base/home/PanelViewAdapter.java
@@ +77,4 @@
> }
> +
> + PanelItemView item = PanelItemView.create(context, viewConfig.getItemType());
> + if (viewConfig.getItemType() == ItemType.IMAGE && targetWidth > 0 && targetHeight > 0) {
This itemType check should be in PanelGridView, not here in the adapter.
Attachment #8396658 -
Flags: review?(lucasr.at.mozilla) → review+
Comment 15•12 years ago
|
||
Assignee: nobody → wjohnston
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 31
Updated•5 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•