If you think the Android project DashClockWidget listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright 2013 Google Inc.//fromwww.java2s.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.google.android.apps.dashclock.render;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.widget.RemoteViews;
/**
* {@link ViewBuilder} implementation for {@link RemoteViews}.
*/publicclass WidgetViewBuilder implements ViewBuilder {
private Context mContext;
private RemoteViews mRemoteViews;
public WidgetViewBuilder(Context context) {
mContext = context;
}
@Override
publicvoid loadRootLayout(Object container, int layoutResId) {
mRemoteViews = new RemoteViews(mContext.getPackageName(), layoutResId);
}
@Override
publicvoid useRoot(Object root) {
thrownew UnsupportedOperationException("Can't reuse RemoteViews for WidgetViewBuilder.");
}
@Override
public Object inflateChildLayout(int layoutResId, int containerId) {
returnnew RemoteViews(mContext.getPackageName(), layoutResId);
}
@Override
publicvoid setLinearLayoutGravity(int viewId, int gravity) {
mRemoteViews.setInt(viewId, "setGravity", gravity);
}
@Override
publicvoid setViewPadding(int viewId, int left, int top, int right, int bottom) {
mRemoteViews.setViewPadding(viewId, left, top, right, bottom);
}
@Override
publicvoid addView(int viewId, Object child) {
mRemoteViews.addView(viewId, (RemoteViews) child);
}
@Override
publicvoid removeAllViews(int viewId) {
mRemoteViews.removeAllViews(viewId);
}
@Override
publicvoid setViewVisibility(int viewId, int visibility) {
mRemoteViews.setViewVisibility(viewId, visibility);
}
@Override
publicvoid setViewBackgroundColor(int viewId, int color) {
mRemoteViews.setInt(viewId, "setBackgroundColor", color);
}
@Override
publicvoid setImageViewBitmap(int viewId, Bitmap bitmap) {
mRemoteViews.setImageViewBitmap(viewId, bitmap);
}
@Override
publicvoid setViewContentDescription(int viewId, String contentDescription) {
mRemoteViews.setContentDescription(viewId, contentDescription);
}
@Override
publicvoid setTextViewText(int viewId, CharSequence text) {
mRemoteViews.setTextViewText(viewId, text);
}
@Override
publicvoid setTextViewColor(int viewId, int color) {
mRemoteViews.setTextColor(viewId, color);
}
@Override
publicvoid setTextViewMaxLines(int viewId, int maxLines) {
mRemoteViews.setInt(viewId, "setMaxLines", maxLines);
}
@Override
publicvoid setTextViewSingleLine(int viewId, boolean singleLine) {
mRemoteViews.setBoolean(viewId, "setSingleLine", singleLine);
}
@Override
publicvoid setTextViewTextSize(int viewId, int unit, float size) {
mRemoteViews.setTextViewTextSize(viewId, unit, size);
}
@Override
publicvoid setViewClickIntent(int viewId, Intent clickIntent) {
mRemoteViews.setOnClickPendingIntent(viewId,
PendingIntent.getActivity(mContext, 0,
clickIntent, PendingIntent.FLAG_UPDATE_CURRENT));
}
@Override
publicvoid setViewClickFillInIntent(int viewId, Intent fillIntent) {
mRemoteViews.setOnClickFillInIntent(viewId, fillIntent);
}
@Override
public Object getRoot() {
return mRemoteViews;
}
}