summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-10-27 17:14:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-10-27 17:14:47 +0000
commit584264f6af08faea57653c65db4abcb8111009c0 (patch)
tree674317f0bd73ec401d77e1c0d8f58931763506bd /core/java/android/widget/RemoteViews.java
parentf501c31454b267ead3e68ef610662fb5200c7141 (diff)
parent5c022639d7e1eebbeb190975980621a286bb2ff1 (diff)
Merge "Adding support for async view loading in RemoteViewsAdapter"
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java50
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)