Loading src/com/android/launcher3/widget/LauncherAppWidgetHostView.java +14 −7 Original line number Original line Diff line number Diff line Loading @@ -57,7 +57,6 @@ import com.android.launcher3.views.BaseDragLayer.TouchCompleteListener; import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener; import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener; import java.util.List; import java.util.List; import java.util.Optional; /** /** * {@inheritDoc} * {@inheritDoc} Loading Loading @@ -118,7 +117,8 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView private final ViewGroupFocusHelper mDragLayerRelativeCoordinateHelper; private final ViewGroupFocusHelper mDragLayerRelativeCoordinateHelper; private long mDeferUpdatesUntilMillis = 0; private long mDeferUpdatesUntilMillis = 0; private RemoteViews mDeferredRemoteViews; private RemoteViews mDeferredRemoteViews; private Optional<SparseIntArray> mDeferredColorChange = Optional.empty(); private boolean mHasDeferredColorChange = false; private @Nullable SparseIntArray mDeferredColorChange = null; private boolean mEnableColorExtraction = true; private boolean mEnableColorExtraction = true; public LauncherAppWidgetHostView(Context context) { public LauncherAppWidgetHostView(Context context) { Loading Loading @@ -244,18 +244,23 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView */ */ public void endDeferringUpdates() { public void endDeferringUpdates() { RemoteViews remoteViews; RemoteViews remoteViews; Optional<SparseIntArray> deferredColors; SparseIntArray deferredColors; boolean hasDeferredColors; synchronized (mUpdateLock) { synchronized (mUpdateLock) { mDeferUpdatesUntilMillis = 0; mDeferUpdatesUntilMillis = 0; remoteViews = mDeferredRemoteViews; remoteViews = mDeferredRemoteViews; mDeferredRemoteViews = null; mDeferredRemoteViews = null; deferredColors = mDeferredColorChange; deferredColors = mDeferredColorChange; mDeferredColorChange = Optional.empty(); hasDeferredColors = mHasDeferredColorChange; mDeferredColorChange = null; mHasDeferredColorChange = false; } } if (remoteViews != null) { if (remoteViews != null) { updateAppWidget(remoteViews); updateAppWidget(remoteViews); } } deferredColors.ifPresent(colors -> onColorsChanged(null /* rectF */, colors)); if (hasDeferredColors) { onColorsChanged(null /* rectF */, deferredColors); } } } public boolean onInterceptTouchEvent(MotionEvent ev) { public boolean onInterceptTouchEvent(MotionEvent ev) { Loading Loading @@ -437,10 +442,12 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView public void onColorsChanged(RectF rectF, SparseIntArray colors) { public void onColorsChanged(RectF rectF, SparseIntArray colors) { synchronized (mUpdateLock) { synchronized (mUpdateLock) { if (isDeferringUpdates()) { if (isDeferringUpdates()) { mDeferredColorChange = Optional.ofNullable(colors); mDeferredColorChange = colors; mHasDeferredColorChange = true; return; return; } } mDeferredColorChange = Optional.empty(); mDeferredColorChange = null; mHasDeferredColorChange = false; } } // setColorResources will reapply the view, which must happen in the UI thread. // setColorResources will reapply the view, which must happen in the UI thread. Loading Loading
src/com/android/launcher3/widget/LauncherAppWidgetHostView.java +14 −7 Original line number Original line Diff line number Diff line Loading @@ -57,7 +57,6 @@ import com.android.launcher3.views.BaseDragLayer.TouchCompleteListener; import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener; import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener; import java.util.List; import java.util.List; import java.util.Optional; /** /** * {@inheritDoc} * {@inheritDoc} Loading Loading @@ -118,7 +117,8 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView private final ViewGroupFocusHelper mDragLayerRelativeCoordinateHelper; private final ViewGroupFocusHelper mDragLayerRelativeCoordinateHelper; private long mDeferUpdatesUntilMillis = 0; private long mDeferUpdatesUntilMillis = 0; private RemoteViews mDeferredRemoteViews; private RemoteViews mDeferredRemoteViews; private Optional<SparseIntArray> mDeferredColorChange = Optional.empty(); private boolean mHasDeferredColorChange = false; private @Nullable SparseIntArray mDeferredColorChange = null; private boolean mEnableColorExtraction = true; private boolean mEnableColorExtraction = true; public LauncherAppWidgetHostView(Context context) { public LauncherAppWidgetHostView(Context context) { Loading Loading @@ -244,18 +244,23 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView */ */ public void endDeferringUpdates() { public void endDeferringUpdates() { RemoteViews remoteViews; RemoteViews remoteViews; Optional<SparseIntArray> deferredColors; SparseIntArray deferredColors; boolean hasDeferredColors; synchronized (mUpdateLock) { synchronized (mUpdateLock) { mDeferUpdatesUntilMillis = 0; mDeferUpdatesUntilMillis = 0; remoteViews = mDeferredRemoteViews; remoteViews = mDeferredRemoteViews; mDeferredRemoteViews = null; mDeferredRemoteViews = null; deferredColors = mDeferredColorChange; deferredColors = mDeferredColorChange; mDeferredColorChange = Optional.empty(); hasDeferredColors = mHasDeferredColorChange; mDeferredColorChange = null; mHasDeferredColorChange = false; } } if (remoteViews != null) { if (remoteViews != null) { updateAppWidget(remoteViews); updateAppWidget(remoteViews); } } deferredColors.ifPresent(colors -> onColorsChanged(null /* rectF */, colors)); if (hasDeferredColors) { onColorsChanged(null /* rectF */, deferredColors); } } } public boolean onInterceptTouchEvent(MotionEvent ev) { public boolean onInterceptTouchEvent(MotionEvent ev) { Loading Loading @@ -437,10 +442,12 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView public void onColorsChanged(RectF rectF, SparseIntArray colors) { public void onColorsChanged(RectF rectF, SparseIntArray colors) { synchronized (mUpdateLock) { synchronized (mUpdateLock) { if (isDeferringUpdates()) { if (isDeferringUpdates()) { mDeferredColorChange = Optional.ofNullable(colors); mDeferredColorChange = colors; mHasDeferredColorChange = true; return; return; } } mDeferredColorChange = Optional.empty(); mDeferredColorChange = null; mHasDeferredColorChange = false; } } // setColorResources will reapply the view, which must happen in the UI thread. // setColorResources will reapply the view, which must happen in the UI thread. Loading