use of wangdaye.com.geometricweather.data.entity.model.Location in project GeometricWeather by WangDaYeeeeee.
the class MainActivity method onNewIntent.
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Location old = locationNow;
readLocationList();
readIntentData(intent);
if (!old.equals(locationNow)) {
reset();
}
}
use of wangdaye.com.geometricweather.data.entity.model.Location in project GeometricWeather by WangDaYeeeeee.
the class ManageActivity method deleteLocation.
private void deleteLocation(int position) {
Location item = adapter.itemList.get(position);
if (adapter.itemList.size() <= 1) {
adapter.removeData(position);
adapter.insertData(item, position);
SnackbarUtils.showSnackbar(getString(R.string.feedback_location_list_cannot_be_null));
} else {
Location location = adapter.itemList.get(position);
adapter.removeData(position);
DatabaseHelper.getInstance(ManageActivity.this).deleteLocation(item);
SnackbarUtils.showSnackbar(getString(R.string.feedback_delete_succeed), getString(R.string.cancel), new CancelDeleteListener(location));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutsManager.refreshShortcuts(ManageActivity.this, adapter.itemList);
}
}
}
use of wangdaye.com.geometricweather.data.entity.model.Location in project GeometricWeather by WangDaYeeeeee.
the class TileHelper method refreshTile.
/**
* <br> UI.
*/
@RequiresApi(api = Build.VERSION_CODES.N)
public static void refreshTile(Context context, Tile tile) {
if (tile == null) {
return;
}
Location location = DatabaseHelper.getInstance(context).readLocationList().get(0);
location.weather = DatabaseHelper.getInstance(context).readWeather(location);
if (location.weather != null) {
boolean f = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.key_fahrenheit), false);
tile.setIcon(Icon.createWithResource(context, WeatherHelper.getNotificationWeatherIcon(location.weather.realTime.weatherKind, TimeManager.getInstance(context).isDayTime())));
tile.setLabel(ValueUtils.buildCurrentTemp(location.weather.realTime.temp, false, f));
tile.updateTile();
}
}
Aggregations