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