diff options
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 6543d0cf8bdd..316dab59628a 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -320,6 +320,10 @@ public class RemoteViews implements Parcelable, Filter { return this; } + public boolean prefersAsyncApply() { + return false; + } + int viewId; } @@ -715,20 +719,29 @@ public class RemoteViews implements Parcelable, Filter { intent.putExtra(EXTRA_REMOTEADAPTER_APPWIDGET_ID, host.getAppWidgetId()); if (target instanceof AbsListView) { AbsListView v = (AbsListView) target; - v.setRemoteViewsAdapter(intent); + v.setRemoteViewsAdapter(intent, isAsync); v.setRemoteViewsOnClickHandler(handler); } else if (target instanceof AdapterViewAnimator) { AdapterViewAnimator v = (AdapterViewAnimator) target; - v.setRemoteViewsAdapter(intent); + v.setRemoteViewsAdapter(intent, isAsync); v.setRemoteViewsOnClickHandler(handler); } } + @Override + public Action initActionAsync(ViewTree root, ViewGroup rootParent, + OnClickHandler handler) { + SetRemoteViewsAdapterIntent copy = new SetRemoteViewsAdapterIntent(viewId, intent); + copy.isAsync = true; + return copy; + } + public String getActionName() { return "SetRemoteViewsAdapterIntent"; } Intent intent; + boolean isAsync = false; public final static int TAG = 10; } @@ -1461,6 +1474,11 @@ public class RemoteViews implements Parcelable, Filter { // unique from the standpoint of merging. return "ReflectionAction" + this.methodName + this.type; } + + @Override + public boolean prefersAsyncApply() { + return this.type == URI || this.type == ICON; + } } /** @@ -1598,6 +1616,11 @@ public class RemoteViews implements Parcelable, Filter { return MERGE_APPEND; } + @Override + public boolean prefersAsyncApply() { + return nestedViews != null && nestedViews.prefersAsyncApply(); + } + RemoteViews nestedViews; public final static int TAG = 4; @@ -1749,6 +1772,11 @@ public class RemoteViews implements Parcelable, Filter { return copy; } + @Override + public boolean prefersAsyncApply() { + return useIcons; + } + public String getActionName() { return "TextViewDrawableAction"; } @@ -3443,6 +3471,24 @@ public class RemoteViews implements Parcelable, Filter { } } + /** + * Returns true if the RemoteViews contains potentially costly operations and should be + * applied asynchronously. + * + * @hide + */ + public boolean prefersAsyncApply() { + if (mActions != null) { + final int count = mActions.size(); + for (int i = 0; i < count; i++) { + if (mActions.get(i).prefersAsyncApply()) { + return true; + } + } + } + return false; + } + private Context getContextForResources(Context context) { if (mApplication != null) { if (context.getUserId() == UserHandle.getUserId(mApplication.uid) |
