本文整理汇总了Java中com.google.android.apps.dashclock.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于com.google.android.apps.dashclock包,在下文中一共展示了Utils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onUpdateData
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
String nextAlarm = Settings.System.getString(getContentResolver(),
Settings.System.NEXT_ALARM_FORMATTED);
if (!TextUtils.isEmpty(nextAlarm)) {
Matcher m = sDigitPattern.matcher(nextAlarm);
if (m.find() && m.start() > 0) {
nextAlarm = nextAlarm.substring(0, m.start()) + "\n"
+ nextAlarm.substring(m.start() + 1); // +1 to skip whitespace
}
}
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Intent alarmIntent = AppChooserPreference.getIntentValue(
sp.getString(PREF_ALARM_SHORTCUT, null), null);
if (alarmIntent == null) {
alarmIntent = Utils.getDefaultAlarmsIntent(this);
}
publishUpdate(new ExtensionData()
.visible(!TextUtils.isEmpty(nextAlarm))
.icon(R.drawable.ic_extension_next_alarm)
.status(nextAlarm)
.clickIntent(alarmIntent));
}
开发者ID:romannurik,项目名称:dashclock,代码行数:26,代码来源:NextAlarmExtension.java
示例2: update
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
/**
* Updated the notification data copy and also updates the notification in the notification
* shade.
* <br />
* All the extension data is consumed and used for building the notification. The title of the
* extension data becomes the notification's title, the body of the extension data becomes the
* notification's content, the click intent of the extension data becomes the notification's
* click intent, the icon of the extension data becomes the notification's icon and the status
* of the extension data becomes the notifications info only if the status does not match the
* title or the body (to prevent redundant information cluttering up the notification.)
*
* @param component the component name of the extension
* @param data the data passed from the extension
*/
@SuppressWarnings("deprecation")
private void update(ComponentName component, ExtensionData data) {
if (data != null && data.visible()) {
int colour = getResources().getColor(R.color.notification_color);
NotificationCompat.Builder notification = new NotificationCompat.Builder(this);
notification.setColor(colour);
notification.setCategory(NotificationCompat.CATEGORY_SERVICE);
notification.setPriority(Integer.MIN_VALUE);
notification.setOnlyAlertOnce(true);
notification.setOngoing(true);
notification.setShowWhen(true);
PendingIntent click = PendingIntent.getActivity(getApplicationContext(), 0, data.clickIntent(), 0);
Bitmap icon = Utils.loadExtensionIcon(getApplicationContext(), component, data.icon(), null, colour);
notification.setStyle(new BigTextStyle().bigText(data.expandedBody()));
notification.setSmallIcon(R.drawable.ic_notification);
notification.setContentTitle(data.expandedTitle());
notification.setContentText(data.expandedBody());
notification.setGroup("dashbar");
if (data.status() != null && !data.status().equalsIgnoreCase(data.expandedBody())
&& !data.status().equalsIgnoreCase(data.expandedTitle())) {
notification.setContentInfo(data.status());
}
notification.setContentIntent(click);
notification.setLargeIcon(icon);
mNotifier.notify(component.getPackageName(), 1, notification.build());
}
}
开发者ID:mridang,项目名称:dashbar,代码行数:45,代码来源:NotificationService.java
示例3: onCreate
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
setupFauxDialog();
RecentTasksStyler.styleRecentTasksEntry(this);
super.onCreate(savedInstanceState);
Utils.enableDisablePhoneOnlyExtensions(this);
Intent intent = getIntent();
if (intent != null) {
if (Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction())) {
Intent.ShortcutIconResource icon = new Intent.ShortcutIconResource();
icon.packageName = getPackageName();
icon.resourceName = getResources().getResourceName(R.mipmap.ic_launcher);
setResult(RESULT_OK, new Intent()
.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.title_configure))
.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon)
.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
Intent.makeMainActivity(
new ComponentName(this, ConfigurationActivity.class))));
finish();
}
mStartSection = intent.getIntExtra(EXTRA_START_SECTION, 0);
}
setContentView(R.layout.activity_configure);
if (intent != null
&& AppWidgetManager.ACTION_APPWIDGET_CONFIGURE.equals(intent.getAction())) {
mNewWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mNewWidgetId);
// See http://code.google.com/p/android/issues/detail?id=2539
setResult(RESULT_CANCELED, new Intent()
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mNewWidgetId));
}
// Set up UI widgets
setupActionBar();
}
开发者ID:mridang,项目名称:dashbar,代码行数:39,代码来源:ConfigurationActivity.java
示例4: onCreate
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_ACTION_BAR);
setupFauxDialog();
super.onCreate(savedInstanceState);
Utils.enableDisablePhoneOnlyExtensions(this);
Intent intent = getIntent();
if (intent != null) {
if (Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction())) {
Intent.ShortcutIconResource icon = new Intent.ShortcutIconResource();
icon.packageName = getPackageName();
icon.resourceName = getResources().getResourceName(R.drawable.ic_launcher);
setResult(RESULT_OK, new Intent()
.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.title_configure))
.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon)
.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
Intent.makeMainActivity(
new ComponentName(this, ConfigurationActivity.class))));
finish();
}
mStartSection = intent.getIntExtra(EXTRA_START_SECTION, 0);
}
setContentView(R.layout.activity_configure);
if (intent != null
&& AppWidgetManager.ACTION_APPWIDGET_CONFIGURE.equals(intent.getAction())) {
mNewWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mNewWidgetId);
// See http://code.google.com/p/android/issues/detail?id=2539
setResult(RESULT_CANCELED, new Intent()
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mNewWidgetId));
}
// Set up UI widgets
setupActionBar();
}
开发者ID:tedk,项目名称:Dash,代码行数:39,代码来源:ConfigurationActivity.java
示例5: renderCollapsedExtension
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
public Object renderCollapsedExtension(Object container, Object convertRoot, boolean inList,
ExtensionWithData ewd) {
ViewBuilder vb = onCreateViewBuilder();
if (convertRoot != null) {
vb.useRoot(convertRoot);
} else {
vb.loadRootLayout(container, inList
? R.layout.widget_include_collapsed_extension
: R.layout.widget_include_collapsed_extension_interactive);
}
Resources res = mContext.getResources();
int extensionCollapsedTextSizeSingleLine = res
.getDimensionPixelSize(R.dimen.extension_collapsed_text_size_single_line);
int extensionCollapsedTextSizeTwoLine = res
.getDimensionPixelSize(R.dimen.extension_collapsed_text_size_two_line);
String status = ewd.latestData.status();
if (TextUtils.isEmpty(status)) {
status = "";
}
if (status.indexOf("\n") > 0) {
vb.setTextViewSingleLine(R.id.collapsed_extension_text, false);
vb.setTextViewMaxLines(R.id.collapsed_extension_text, 2);
vb.setTextViewTextSize(R.id.collapsed_extension_text,
TypedValue.COMPLEX_UNIT_PX,
extensionCollapsedTextSizeTwoLine);
} else {
vb.setTextViewSingleLine(R.id.collapsed_extension_text, true);
vb.setTextViewMaxLines(R.id.collapsed_extension_text, 1);
vb.setTextViewTextSize(R.id.collapsed_extension_text,
TypedValue.COMPLEX_UNIT_PX,
extensionCollapsedTextSizeSingleLine);
}
vb.setTextViewText(R.id.collapsed_extension_text, status.toUpperCase(Locale.getDefault()));
vb.setTextViewColor(R.id.collapsed_extension_text, mOptions.foregroundColor);
String statusContentDescription = ewd.latestData.contentDescription();
if (TextUtils.isEmpty(statusContentDescription)) {
StringBuilder builder = new StringBuilder();
String expandedTitle = Utils.expandedTitleOrStatus(ewd.latestData);
if (!TextUtils.isEmpty(expandedTitle)) {
builder.append(expandedTitle);
}
String expandedBody = ewd.latestData.expandedBody();
if (!TextUtils.isEmpty(expandedBody)) {
builder.append(" ").append(expandedBody);
}
statusContentDescription = builder.toString();
}
vb.setViewContentDescription(R.id.collapsed_extension_text, statusContentDescription);
vb.setImageViewBitmap(R.id.collapsed_extension_icon,
Utils.loadExtensionIcon(mContext, ewd.listing.componentName(),
ewd.latestData.icon(), ewd.latestData.iconUri(), mOptions.foregroundColor));
vb.setViewContentDescription(R.id.collapsed_extension_icon, ewd.listing.title());
Intent clickIntent = ewd.latestData.clickIntent();
if (clickIntent != null) {
if (inList) {
vb.setViewClickFillInIntent(R.id.collapsed_extension_target,
WidgetClickProxyActivity.getFillIntent(clickIntent,
ewd.listing.componentName()));
} else {
vb.setViewClickIntent(R.id.collapsed_extension_target,
WidgetClickProxyActivity.wrap(mContext, clickIntent,
ewd.listing.componentName()));
}
}
return vb.getRoot();
}
开发者ID:mridang,项目名称:dashbar,代码行数:75,代码来源:DashClockRenderer.java
示例6: setColorViewValue
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
private static void setColorViewValue(View view, int color, boolean selected) {
if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
Resources res = imageView.getContext().getResources();
Drawable currentDrawable = imageView.getDrawable();
GradientDrawable colorChoiceDrawable;
if (currentDrawable instanceof GradientDrawable) {
// Reuse drawable
colorChoiceDrawable = (GradientDrawable) currentDrawable;
} else {
colorChoiceDrawable = new GradientDrawable();
colorChoiceDrawable.setShape(GradientDrawable.OVAL);
}
// Set stroke to dark version of color
int darkenedColor = Color.rgb(
Color.red(color) * 192 / 256,
Color.green(color) * 192 / 256,
Color.blue(color) * 192 / 256);
colorChoiceDrawable.setColor(color);
colorChoiceDrawable.setStroke((int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 2, res.getDisplayMetrics()), darkenedColor);
Drawable drawable = colorChoiceDrawable;
if (selected) {
BitmapDrawable checkmark = (BitmapDrawable) res.getDrawable(Utils.isColorDark(color)
? R.drawable.checkmark_white
: R.drawable.checkmark_black);
checkmark.setGravity(Gravity.CENTER);
drawable = new LayerDrawable(new Drawable[]{
colorChoiceDrawable,
checkmark});
}
imageView.setImageDrawable(drawable);
} else if (view instanceof TextView) {
((TextView) view).setTextColor(color);
}
}
开发者ID:mridang,项目名称:dashbar,代码行数:43,代码来源:ColorPreference.java
示例7: renderExpandedExtension
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
public Object renderExpandedExtension(Object container, Object convertRoot, boolean inList,
ExtensionWithData ewd) {
ViewBuilder vb = onCreateViewBuilder();
if (convertRoot != null) {
vb.useRoot(convertRoot);
} else {
vb.loadRootLayout(container, R.layout.widget_list_item_expanded_extension);
}
if (ewd == null || ewd.latestData == null) {
vb.setTextViewText(R.id.text1, mContext.getResources()
.getText(R.string.status_none));
vb.setViewVisibility(R.id.text2, View.GONE);
return vb.getRoot();
}
vb.setTextViewText(R.id.text1, Utils.expandedTitleOrStatus(ewd.latestData));
vb.setTextViewColor(R.id.text1, mOptions.foregroundColor);
String expandedBody = ewd.latestData.expandedBody();
vb.setViewVisibility(R.id.text2, TextUtils.isEmpty(expandedBody)
? View.GONE : View.VISIBLE);
vb.setTextViewText(R.id.text2, ewd.latestData.expandedBody());
vb.setTextViewColor(R.id.text2, mOptions.foregroundColor);
vb.setImageViewBitmap(R.id.icon,
Utils.loadExtensionIcon(mContext, ewd.listing.componentName(),
ewd.latestData.icon(), ewd.latestData.iconUri(), mOptions.foregroundColor));
String contentDescription = ewd.latestData.contentDescription();
if (TextUtils.isEmpty(contentDescription)) {
// No specific content description provided. Just set the minimal extra content
// description for the icon.
vb.setViewContentDescription(R.id.icon, ewd.listing.title());
} else {
// Content description for the entire row provided. Use it!
vb.setViewContentDescription(R.id.list_item,
ewd.listing.title() + ". " + contentDescription);
vb.setViewContentDescription(R.id.text1, "."); // silence title
vb.setViewContentDescription(R.id.text2, "."); // silence body
}
Intent clickIntent = ewd.latestData.clickIntent();
if (clickIntent != null) {
if (inList) {
vb.setViewClickFillInIntent(R.id.list_item,
WidgetClickProxyActivity.getFillIntent(clickIntent,
ewd.listing.componentName()));
} else {
vb.setViewClickIntent(R.id.list_item,
WidgetClickProxyActivity.wrap(mContext, clickIntent,
ewd.listing.componentName()));
}
}
return vb.getRoot();
}
开发者ID:romannurik,项目名称:dashclock,代码行数:58,代码来源:DashClockRenderer.java
示例8: getWeatherDataForLocation
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
private static WeatherData getWeatherDataForLocation(LocationInfo li) throws IOException {
HttpURLConnection connection = Utils.openUrlConnection(buildWeatherQueryUrl(li.woeid));
try {
XmlPullParser xpp = sXmlPullParserFactory.newPullParser();
xpp.setInput(new InputStreamReader(connection.getInputStream()));
WeatherData data = new WeatherData();
boolean hasTodayForecast = false;
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG
&& "condition".equals(xpp.getName())) {
for (int i = xpp.getAttributeCount() - 1; i >= 0; i--) {
if ("temp".equals(xpp.getAttributeName(i))) {
data.temperature = Integer.parseInt(xpp.getAttributeValue(i));
} else if ("code".equals(xpp.getAttributeName(i))) {
data.conditionCode = Integer.parseInt(xpp.getAttributeValue(i));
} else if ("text".equals(xpp.getAttributeName(i))) {
data.conditionText = xpp.getAttributeValue(i);
}
}
} else if (eventType == XmlPullParser.START_TAG
&& "forecast".equals(xpp.getName())
&& !hasTodayForecast) {
// TODO: verify this is the forecast for today (this currently assumes the
// first forecast is today's forecast)
hasTodayForecast = true;
for (int i = xpp.getAttributeCount() - 1; i >= 0; i--) {
if ("code".equals(xpp.getAttributeName(i))) {
data.todayForecastConditionCode
= Integer.parseInt(xpp.getAttributeValue(i));
} else if ("text".equals(xpp.getAttributeName(i))) {
data.forecastText = xpp.getAttributeValue(i);
}
}
} else if (eventType == XmlPullParser.START_TAG
&& "location".equals(xpp.getName())) {
String cityOrVillage = "--";
String region = "--";
for (int i = xpp.getAttributeCount() - 1; i >= 0; i--) {
if ("city".equals(xpp.getAttributeName(i))) {
cityOrVillage = xpp.getAttributeValue(i);
} else if ("region".equals(xpp.getAttributeName(i))) {
region = xpp.getAttributeValue(i);
}
}
if (!TextUtils.isEmpty(li.town) && !li.town.equals(cityOrVillage)) {
data.location = cityOrVillage + ", " + li.town + ", " + region;
} else {
data.location = cityOrVillage + ", " + region;
}
}
eventType = xpp.next();
}
return data;
} catch (XmlPullParserException e) {
throw new IOException("Error parsing weather feed XML.", e);
} finally {
connection.disconnect();
}
}
开发者ID:JesusM,项目名称:DashClock,代码行数:65,代码来源:WeatherExtension.java
示例9: getLocationInfo
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
private static LocationInfo getLocationInfo(Location location)
throws IOException, InvalidLocationException {
LocationInfo li = new LocationInfo();
HttpURLConnection connection = Utils.openUrlConnection(buildPlaceSearchUrl(location));
try {
XmlPullParser xpp = sXmlPullParserFactory.newPullParser();
xpp.setInput(new InputStreamReader(connection.getInputStream()));
boolean inWoe = false;
boolean inTown = false;
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG && "woeid".equals(xpp.getName())) {
inWoe = true;
} else if (eventType == XmlPullParser.TEXT && inWoe) {
li.woeid = xpp.getText();
}
if (eventType == XmlPullParser.START_TAG && xpp.getName().startsWith("locality")) {
for (int i = xpp.getAttributeCount() - 1; i >= 0; i--) {
if ("type".equals(xpp.getAttributeName(i))
&& "Town".equals(xpp.getAttributeValue(i))) {
inTown = true;
}
}
} else if (eventType == XmlPullParser.TEXT && inTown) {
li.town = xpp.getText();
}
if (eventType == XmlPullParser.END_TAG) {
inWoe = false;
inTown = false;
}
eventType = xpp.next();
}
if (!TextUtils.isEmpty(li.woeid)) {
return li;
}
throw new InvalidLocationException();
} catch (XmlPullParserException e) {
throw new IOException("Error parsing location XML response.", e);
} finally {
connection.disconnect();
}
}
开发者ID:JesusM,项目名称:DashClock,代码行数:50,代码来源:WeatherExtension.java
示例10: renderCollapsedExtension
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
public Object renderCollapsedExtension(Object container, Object convertRoot, boolean inList,
ExtensionWithData ewd) {
ViewBuilder vb = onCreateViewBuilder();
if (convertRoot != null) {
vb.useRoot(convertRoot);
} else {
vb.loadRootLayout(container, inList
? R.layout.widget_include_collapsed_extension
: R.layout.widget_include_collapsed_extension_interactive);
}
Resources res = mContext.getResources();
int extensionCollapsedTextSizeSingleLine = res
.getDimensionPixelSize(R.dimen.extension_collapsed_text_size_single_line);
int extensionCollapsedTextSizeTwoLine = res
.getDimensionPixelSize(R.dimen.extension_collapsed_text_size_two_line);
String status = ewd.latestData.status();
if (TextUtils.isEmpty(status)) {
status = "";
}
if (status.indexOf("\n") > 0) {
vb.setTextViewSingleLine(R.id.collapsed_extension_text, false);
vb.setTextViewMaxLines(R.id.collapsed_extension_text, 2);
vb.setTextViewTextSize(R.id.collapsed_extension_text,
TypedValue.COMPLEX_UNIT_PX,
extensionCollapsedTextSizeTwoLine);
} else {
vb.setTextViewSingleLine(R.id.collapsed_extension_text, true);
vb.setTextViewMaxLines(R.id.collapsed_extension_text, 1);
vb.setTextViewTextSize(R.id.collapsed_extension_text,
TypedValue.COMPLEX_UNIT_PX,
extensionCollapsedTextSizeSingleLine);
}
vb.setTextViewText(R.id.collapsed_extension_text, status);
vb.setTextViewColor(R.id.collapsed_extension_text, mOptions.foregroundColor);
String statusContentDescription = ewd.latestData.contentDescription();
if (TextUtils.isEmpty(statusContentDescription)) {
StringBuilder builder = new StringBuilder();
String expandedTitle = Utils.expandedTitleOrStatus(ewd.latestData);
if (!TextUtils.isEmpty(expandedTitle)) {
builder.append(expandedTitle);
}
String expandedBody = ewd.latestData.expandedBody();
if (!TextUtils.isEmpty(expandedBody)) {
builder.append(" ").append(expandedBody);
}
statusContentDescription = builder.toString();
}
vb.setViewContentDescription(R.id.collapsed_extension_text, statusContentDescription);
vb.setImageViewBitmap(R.id.collapsed_extension_icon,
Utils.loadExtensionIcon(mContext, ewd.listing.componentName,
ewd.latestData.icon(), ewd.latestData.iconUri(), mOptions.foregroundColor));
vb.setViewContentDescription(R.id.collapsed_extension_icon, ewd.listing.title);
Intent clickIntent = ewd.latestData.clickIntent();
if (clickIntent != null) {
if (inList) {
vb.setViewClickFillInIntent(R.id.collapsed_extension_target,
WidgetClickProxyActivity.getFillIntent(clickIntent,
ewd.listing.componentName));
} else {
vb.setViewClickIntent(R.id.collapsed_extension_target,
WidgetClickProxyActivity.wrap(mContext, clickIntent,
ewd.listing.componentName));
}
}
return vb.getRoot();
}
开发者ID:tedk,项目名称:Dash,代码行数:75,代码来源:DashClockRenderer.java
示例11: renderExpandedExtension
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
public Object renderExpandedExtension(Object container, Object convertRoot, boolean inList,
ExtensionWithData ewd) {
ViewBuilder vb = onCreateViewBuilder();
if (convertRoot != null) {
vb.useRoot(convertRoot);
} else {
vb.loadRootLayout(container, R.layout.widget_list_item_expanded_extension);
}
if (ewd == null || ewd.latestData == null) {
vb.setTextViewText(R.id.text1, mContext.getResources()
.getText(R.string.status_none));
vb.setViewVisibility(R.id.text2, View.GONE);
return vb.getRoot();
}
vb.setTextViewText(R.id.text1, Utils.expandedTitleOrStatus(ewd.latestData));
vb.setTextViewColor(R.id.text1, mOptions.foregroundColor);
String expandedBody = ewd.latestData.expandedBody();
vb.setViewVisibility(R.id.text2, TextUtils.isEmpty(expandedBody)
? View.GONE : View.VISIBLE);
vb.setTextViewText(R.id.text2, ewd.latestData.expandedBody());
vb.setTextViewColor(R.id.text2, mOptions.foregroundColor);
vb.setImageViewBitmap(R.id.icon,
Utils.loadExtensionIcon(mContext, ewd.listing.componentName,
ewd.latestData.icon(), ewd.latestData.iconUri(), mOptions.foregroundColor));
String contentDescription = ewd.latestData.contentDescription();
if (TextUtils.isEmpty(contentDescription)) {
// No specific content description provided. Just set the minimal extra content
// description for the icon.
vb.setViewContentDescription(R.id.icon, ewd.listing.title);
} else {
// Content description for the entire row provided. Use it!
vb.setViewContentDescription(R.id.list_item,
ewd.listing.title + ". " + contentDescription);
vb.setViewContentDescription(R.id.text1, "."); // silence title
vb.setViewContentDescription(R.id.text2, "."); // silence body
}
Intent clickIntent = ewd.latestData.clickIntent();
if (clickIntent != null) {
if (inList) {
vb.setViewClickFillInIntent(R.id.list_item,
WidgetClickProxyActivity.getFillIntent(clickIntent,
ewd.listing.componentName));
} else {
vb.setViewClickIntent(R.id.list_item,
WidgetClickProxyActivity.wrap(mContext, clickIntent,
ewd.listing.componentName));
}
}
return vb.getRoot();
}
开发者ID:tedk,项目名称:Dash,代码行数:58,代码来源:DashClockRenderer.java
示例12: setColorViewValue
import com.google.android.apps.dashclock.Utils; //导入依赖的package包/类
private static void setColorViewValue(View view, int color, boolean selected) {
if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
Resources res = imageView.getContext().getResources();
Drawable currentDrawable = imageView.getDrawable();
GradientDrawable colorChoiceDrawable;
if (currentDrawable != null && currentDrawable instanceof GradientDrawable) {
// Reuse drawable
colorChoiceDrawable = (GradientDrawable) currentDrawable;
} else {
colorChoiceDrawable = new GradientDrawable();
colorChoiceDrawable.setShape(GradientDrawable.OVAL);
}
// Set stroke to dark version of color
int darkenedColor = Color.rgb(
Color.red(color) * 192 / 256,
Color.green(color) * 192 / 256,
Color.blue(color) * 192 / 256);
colorChoiceDrawable.setColor(color);
colorChoiceDrawable.setStroke((int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 1, res.getDisplayMetrics()), darkenedColor);
Drawable drawable = colorChoiceDrawable;
if (selected) {
drawable = new LayerDrawable(new Drawable[]{
colorChoiceDrawable,
res.getDrawable(Utils.isColorDark(color)
? R.drawable.checkmark_white
: R.drawable.checkmark_black)
});
}
imageView.setImageDrawable(drawable);
} else if (view instanceof TextView) {
((TextView) view).setTextColor(color);
}
}
开发者ID:tedk,项目名称:Dash,代码行数:42,代码来源:ColorPreference.java
注:本文中的com.google.android.apps.dashclock.Utils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论