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


Java Utility.getArtUrlForWeatherCondition方法代码示例

本文整理汇总了Java中com.example.android.sunshine.app.Utility.getArtUrlForWeatherCondition方法的典型用法代码示例。如果您正苦于以下问题:Java Utility.getArtUrlForWeatherCondition方法的具体用法?Java Utility.getArtUrlForWeatherCondition怎么用?Java Utility.getArtUrlForWeatherCondition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.example.android.sunshine.app.Utility的用法示例。


在下文中一共展示了Utility.getArtUrlForWeatherCondition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPostExecute

import com.example.android.sunshine.app.Utility; //导入方法依赖的package包/类
@Override
    protected void onPostExecute(final Weather s) {
        super.onPostExecute(s);
        int weatherId = s.getWeatherId();
        String artUrl = Utility.getArtUrlForWeatherCondition(SunshineApp.getContext(), weatherId);
        DataMap config = new DataMap();
        config.putString(KEY_WEATHER_LOW_TEMP, s.getLow());
        config.putString(KEY_WEATHER_MAX_TEMP, s.getHigh());
        weatherListener.sendWeatherData(config);
        int artResourceId = Utility.getArtResourceForWeatherCondition(weatherId);
        weatherListener.sendWeatherIcon(Utility.getResizedBitmap(BitmapFactory.decodeResource(SunshineApp.getContext().getResources(), artResourceId),40,40));
//        Glide
//            .with(SunshineApp.getContext())
//            .load(artUrl)
//                .asBitmap()
//                .into(new SimpleTarget<Bitmap>(40,40) {
//                    @Override
//                    public void onResourceReady(Bitmap weatherBitmap, GlideAnimation glideAnimation) {
//
//                    }
//                });

    }
 
开发者ID:PedroCarrillo,项目名称:sunshine-wear-watchface,代码行数:24,代码来源:TodayWeatherAsyncTask.java

示例2: notifyWearable

import com.example.android.sunshine.app.Utility; //导入方法依赖的package包/类
private void notifyWearable() {
    final Context context = getContext();
    final String preferredLocation = Utility.getPreferredLocation(getContext());

    final Uri uri = WeatherContract.WeatherEntry.buildWeatherLocationWithDate(preferredLocation, System.currentTimeMillis());
    Cursor query = context.getContentResolver().query(uri, WEARABLE_WEATHER_PROJECTION, null, null, null);

    if (null == query) {
        return;
    }

    if(!query.moveToFirst()){
        query.close();
        return;
    }

    PutDataMapRequest sendRequest = PutDataMapRequest.create("/SunshineWearListenerService/Data");

    double highTemp = query.getDouble(INDEX_MAX_TEMP);
    double lowTemp = query.getDouble(INDEX_MIN_TEMP);

    int highTempInt = Utility.isMetric(context) ? (int)highTemp : (int)((highTemp * 1.8) + 32);
    int lowTempInt = Utility.isMetric(context) ? (int)lowTemp : (int)((lowTemp * 1.8) + 32);

    sendRequest.getDataMap().putInt("dataHigh", highTempInt);
    sendRequest.getDataMap().putInt("dataLow", lowTempInt);
    sendRequest.getDataMap().putLong("dataTime", System.currentTimeMillis());

    final ByteArrayOutputStream imageBytes = new ByteArrayOutputStream();
    String artUrl = Utility.getArtUrlForWeatherCondition(context, query.getInt(INDEX_WEATHER_ID));

    int artResourceId = Utility.getArtResourceForWeatherCondition(query.getInt(INDEX_WEATHER_ID));
    int size = context.getResources().getDimensionPixelSize(R.dimen.wearable_large_icon_default);

    try {
        Bitmap weatherIcon = Glide.with(context)
                .load(artUrl)
                .asBitmap()
                .error(artResourceId)
                .fitCenter()
                .into(size, size)
                .get();

        weatherIcon.compress(Bitmap.CompressFormat.PNG, 100, imageBytes);
        Asset weatherIconAsset = Asset.createFromBytes(imageBytes.toByteArray());
        sendRequest.getDataMap().putAsset("dataIcon", weatherIconAsset);
    } catch(Exception ex){
        Log.e(LOG_TAG, ex.toString());
    }

    PutDataRequest putDataRequest = sendRequest.asPutDataRequest();

    GoogleApiClient googleApiClient = getGoogleApiClient();
    googleApiClient.connect();

    Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
}
 
开发者ID:hieple7985,项目名称:nano-go-ubiquitous,代码行数:58,代码来源:SunshineSyncAdapter.java


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