diff options
| author | Joe Onorato <joeo@google.com> | 2010-10-31 11:35:41 -0700 |
|---|---|---|
| committer | Joe Onorato <joeo@google.com> | 2010-10-31 11:35:41 -0700 |
| commit | 2b69ce469d544f4b2cb6423feaf4da8df7cf7a64 (patch) | |
| tree | 94273d9a2db54473104bbaf8fde1e2a6b8c8c4c2 /core | |
| parent | aaffa8b4d4d3530e02cd6a0619b0c1485c133e55 (diff) | |
| download | frameworks_base-2b69ce469d544f4b2cb6423feaf4da8df7cf7a64.zip frameworks_base-2b69ce469d544f4b2cb6423feaf4da8df7cf7a64.tar.gz frameworks_base-2b69ce469d544f4b2cb6423feaf4da8df7cf7a64.tar.bz2 | |
Allow RemoteViews to silently fail when a view can't be found.
Generally, I'm not a huge fan of allowing bugs like this, but this
will allow people to write apps with better compatibility across
configurations. They can just add a bunch of actions, and have
only some of them apply based on which views are in the layout
resource.
Bug: 3107945
Change-Id: Iecb118ce5f56421ac53a7b95ea470de9f726ee82
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 9d214fc..35c50fd 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -190,6 +190,7 @@ public class RemoteViews implements Parcelable, Filter { @Override public void apply(View root) { final View target = root.findViewById(viewId); + if (target == null) return; if (!mIsWidgetCollectionChild) { Log.e("RemoteViews", "The method setOnClickFillInIntent is available " + @@ -277,6 +278,7 @@ public class RemoteViews implements Parcelable, Filter { @Override public void apply(View root) { final View target = root.findViewById(viewId); + if (target == null) return; if (!mIsWidgetCollectionChild) { Log.e("RemoteViews", "The method setOnClickExtras is available " + @@ -367,6 +369,7 @@ public class RemoteViews implements Parcelable, Filter { @Override public void apply(View root) { final View target = root.findViewById(viewId); + if (target == null) return; // If the view isn't an AdapterView, setting a PendingIntent template doesn't make sense if (target instanceof AdapterView<?>) { @@ -410,6 +413,7 @@ public class RemoteViews implements Parcelable, Filter { @Override public void apply(View root) { final View target = root.findViewById(viewId); + if (target == null) return; // If the view is an AdapterView, setting a PendingIntent on click doesn't make much // sense, do they mean to set a PendingIntent template for the AdapterView's children? @@ -513,9 +517,7 @@ public class RemoteViews implements Parcelable, Filter { @Override public void apply(View root) { final View target = root.findViewById(viewId); - if (target == null) { - return; - } + if (target == null) return; // Pick the correct drawable to modify for this view Drawable targetDrawable = null; @@ -575,9 +577,7 @@ public class RemoteViews implements Parcelable, Filter { @Override public void apply(View root) { final View view = root.findViewById(viewId); - if (view == null) { - throw new ActionException("can't find view: 0x" + Integer.toHexString(viewId)); - } + if (view == null) return; Class klass = view.getClass(); Method method; @@ -793,9 +793,7 @@ public class RemoteViews implements Parcelable, Filter { @Override public void apply(View root) { final View view = root.findViewById(viewId); - if (view == null) { - throw new ActionException("can't find view: 0x" + Integer.toHexString(viewId)); - } + if (view == null) return; Class param = getParameterType(); if (param == null) { @@ -888,10 +886,11 @@ public class RemoteViews implements Parcelable, Filter { public void apply(View root) { final Context context = root.getContext(); final ViewGroup target = (ViewGroup) root.findViewById(viewId); + if (target == null) return; if (nestedViews != null) { // Inflate nested views and add as children target.addView(nestedViews.apply(context, target)); - } else if (target != null) { + } else { // Clear all children when nested views omitted target.removeAllViews(); } |
