Widget preview improvements

- Make widget preview bitmaps as small as they can be, saving ~0.7-2MB peak memory (5104303)
- When adding/dragging a widget, make the drag outline/drag view much more closely match the actual size (5566938)

Change-Id: I5b5b7b84fa551d56432a76223b1a9e4de620ff56
This commit is contained in:
Michael Jurka
2011-11-03 13:50:45 -07:00
parent fd99e7776a
commit 038f9d8bfb
5 changed files with 171 additions and 113 deletions

View File

@@ -135,13 +135,20 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
}
}
void applyPreview(FastBitmapDrawable preview, int index, boolean scale) {
public int[] getPreviewSize() {
final ImageView i = (ImageView) findViewById(R.id.widget_preview);
int[] maxSize = new int[2];
maxSize[0] = i.getWidth() - i.getPaddingLeft() - i.getPaddingRight();
maxSize[1] = i.getHeight() - i.getPaddingBottom() - i.getPaddingTop();
return maxSize;
}
void applyPreview(FastBitmapDrawable preview, int index) {
final PagedViewWidgetImageView image =
(PagedViewWidgetImageView) findViewById(R.id.widget_preview);
if (preview != null) {
image.mAllowRequestLayout = false;
image.setImageDrawable(preview);
image.setScaleType(scale ? ImageView.ScaleType.FIT_START : ImageView.ScaleType.MATRIX);
image.mAllowRequestLayout = true;
image.setAlpha(0f);
image.animate()