示例#1
0
 @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();
   }
 }
示例#2
0
 @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();
   }
 }
示例#3
0
 @Override
 public void onCityDelete(final City city) {
   final IActionUI context = this;
   // TODO: delete city on long press
   AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setTitle("Remove " + city.getName() + "?");
   builder.setPositiveButton(
       android.R.string.yes,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           // Start delete task!
           new DeleteCityThread(dataBase, city, context).start();
           dialog.dismiss();
         }
       });
   builder.setNegativeButton(
       android.R.string.no,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           dialog.dismiss();
         }
       });
   AlertDialog dialog = builder.create();
   dialog.show();
 }
示例#4
0
 @Override
 public void CitySaved(City city) {
   if (city != null) {
     if (city.getName() != null) {
       menuFragment.addCity(city);
       dialogFragment.dismiss();
     }
   } else {
     Toast.makeText(
             this.getApplicationContext(),
             "This city already is in your Favourites",
             Toast.LENGTH_SHORT)
         .show();
   }
 }