Search in sources :

Example 1 with Result

use of com.linroid.weather.model.Result in project steps by linroid.

the class MainActivity method onAddCity.

@Override
public void onAddCity(String cityName) {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("添加中....");
    dialog.show();
    WeatherApp app = (WeatherApp) getApplication();
    WeatherService service = app.getWeatherService();
    service.getDataAsync(cityName, new Callback<Data>() {

        @Override
        public void success(Data data, Response response) {
            Result result = data.getResults().get(0);
            getContentResolver().insert(DataContract.Weather.CONTENT_URI, result.toContentValues());
            // triggerSync();
            Toast.makeText(MainActivity.this, R.string.add_city_success, Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }

        @Override
        public void failure(RetrofitError retrofitError) {
            Toast.makeText(MainActivity.this, R.string.add_city_fail, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : Response(retrofit.client.Response) WeatherService(com.linroid.weather.data.WeatherService) Data(com.linroid.weather.model.Data) ProgressDialog(android.app.ProgressDialog) Result(com.linroid.weather.model.Result) RetrofitError(retrofit.RetrofitError)

Aggregations

ProgressDialog (android.app.ProgressDialog)1 WeatherService (com.linroid.weather.data.WeatherService)1 Data (com.linroid.weather.model.Data)1 Result (com.linroid.weather.model.Result)1 RetrofitError (retrofit.RetrofitError)1 Response (retrofit.client.Response)1