コード例 #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
ファイル: OsmBugsLayer.java プロジェクト: Boothy99/Osmand
 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;
   }
 }
コード例 #3
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);
   }
 }
コード例 #4
0
  @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);
  }