summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2010-08-25 17:24:53 -0700
committerAdam Cohen <adamcohen@google.com>2010-08-26 15:28:05 -0700
commit1480fddea874a42adb43b4bcdac6704e4c3e110b (patch)
tree87493bd5b35350595bdbab82695650d1d8a684b4 /core/java/android/widget/RemoteViews.java
parentdeefe553221faf1ac7077a9854a98f5f5c12f248 (diff)
-> Added the ability to specify an AdapterView's empty view
through RemoteViews. An empty view is the view that appears in lieu of the collection when the collection is empty. -> Made StackViews start at their last item Change-Id: Ica44e5e8f8f2a2e5589a6c74414ec4d08303887f
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index f23a7239ede9..0ca71e1665c9 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -17,6 +17,7 @@
package android.widget;
import android.app.PendingIntent;
+import android.appwidget.AppWidgetHostView;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
@@ -110,6 +111,42 @@ public class RemoteViews implements Parcelable, Filter {
}
}
+ private class SetEmptyView extends Action {
+ int viewId;
+ int emptyViewId;
+
+ public final static int TAG = 6;
+
+ SetEmptyView(int viewId, int emptyViewId) {
+ this.viewId = viewId;
+ this.emptyViewId = emptyViewId;
+ }
+
+ SetEmptyView(Parcel in) {
+ this.viewId = in.readInt();
+ this.emptyViewId = in.readInt();
+ }
+
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(TAG);
+ out.writeInt(this.viewId);
+ out.writeInt(this.emptyViewId);
+ }
+
+ @Override
+ public void apply(View root) {
+ final View view = root.findViewById(viewId);
+ if (!(view instanceof AdapterView<?>)) return;
+
+ AdapterView<?> adapterView = (AdapterView<?>) view;
+
+ final View emptyView = root.findViewById(emptyViewId);
+ if (emptyView == null) return;
+
+ adapterView.setEmptyView(emptyView);
+ }
+ }
+
/**
* Equivalent to calling
* {@link android.view.View#setOnClickListener(android.view.View.OnClickListener)}
@@ -631,6 +668,9 @@ public class RemoteViews implements Parcelable, Filter {
case ReflectionActionWithoutParams.TAG:
mActions.add(new ReflectionActionWithoutParams(parcel));
break;
+ case SetEmptyView.TAG:
+ mActions.add(new SetEmptyView(parcel));
+ break;
default:
throw new ActionException("Tag " + tag + " not found");
}
@@ -760,6 +800,16 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * Equivalent to calling AdapterView.setEmptyView
+ *
+ * @param viewId The id of the view on which to set the empty view
+ * @param emptyViewId The view id of the empty view
+ */
+ public void setEmptyView(int viewId, int emptyViewId) {
+ addAction(new SetEmptyView(viewId, emptyViewId));
+ }
+
+ /**
* Equivalent to calling {@link Chronometer#setBase Chronometer.setBase},
* {@link Chronometer#setFormat Chronometer.setFormat},
* and {@link Chronometer#start Chronometer.start()} or