当前位置: 首页>>代码示例>>Java>>正文


Java Utility.getIconResourceForWeatherCondition方法代码示例

本文整理汇总了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());
}
 
开发者ID:chi6rag,项目名称:SunshineWear,代码行数:8,代码来源:SunshineSyncAdapter.java

示例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;
}
 
开发者ID:googlecodelabs,项目名称:getting-ready-for-android-n,代码行数:42,代码来源:SunshineSyncEngine.java


注:本文中的com.example.android.sunshine.app.Utility.getIconResourceForWeatherCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。