RemoteViewspublic class RemoteViews extends Object implements android.view.LayoutInflater.Filter, android.os.ParcelableA class that describes a view hierarchy that can be displayed in
another process. The hierarchy is inflated from a layout resource
file, and this class provides some basic operations for modifying
the content of the inflated hierarchy. |
Fields Summary |
---|
private static final String | LOG_TAG | static final String | EXTRA_REMOTEADAPTER_APPWIDGET_IDThe intent extra that contains the appWidgetId. | private android.content.pm.ApplicationInfo | mApplicationApplication that hosts the remote views. | private final int | mLayoutIdThe resource ID of the layout file. (Added to the parcel) | private ArrayList | mActionsAn array of actions to perform on the view tree once it has been
inflated | private MemoryUsageCounter | mMemoryUsageCounterA class to keep track of memory usage by this RemoteViews | private BitmapCache | mBitmapCacheMaps bitmaps to unique indicies to avoid Bitmap duplication. | private boolean | mIsRootIndicates whether or not this RemoteViews object is contained as a child of any other
RemoteViews. | private static final int | MODE_NORMALConstants to whether or not this RemoteViews is composed of a landscape and portrait
RemoteViews. | private static final int | MODE_HAS_LANDSCAPE_AND_PORTRAIT | private RemoteViews | mLandscapeUsed in conjunction with the special constructor
{@link #RemoteViews(RemoteViews, RemoteViews)} to keep track of the landscape and portrait
RemoteViews. | private RemoteViews | mPortrait | private boolean | mIsWidgetCollectionChildThis flag indicates whether this RemoteViews object is being created from a
RemoteViewsService for use as a child of a widget collection. This flag is used
to determine whether or not certain features are available, in particular,
setting on click extras and setting on click pending intents. The former is enabled,
and the latter disabled when this flag is true. | private static final OnClickHandler | DEFAULT_ON_CLICK_HANDLER | private static final Object[] | sMethodsLock | private static final android.util.ArrayMap | sMethods | private static final ThreadLocal | sInvokeArgsTls | private final MutablePair | mPairThis pair is used to perform lookups in sMethods without causing allocations. | public static final Parcelable.Creator | CREATORParcelable.Creator that instantiates RemoteViews objects |
Constructors Summary |
---|
protected RemoteViews(android.content.pm.ApplicationInfo application, int layoutId)Create a new RemoteViews object that will display the views contained
in the specified layout file.
mApplication = application;
mLayoutId = layoutId;
mBitmapCache = new BitmapCache();
// setup the memory usage statistics
mMemoryUsageCounter = new MemoryUsageCounter();
recalculateMemoryUsage();
| public RemoteViews(RemoteViews landscape, RemoteViews portrait)Create a new RemoteViews object that will inflate as the specified
landspace or portrait RemoteViews, depending on the current configuration.
if (landscape == null || portrait == null) {
throw new RuntimeException("Both RemoteViews must be non-null");
}
if (landscape.mApplication.uid != portrait.mApplication.uid
|| !landscape.mApplication.packageName.equals(portrait.mApplication.packageName)) {
throw new RuntimeException("Both RemoteViews must share the same package and user");
}
mApplication = portrait.mApplication;
mLayoutId = portrait.getLayoutId();
mLandscape = landscape;
mPortrait = portrait;
// setup the memory usage statistics
mMemoryUsageCounter = new MemoryUsageCounter();
mBitmapCache = new BitmapCache();
configureRemoteViewsAsChild(landscape);
configureRemoteViewsAsChild(portrait);
recalculateMemoryUsage();
| public RemoteViews(android.os.Parcel parcel)Reads a RemoteViews object from a parcel.
this(parcel, null);
| private RemoteViews(android.os.Parcel parcel, BitmapCache bitmapCache)
int mode = parcel.readInt();
// We only store a bitmap cache in the root of the RemoteViews.
if (bitmapCache == null) {
mBitmapCache = new BitmapCache(parcel);
} else {
setBitmapCache(bitmapCache);
setNotRoot();
}
if (mode == MODE_NORMAL) {
mApplication = parcel.readParcelable(null);
mLayoutId = parcel.readInt();
mIsWidgetCollectionChild = parcel.readInt() == 1;
int count = parcel.readInt();
if (count > 0) {
mActions = new ArrayList<Action>(count);
for (int i=0; i<count; i++) {
int tag = parcel.readInt();
switch (tag) {
case SetOnClickPendingIntent.TAG:
mActions.add(new SetOnClickPendingIntent(parcel));
break;
case SetDrawableParameters.TAG:
mActions.add(new SetDrawableParameters(parcel));
break;
case ReflectionAction.TAG:
mActions.add(new ReflectionAction(parcel));
break;
case ViewGroupAction.TAG:
mActions.add(new ViewGroupAction(parcel, mBitmapCache));
break;
case ReflectionActionWithoutParams.TAG:
mActions.add(new ReflectionActionWithoutParams(parcel));
break;
case SetEmptyView.TAG:
mActions.add(new SetEmptyView(parcel));
break;
case SetPendingIntentTemplate.TAG:
mActions.add(new SetPendingIntentTemplate(parcel));
break;
case SetOnClickFillInIntent.TAG:
mActions.add(new SetOnClickFillInIntent(parcel));
break;
case SetRemoteViewsAdapterIntent.TAG:
mActions.add(new SetRemoteViewsAdapterIntent(parcel));
break;
case TextViewDrawableAction.TAG:
mActions.add(new TextViewDrawableAction(parcel));
break;
case TextViewSizeAction.TAG:
mActions.add(new TextViewSizeAction(parcel));
break;
case ViewPaddingAction.TAG:
mActions.add(new ViewPaddingAction(parcel));
break;
case BitmapReflectionAction.TAG:
mActions.add(new BitmapReflectionAction(parcel));
break;
case SetRemoteViewsAdapterList.TAG:
mActions.add(new SetRemoteViewsAdapterList(parcel));
break;
case TextViewDrawableColorFilterAction.TAG:
mActions.add(new TextViewDrawableColorFilterAction(parcel));
break;
default:
throw new ActionException("Tag " + tag + " not found");
}
}
}
} else {
// MODE_HAS_LANDSCAPE_AND_PORTRAIT
mLandscape = new RemoteViews(parcel, mBitmapCache);
mPortrait = new RemoteViews(parcel, mBitmapCache);
mApplication = mPortrait.mApplication;
mLayoutId = mPortrait.getLayoutId();
}
// setup the memory usage statistics
mMemoryUsageCounter = new MemoryUsageCounter();
recalculateMemoryUsage();
| public RemoteViews(String packageName, int layoutId)Create a new RemoteViews object that will display the views contained
in the specified layout file.
this(getApplicationInfo(packageName, UserHandle.myUserId()), layoutId);
| public RemoteViews(String packageName, int userId, int layoutId)Create a new RemoteViews object that will display the views contained
in the specified layout file.
this(getApplicationInfo(packageName, userId), layoutId);
|
Methods Summary |
---|
private void | addAction(android.widget.RemoteViews$Action a)Add an action to be executed on the remote side when apply is called.
if (hasLandscapeAndPortraitLayouts()) {
throw new RuntimeException("RemoteViews specifying separate landscape and portrait" +
" layouts cannot be modified. Instead, fully configure the landscape and" +
" portrait layouts individually before constructing the combined layout.");
}
if (mActions == null) {
mActions = new ArrayList<Action>();
}
mActions.add(a);
// update the memory usage stats
a.updateMemoryUsageEstimate(mMemoryUsageCounter);
| public void | addView(int viewId, android.widget.RemoteViews nestedView)Equivalent to calling {@link ViewGroup#addView(View)} after inflating the
given {@link RemoteViews}. This allows users to build "nested"
{@link RemoteViews}. In cases where consumers of {@link RemoteViews} may
recycle layouts, use {@link #removeAllViews(int)} to clear any existing
children.
addAction(new ViewGroupAction(viewId, nestedView));
| public android.view.View | apply(android.content.Context context, android.view.ViewGroup parent)Inflates the view hierarchy represented by this object and applies
all of the actions.
Caller beware: this may throw
return apply(context, parent, null);
| public android.view.View | apply(android.content.Context context, android.view.ViewGroup parent, android.widget.RemoteViews$OnClickHandler handler)
RemoteViews rvToApply = getRemoteViewsToApply(context);
View result;
// RemoteViews may be built by an application installed in another
// user. So build a context that loads resources from that user but
// still returns the current users userId so settings like data / time formats
// are loaded without requiring cross user persmissions.
final Context contextForResources = getContextForResources(context);
Context inflationContext = new ContextWrapper(context) {
@Override
public Resources getResources() {
return contextForResources.getResources();
}
@Override
public Resources.Theme getTheme() {
return contextForResources.getTheme();
}
};
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Clone inflater so we load resources from correct context and
// we don't add a filter to the static version returned by getSystemService.
inflater = inflater.cloneInContext(inflationContext);
inflater.setFilter(this);
result = inflater.inflate(rvToApply.getLayoutId(), parent, false);
rvToApply.performApply(result, parent, handler);
return result;
| public android.widget.RemoteViews | clone()
Parcel p = Parcel.obtain();
writeToParcel(p, 0);
p.setDataPosition(0);
RemoteViews rv = new RemoteViews(p);
p.recycle();
return rv;
| private void | configureRemoteViewsAsChild(android.widget.RemoteViews rv)
mBitmapCache.assimilate(rv.mBitmapCache);
rv.setBitmapCache(mBitmapCache);
rv.setNotRoot();
| public int | describeContents()
return 0;
| public int | estimateMemoryUsage()
return mMemoryUsageCounter.getMemoryUsage();
| private static android.content.pm.ApplicationInfo | getApplicationInfo(java.lang.String packageName, int userId)
if (packageName == null) {
return null;
}
// Get the application for the passed in package and user.
Application application = ActivityThread.currentApplication();
if (application == null) {
throw new IllegalStateException("Cannot create remote views out of an aplication.");
}
ApplicationInfo applicationInfo = application.getApplicationInfo();
if (UserHandle.getUserId(applicationInfo.uid) != userId
|| !applicationInfo.packageName.equals(packageName)) {
try {
Context context = application.getBaseContext().createPackageContextAsUser(
packageName, 0, new UserHandle(userId));
applicationInfo = context.getApplicationInfo();
} catch (NameNotFoundException nnfe) {
throw new IllegalArgumentException("No such package " + packageName);
}
}
return applicationInfo;
| private android.content.Context | getContextForResources(android.content.Context context)
if (mApplication != null) {
if (context.getUserId() == UserHandle.getUserId(mApplication.uid)
&& context.getPackageName().equals(mApplication.packageName)) {
return context;
}
try {
return context.createApplicationContext(mApplication,
Context.CONTEXT_RESTRICTED);
} catch (NameNotFoundException e) {
Log.e(LOG_TAG, "Package name " + mApplication.packageName + " not found");
}
}
return context;
| public int | getLayoutId()Reutrns the layout id of the root layout associated with this RemoteViews. In the case
that the RemoteViews has both a landscape and portrait root, this will return the layout
id associated with the portrait layout.
return mLayoutId;
| private java.lang.reflect.Method | getMethod(android.view.View view, java.lang.String methodName, java.lang.Class paramType)
Method method;
Class<? extends View> klass = view.getClass();
synchronized (sMethodsLock) {
ArrayMap<MutablePair<String, Class<?>>, Method> methods = sMethods.get(klass);
if (methods == null) {
methods = new ArrayMap<MutablePair<String, Class<?>>, Method>();
sMethods.put(klass, methods);
}
mPair.first = methodName;
mPair.second = paramType;
method = methods.get(mPair);
if (method == null) {
try {
if (paramType == null) {
method = klass.getMethod(methodName);
} else {
method = klass.getMethod(methodName, paramType);
}
} catch (NoSuchMethodException ex) {
throw new ActionException("view: " + klass.getName() + " doesn't have method: "
+ methodName + getParameters(paramType));
}
if (!method.isAnnotationPresent(RemotableViewMethod.class)) {
throw new ActionException("view: " + klass.getName()
+ " can't use method with RemoteViews: "
+ methodName + getParameters(paramType));
}
methods.put(new MutablePair<String, Class<?>>(methodName, paramType), method);
}
}
return method;
| public java.lang.String | getPackage()
return (mApplication != null) ? mApplication.packageName : null;
| private static java.lang.String | getParameters(java.lang.Class paramType)
if (paramType == null) return "()";
return "(" + paramType + ")";
| private android.widget.RemoteViews | getRemoteViewsToApply(android.content.Context context)
if (hasLandscapeAndPortraitLayouts()) {
int orientation = context.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return mLandscape;
} else {
return mPortrait;
}
}
return this;
| public int | getSequenceNumber()Returns the number of actions in this RemoteViews. Can be used as a sequence number.
return (mActions == null) ? 0 : mActions.size();
| private static android.graphics.Rect | getSourceBounds(android.view.View v)
final float appScale = v.getContext().getResources()
.getCompatibilityInfo().applicationScale;
final int[] pos = new int[2];
v.getLocationOnScreen(pos);
final Rect rect = new Rect();
rect.left = (int) (pos[0] * appScale + 0.5f);
rect.top = (int) (pos[1] * appScale + 0.5f);
rect.right = (int) ((pos[0] + v.getWidth()) * appScale + 0.5f);
rect.bottom = (int) ((pos[1] + v.getHeight()) * appScale + 0.5f);
return rect;
| private boolean | hasLandscapeAndPortraitLayouts()
return (mLandscape != null) && (mPortrait != null);
| public void | mergeRemoteViews(android.widget.RemoteViews newRv)Merges the passed RemoteViews actions with this RemoteViews actions according to
action-specific merge rules.
if (newRv == null) return;
// We first copy the new RemoteViews, as the process of merging modifies the way the actions
// reference the bitmap cache. We don't want to modify the object as it may need to
// be merged and applied multiple times.
RemoteViews copy = newRv.clone();
HashMap<String, Action> map = new HashMap<String, Action>();
if (mActions == null) {
mActions = new ArrayList<Action>();
}
int count = mActions.size();
for (int i = 0; i < count; i++) {
Action a = mActions.get(i);
map.put(a.getUniqueKey(), a);
}
ArrayList<Action> newActions = copy.mActions;
if (newActions == null) return;
count = newActions.size();
for (int i = 0; i < count; i++) {
Action a = newActions.get(i);
String key = newActions.get(i).getUniqueKey();
int mergeBehavior = newActions.get(i).mergeBehavior();
if (map.containsKey(key) && mergeBehavior == Action.MERGE_REPLACE) {
mActions.remove(map.get(key));
map.remove(key);
}
// If the merge behavior is ignore, we don't bother keeping the extra action
if (mergeBehavior == Action.MERGE_REPLACE || mergeBehavior == Action.MERGE_APPEND) {
mActions.add(a);
}
}
// Because pruning can remove the need for bitmaps, we reconstruct the bitmap cache
mBitmapCache = new BitmapCache();
setBitmapCache(mBitmapCache);
| public boolean | onLoadClass(java.lang.Class clazz)
return clazz.isAnnotationPresent(RemoteView.class);
| private void | performApply(android.view.View v, android.view.ViewGroup parent, android.widget.RemoteViews$OnClickHandler handler)
if (mActions != null) {
handler = handler == null ? DEFAULT_ON_CLICK_HANDLER : handler;
final int count = mActions.size();
for (int i = 0; i < count; i++) {
Action a = mActions.get(i);
a.apply(v, parent, handler);
}
}
| public void | reapply(android.content.Context context, android.view.View v)Applies all of the actions to the provided view.
Caller beware: this may throw
reapply(context, v, null);
| public void | reapply(android.content.Context context, android.view.View v, android.widget.RemoteViews$OnClickHandler handler)
RemoteViews rvToApply = getRemoteViewsToApply(context);
// In the case that a view has this RemoteViews applied in one orientation, is persisted
// across orientation change, and has the RemoteViews re-applied in the new orientation,
// we throw an exception, since the layouts may be completely unrelated.
if (hasLandscapeAndPortraitLayouts()) {
if (v.getId() != rvToApply.getLayoutId()) {
throw new RuntimeException("Attempting to re-apply RemoteViews to a view that" +
" that does not share the same root layout id.");
}
}
rvToApply.performApply(v, (ViewGroup) v.getParent(), handler);
| private void | recalculateMemoryUsage()Updates the memory usage statistics.
mMemoryUsageCounter.clear();
if (!hasLandscapeAndPortraitLayouts()) {
// Accumulate the memory usage for each action
if (mActions != null) {
final int count = mActions.size();
for (int i= 0; i < count; ++i) {
mActions.get(i).updateMemoryUsageEstimate(mMemoryUsageCounter);
}
}
if (mIsRoot) {
mBitmapCache.addBitmapMemory(mMemoryUsageCounter);
}
} else {
mMemoryUsageCounter.increment(mLandscape.estimateMemoryUsage());
mMemoryUsageCounter.increment(mPortrait.estimateMemoryUsage());
mBitmapCache.addBitmapMemory(mMemoryUsageCounter);
}
| public void | removeAllViews(int viewId)Equivalent to calling {@link ViewGroup#removeAllViews()}.
addAction(new ViewGroupAction(viewId, null));
| public void | setAccessibilityTraversalAfter(int viewId, int nextId)Equivalent to calling {@link android.view.View#setAccessibilityTraversalAfter(int)}.
setInt(viewId, "setAccessibilityTraversalAfter", nextId);
| public void | setAccessibilityTraversalBefore(int viewId, int nextId)Equivalent to calling {@link android.view.View#setAccessibilityTraversalBefore(int)}.
setInt(viewId, "setAccessibilityTraversalBefore", nextId);
| public void | setBitmap(int viewId, java.lang.String methodName, android.graphics.Bitmap value)Call a method taking one Bitmap on a view in the layout for this RemoteViews.
addAction(new BitmapReflectionAction(viewId, methodName, value));
| private void | setBitmapCache(android.widget.RemoteViews$BitmapCache bitmapCache)Recursively sets BitmapCache in the hierarchy and update the bitmap ids.
mBitmapCache = bitmapCache;
if (!hasLandscapeAndPortraitLayouts()) {
if (mActions != null) {
final int count = mActions.size();
for (int i= 0; i < count; ++i) {
mActions.get(i).setBitmapCache(bitmapCache);
}
}
} else {
mLandscape.setBitmapCache(bitmapCache);
mPortrait.setBitmapCache(bitmapCache);
}
| public void | setBoolean(int viewId, java.lang.String methodName, boolean value)Call a method taking one boolean on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.BOOLEAN, value));
| public void | setBundle(int viewId, java.lang.String methodName, android.os.Bundle value)Call a method taking one Bundle on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.BUNDLE, value));
| public void | setByte(int viewId, java.lang.String methodName, byte value)Call a method taking one byte on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.BYTE, value));
| public void | setChar(int viewId, java.lang.String methodName, char value)Call a method taking one char on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.CHAR, value));
| public void | setCharSequence(int viewId, java.lang.String methodName, java.lang.CharSequence value)Call a method taking one CharSequence on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.CHAR_SEQUENCE, value));
| public void | setChronometer(int viewId, long base, java.lang.String format, boolean started)Equivalent to calling {@link Chronometer#setBase Chronometer.setBase},
{@link Chronometer#setFormat Chronometer.setFormat},
and {@link Chronometer#start Chronometer.start()} or
{@link Chronometer#stop Chronometer.stop()}.
setLong(viewId, "setBase", base);
setString(viewId, "setFormat", format);
setBoolean(viewId, "setStarted", started);
| public void | setContentDescription(int viewId, java.lang.CharSequence contentDescription)Equivalent to calling View.setContentDescription(CharSequence).
setCharSequence(viewId, "setContentDescription", contentDescription);
| public void | setDisplayedChild(int viewId, int childIndex)Equivalent to calling {@link AdapterViewAnimator#setDisplayedChild(int)}
setInt(viewId, "setDisplayedChild", childIndex);
| public void | setDouble(int viewId, java.lang.String methodName, double value)Call a method taking one double on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.DOUBLE, value));
| public void | setDrawableParameters(int viewId, boolean targetBackground, int alpha, int colorFilter, PorterDuff.Mode mode, int level)
addAction(new SetDrawableParameters(viewId, targetBackground, alpha,
colorFilter, mode, level));
| public void | setEmptyView(int viewId, int emptyViewId)Equivalent to calling AdapterView.setEmptyView
addAction(new SetEmptyView(viewId, emptyViewId));
| public void | setFloat(int viewId, java.lang.String methodName, float value)Call a method taking one float on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.FLOAT, value));
| public void | setImageViewBitmap(int viewId, android.graphics.Bitmap bitmap)Equivalent to calling ImageView.setImageBitmap
setBitmap(viewId, "setImageBitmap", bitmap);
| public void | setImageViewResource(int viewId, int srcId)Equivalent to calling ImageView.setImageResource
setInt(viewId, "setImageResource", srcId);
| public void | setImageViewUri(int viewId, android.net.Uri uri)Equivalent to calling ImageView.setImageURI
setUri(viewId, "setImageURI", uri);
| public void | setInt(int viewId, java.lang.String methodName, int value)Call a method taking one int on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.INT, value));
| public void | setIntent(int viewId, java.lang.String methodName, android.content.Intent value)Call a method taking one Intent on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.INTENT, value));
| void | setIsWidgetCollectionChild(boolean isWidgetCollectionChild)
mIsWidgetCollectionChild = isWidgetCollectionChild;
| public void | setLabelFor(int viewId, int labeledId)Equivalent to calling View.setLabelFor(int).
setInt(viewId, "setLabelFor", labeledId);
| public void | setLong(int viewId, java.lang.String methodName, long value)Call a method taking one long on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.LONG, value));
| void | setNotRoot()
mIsRoot = false;
| public void | setOnClickFillInIntent(int viewId, android.content.Intent fillInIntent)When using collections (eg. {@link ListView}, {@link StackView} etc.) in widgets, it is very
costly to set PendingIntents on the individual items, and is hence not permitted. Instead
a single PendingIntent template can be set on the collection, see {@link
RemoteViews#setPendingIntentTemplate(int, PendingIntent)}, and the individual on-click
action of a given item can be distinguished by setting a fillInIntent on that item. The
fillInIntent is then combined with the PendingIntent template in order to determine the final
intent which will be executed when the item is clicked. This works as follows: any fields
which are left blank in the PendingIntent template, but are provided by the fillInIntent
will be overwritten, and the resulting PendingIntent will be used.
of the PendingIntent template will then be filled in with the associated fields that are
set in fillInIntent. See {@link Intent#fillIn(Intent, int)} for more details.
addAction(new SetOnClickFillInIntent(viewId, fillInIntent));
| public void | setOnClickPendingIntent(int viewId, android.app.PendingIntent pendingIntent)Equivalent to calling
{@link android.view.View#setOnClickListener(android.view.View.OnClickListener)}
to launch the provided {@link PendingIntent}.
When setting the on-click action of items within collections (eg. {@link ListView},
{@link StackView} etc.), this method will not work. Instead, use {@link
RemoteViews#setPendingIntentTemplate(int, PendingIntent) in conjunction with
RemoteViews#setOnClickFillInIntent(int, Intent).
addAction(new SetOnClickPendingIntent(viewId, pendingIntent));
| public void | setPendingIntentTemplate(int viewId, android.app.PendingIntent pendingIntentTemplate)When using collections (eg. {@link ListView}, {@link StackView} etc.) in widgets, it is very
costly to set PendingIntents on the individual items, and is hence not permitted. Instead
this method should be used to set a single PendingIntent template on the collection, and
individual items can differentiate their on-click behavior using
{@link RemoteViews#setOnClickFillInIntent(int, Intent)}.
addAction(new SetPendingIntentTemplate(viewId, pendingIntentTemplate));
| public void | setProgressBackgroundTintList(int viewId, android.content.res.ColorStateList tint)
addAction(new ReflectionAction(viewId, "setProgressBackgroundTintList",
ReflectionAction.COLOR_STATE_LIST, tint));
| public void | setProgressBar(int viewId, int max, int progress, boolean indeterminate)Equivalent to calling {@link ProgressBar#setMax ProgressBar.setMax},
{@link ProgressBar#setProgress ProgressBar.setProgress}, and
{@link ProgressBar#setIndeterminate ProgressBar.setIndeterminate}
If indeterminate is true, then the values for max and progress are ignored.
setBoolean(viewId, "setIndeterminate", indeterminate);
if (!indeterminate) {
setInt(viewId, "setMax", max);
setInt(viewId, "setProgress", progress);
}
| public void | setProgressIndeterminateTintList(int viewId, android.content.res.ColorStateList tint)
addAction(new ReflectionAction(viewId, "setIndeterminateTintList",
ReflectionAction.COLOR_STATE_LIST, tint));
| public void | setProgressTintList(int viewId, android.content.res.ColorStateList tint)
addAction(new ReflectionAction(viewId, "setProgressTintList",
ReflectionAction.COLOR_STATE_LIST, tint));
| public void | setRelativeScrollPosition(int viewId, int offset)Equivalent to calling {@link android.widget.AbsListView#smoothScrollToPosition(int, int)}.
setInt(viewId, "smoothScrollByOffset", offset);
| public void | setRemoteAdapter(int appWidgetId, int viewId, android.content.Intent intent)Equivalent to calling {@link android.widget.AbsListView#setRemoteViewsAdapter(Intent)}.
setRemoteAdapter(viewId, intent);
| public void | setRemoteAdapter(int viewId, android.content.Intent intent)Equivalent to calling {@link android.widget.AbsListView#setRemoteViewsAdapter(Intent)}.
Can only be used for App Widgets.
addAction(new SetRemoteViewsAdapterIntent(viewId, intent));
| public void | setRemoteAdapter(int viewId, java.util.ArrayList list, int viewTypeCount)Creates a simple Adapter for the viewId specified. The viewId must point to an AdapterView,
ie. {@link ListView}, {@link GridView}, {@link StackView} or {@link AdapterViewAnimator}.
This is a simpler but less flexible approach to populating collection widgets. Its use is
encouraged for most scenarios, as long as the total memory within the list of RemoteViews
is relatively small (ie. doesn't contain large or numerous Bitmaps, see {@link
RemoteViews#setImageViewBitmap}). In the case of numerous images, the use of API is still
possible by setting image URIs instead of Bitmaps, see {@link RemoteViews#setImageViewUri}.
This API is supported in the compatibility library for previous API levels, see
RemoteViewsCompat.
addAction(new SetRemoteViewsAdapterList(viewId, list, viewTypeCount));
| public void | setScrollPosition(int viewId, int position)Equivalent to calling {@link android.widget.AbsListView#smoothScrollToPosition(int, int)}.
setInt(viewId, "smoothScrollToPosition", position);
| public void | setShort(int viewId, java.lang.String methodName, short value)Call a method taking one short on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.SHORT, value));
| public void | setString(int viewId, java.lang.String methodName, java.lang.String value)Call a method taking one String on a view in the layout for this RemoteViews.
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.STRING, value));
| public void | setTextColor(int viewId, int color)Equivalent to calling {@link android.widget.TextView#setTextColor(int)}.
setInt(viewId, "setTextColor", color);
| public void | setTextViewCompoundDrawables(int viewId, int left, int top, int right, int bottom)Equivalent to calling
{@link TextView#setCompoundDrawablesWithIntrinsicBounds(int, int, int, int)}.
addAction(new TextViewDrawableAction(viewId, false, left, top, right, bottom));
| public void | setTextViewCompoundDrawablesRelative(int viewId, int start, int top, int end, int bottom)Equivalent to calling {@link
TextView#setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, int)}.
addAction(new TextViewDrawableAction(viewId, true, start, top, end, bottom));
| public void | setTextViewCompoundDrawablesRelativeColorFilter(int viewId, int index, int color, PorterDuff.Mode mode)Equivalent to applying a color filter on one of the drawables in
{@link android.widget.TextView#getCompoundDrawablesRelative()}.
if (index < 0 || index >= 4) {
throw new IllegalArgumentException("index must be in range [0, 3].");
}
addAction(new TextViewDrawableColorFilterAction(viewId, true, index, color, mode));
| public void | setTextViewText(int viewId, java.lang.CharSequence text)Equivalent to calling TextView.setText
setCharSequence(viewId, "setText", text);
| public void | setTextViewTextSize(int viewId, int units, float size)Equivalent to calling {@link TextView#setTextSize(int, float)}
addAction(new TextViewSizeAction(viewId, units, size));
| public void | setUri(int viewId, java.lang.String methodName, android.net.Uri value)Call a method taking one Uri on a view in the layout for this RemoteViews.
if (value != null) {
// Resolve any filesystem path before sending remotely
value = value.getCanonicalUri();
if (StrictMode.vmFileUriExposureEnabled()) {
value.checkFileUriExposed("RemoteViews.setUri()");
}
}
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.URI, value));
| public void | setViewPadding(int viewId, int left, int top, int right, int bottom)Equivalent to calling {@link android.view.View#setPadding(int, int, int, int)}.
addAction(new ViewPaddingAction(viewId, left, top, right, bottom));
| public void | setViewVisibility(int viewId, int visibility)Equivalent to calling View.setVisibility
setInt(viewId, "setVisibility", visibility);
| public void | showNext(int viewId)Equivalent to calling {@link AdapterViewAnimator#showNext()}
addAction(new ReflectionActionWithoutParams(viewId, "showNext"));
| public void | showPrevious(int viewId)Equivalent to calling {@link AdapterViewAnimator#showPrevious()}
addAction(new ReflectionActionWithoutParams(viewId, "showPrevious"));
| private static java.lang.Object[] | wrapArg(java.lang.Object value)
Object[] args = sInvokeArgsTls.get();
args[0] = value;
return args;
| public void | writeToParcel(android.os.Parcel dest, int flags)
if (!hasLandscapeAndPortraitLayouts()) {
dest.writeInt(MODE_NORMAL);
// We only write the bitmap cache if we are the root RemoteViews, as this cache
// is shared by all children.
if (mIsRoot) {
mBitmapCache.writeBitmapsToParcel(dest, flags);
}
dest.writeParcelable(mApplication, flags);
dest.writeInt(mLayoutId);
dest.writeInt(mIsWidgetCollectionChild ? 1 : 0);
int count;
if (mActions != null) {
count = mActions.size();
} else {
count = 0;
}
dest.writeInt(count);
for (int i=0; i<count; i++) {
Action a = mActions.get(i);
a.writeToParcel(dest, 0);
}
} else {
dest.writeInt(MODE_HAS_LANDSCAPE_AND_PORTRAIT);
// We only write the bitmap cache if we are the root RemoteViews, as this cache
// is shared by all children.
if (mIsRoot) {
mBitmapCache.writeBitmapsToParcel(dest, flags);
}
mLandscape.writeToParcel(dest, flags);
mPortrait.writeToParcel(dest, flags);
}
|
|