本文整理汇总了Java中com.example.android.sunshine.app.Utility.getIconResourceForWeatherCondition方法的典型用法代码示例。如果您正苦于以下问题:Java Utility.getIconResourceForWeatherCondition方法的具体用法?Java Utility.getIconResourceForWeatherCondition怎么用?Java Utility.getIconResourceForWeatherCondition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.example.android.sunshine.app.Utility
的用法示例。
在下文中一共展示了Utility.getIconResourceForWeatherCondition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWeatherAsset
import com.example.android.sunshine.app.Utility; //导入方法依赖的package包/类
private Asset getWeatherAsset(int weatherId) {
int iconId = Utility.getIconResourceForWeatherCondition(weatherId);
Bitmap weatherIcon = BitmapFactory.decodeResource(getContext().getResources(), iconId);
ByteArrayOutputStream weatherIconByteStream = new ByteArrayOutputStream();
weatherIcon.compress(Bitmap.CompressFormat.PNG, 100, weatherIconByteStream);
return Asset.createFromBytes(weatherIconByteStream.toByteArray());
}
示例2: createForecastNotificationBuilder
import com.example.android.sunshine.app.Utility; //导入方法依赖的package包/类
public static NotificationCompat.Builder createForecastNotificationBuilder(
@NonNull Context context, @NonNull Forecast forecast) {
int iconId = R.mipmap.ic_launcher;
if (forecast.mWeatherId > 0) {
iconId = Utility.getIconResourceForWeatherCondition(forecast.mWeatherId);
}
Resources resources = context.getResources();
// Normally when loading resources you should utilize a library like Glide, since this is a
// sample we keep it simple.
Bitmap largeIcon = BitmapFactory.decodeResource(resources,
Utility.getArtResourceForWeatherCondition(iconId));
// NotificationCompatBuilder is a very convenient way to build
// backward-compatible notifications; just input data.
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setColor(resources.getColor(R.color.sunshine_light_blue))
.setSmallIcon(iconId)
.setLargeIcon(largeIcon)
.setContentTitle(forecast.mNotificationTitle)
.setContentText(forecast.mNotificationContentText);
// Make something interesting happen when the user clicks on the
// notification. In this case, opening the app is sufficient.
Intent resultIntent = new Intent(context, MainActivity.class);
// The stack builder object will contain an artificial back stack for the
// started Activity. This ensures that navigating backward from the
// Activity leads out of your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
builder.setContentIntent(resultPendingIntent);
return builder;
}