コード例 #1
0
ファイル: MainActivity.java プロジェクト: pikaso19/Weather1
 @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();
   }
 }
コード例 #2
0
ファイル: MainActivity.java プロジェクト: pikaso19/Weather1
 @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();
   }
 }