Пример #1
0
  public static void showEditInstance(final Amenity amenity, final AppCompatActivity activity) {
    final OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
    final OpenstreetmapUtil openstreetmapUtilToLoad;
    if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
      OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
      openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, activity);
    } else if (!settings.isInternetConnectionAvailable(true)) {
      openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
    } else {
      openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
    }
    new AsyncTask<Void, Void, Node>() {
      @Override
      protected Node doInBackground(Void... params) {
        return openstreetmapUtilToLoad.loadNode(amenity);
      }

      protected void onPostExecute(Node n) {
        if (n != null) {
          EditPoiDialogFragment fragment = EditPoiDialogFragment.createInstance(n, amenity);
          fragment.show(activity.getSupportFragmentManager(), TAG);
        } else {
          AccessibleToast.makeText(
                  activity,
                  activity.getString(R.string.poi_error_poi_not_found),
                  Toast.LENGTH_SHORT)
              .show();
        }
      }
    }.execute();
  }
Пример #2
0
 public ShowDeleteDialogAsyncTask(AppCompatActivity activity) {
   this.activity = activity;
   OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
   OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
   if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
     openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
   } else if (!settings.isInternetConnectionAvailable(true)) {
     openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
   } else {
     openstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
   }
 }