本文整理汇总了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) {
//
// }
// });
}
示例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);
}