From f17a1c9ad99d46a65de797422fd439382114b348 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Mon, 27 Apr 2015 17:01:32 -0700 Subject: Widget tray alignment according to UX spec - Fixing an issue where widget preview is not loaded do to faulty canceling of loading async task when view is detached from the window. b/20338334 Change-Id: I1e3bd6b6cdafda8d1e0a7a0e87c8089100c341a7 --- res/layout/widget_cell.xml | 8 ++---- res/layout/widgets_list_row_view.xml | 33 ++++++++-------------- res/values/colors.xml | 1 + res/values/dimens.xml | 8 ++++-- src/com/android/launcher3/widget/WidgetCell.java | 19 +++---------- .../launcher3/widget/WidgetsListAdapter.java | 11 +++++++- 6 files changed, 36 insertions(+), 44 deletions(-) diff --git a/res/layout/widget_cell.xml b/res/layout/widget_cell.xml index 64ddea1ae..cb1c812cb 100644 --- a/res/layout/widget_cell.xml +++ b/res/layout/widget_cell.xml @@ -17,13 +17,11 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:launcher="http://schemas.android.com/apk/res-auto" android:layout_width="@dimen/widget_preview_container_width" - android:layout_height="wrap_content" + android:layout_height="@dimen/widget_cell_height" android:layout_weight="1" - android:layout_marginTop="@dimen/widget_preview_padding_top" - android:layout_marginLeft="8dp" - android:layout_marginBottom="8dp" + android:layout_marginRight="@dimen/widget_row_divider" android:orientation="vertical" - android:background="@color/bubble_dark_background" + android:background="@color/widgets_cell_color" android:focusable="true"> @@ -29,24 +28,23 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:focusable="true" - android:background="@drawable/focusable_view_bg" android:descendantFocusability="afterDescendants"> - - - + android:orientation="horizontal" + android:background="@color/widget_text_panel"/> diff --git a/res/values/colors.xml b/res/values/colors.xml index 3a06bd95a..58a4d4ce1 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -42,4 +42,5 @@ #009688 + #263238 diff --git a/res/values/dimens.xml b/res/values/dimens.xml index da1108271..a57ae89d0 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -86,12 +86,16 @@ 8dp 8dp - 52dp - 8dp + 56dp + 72dp + 8dp + 16dp 136dp 150dp + 8dp + 1dp 0dp diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java index 0bc7333ec..7c7d982de 100644 --- a/src/com/android/launcher3/widget/WidgetCell.java +++ b/src/com/android/launcher3/widget/WidgetCell.java @@ -48,7 +48,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener { private static final String TAG = "WidgetCell"; private static final boolean DEBUG = false; - private static final int FADE_IN_DURATION_MS = 70; + private static final int FADE_IN_DURATION_MS = 90; private int mPresetPreviewSize; private ImageView mWidgetImage; @@ -104,6 +104,8 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener { mWidgetImage.setImageDrawable(null); mWidgetName.setText(null); mWidgetDims.setText(null); + + cancelLoader(false); } /** @@ -140,16 +142,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener { mWidgetPreviewLoader = loader; } - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - deletePreview(false); - - if (DEBUG) { - Log.d(TAG, String.format("[tag=%s] onDetachedFromWindow", getTagToString())); - } - } - public int[] getPreviewSize() { int[] maxSize = new int[2]; maxSize[0] = mPresetPreviewSize; @@ -219,10 +211,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener { return Math.min(size[0], info.spanX * cellWidth); } - - private void deletePreview(boolean recycleImage) { - mWidgetImage.setImageDrawable(null); - + private void cancelLoader(boolean recycleImage) { if (mActiveRequest != null) { mActiveRequest.cancel(recycleImage); mActiveRequest = null; diff --git a/src/com/android/launcher3/widget/WidgetsListAdapter.java b/src/com/android/launcher3/widget/WidgetsListAdapter.java index f6ab21eb4..a5b2aff1b 100644 --- a/src/com/android/launcher3/widget/WidgetsListAdapter.java +++ b/src/com/android/launcher3/widget/WidgetsListAdapter.java @@ -127,7 +127,6 @@ public class WidgetsListAdapter extends Adapter { // Bind the view in the widget horizontal tray region. for (int i=0; i < infoList.size(); i++) { WidgetCell widget = (WidgetCell) row.getChildAt(i); - widget.reset(); if (getWidgetPreviewLoader() == null) { return; } @@ -158,6 +157,16 @@ public class WidgetsListAdapter extends Adapter { return new WidgetsRowViewHolder(container); } + @Override + public void onViewRecycled(WidgetsRowViewHolder holder) { + ViewGroup row = ((ViewGroup) holder.getContent().findViewById(R.id.widgets_cell_list)); + + for (int i = 0; i < row.getChildCount(); i++) { + WidgetCell widget = (WidgetCell) row.getChildAt(i); + widget.reset(); + } + } + @Override public long getItemId(int pos) { return pos; -- cgit v1.2.3