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();
  }
Exemple #2
0
 public OsmBugsUtil getOsmbugsUtil(OpenStreetNote bug) {
   OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
   if ((bug != null && bug.isLocal())
       || settings.OFFLINE_EDITION.get()
       || !settings.isInternetConnectionAvailable(true)) {
     return local;
   } else {
     return remote;
   }
 }
 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);
   }
 }
  @Override
  public void onAttach(Activity activity) {
    super.onAttach(activity);
    OsmandSettings settings = getMyApplication().getSettings();
    OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
    if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
      mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
    } else if (!settings.isInternetConnectionAvailable(true)) {
      mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
    } else {
      mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
    }

    node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE);
    allTranslatedSubTypes = getMyApplication().getPoiTypes().getAllTranslatedNames();

    Amenity amenity = (Amenity) getArguments().getSerializable(KEY_AMENITY);
    editPoiData = new EditPoiData(amenity, node, allTranslatedSubTypes);
  }