@Override public void onCitySelected(City city) { if (isBigDisplay) { weatherFragment.setArgs(city.getName(), city.getId()); } else { weatherFragment = WeatherFragment.newInstance(city.getName(), city.getId()); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragment, weatherFragment) .addToBackStack(null) .commit(); } }
@Override public void onCityAdd(City city) { if (city != null) { if (city.getName() != null && city.getId() > 0) { if (!city.getName().isEmpty()) { // save City in DB SaveCityTask thread = new SaveCityTask(city, dataBase, this); thread.execute(); } else { Toast.makeText( this.getApplicationContext(), "Weather is available only for settlements", Toast.LENGTH_SHORT) .show(); } } else { Toast.makeText( this.getApplicationContext(), "Retry search with analogue", Toast.LENGTH_SHORT) .show(); } } else { Toast.makeText( this.getApplicationContext(), "Press find and choose city from list", Toast.LENGTH_SHORT) .show(); } }