예제 #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.credits) {
      startActivity(new Intent(this, LegalNoticesActivity.class));

      return (true);
    } else if (item.getItemId() == R.id.satellite) {
      ViewMapFragment mMapFragment =
          (ViewMapFragment) getSupportFragmentManager().findFragmentByTag("map");
      mMapFragment.changeView(ViewMapFragment.MapType.Satellite);

    } else if (item.getItemId() == R.id.hybrid) {
      ViewMapFragment mMapFragment =
          (ViewMapFragment) getSupportFragmentManager().findFragmentByTag("map");
      mMapFragment.changeView(ViewMapFragment.MapType.Hybrid);
    } else if (item.getItemId() == R.id.map_only) {
      ViewMapFragment mMapFragment =
          (ViewMapFragment) getSupportFragmentManager().findFragmentByTag("map");
      mMapFragment.changeView(ViewMapFragment.MapType.Map);
    } else if (item.getItemId() == R.id.terrain) {
      ViewMapFragment mMapFragment =
          (ViewMapFragment) getSupportFragmentManager().findFragmentByTag("map");
      mMapFragment.changeView(ViewMapFragment.MapType.Terrain);
    } else if (item.getItemId() == R.id.add_new) {
      if (isOnline()) {
        if (PreferenceManager.getDefaultSharedPreferences(this)
            .getString("accessToken", "")
            .equals("")) {
          FragmentManager fm = getSupportFragmentManager();
          OAuthFragmentDialog oAuthFragmentDialog = OAuthFragmentDialog.newInstance();
          oAuthFragmentDialog.show(fm, "fragment_login");
        } else {
          // TODO verify token
          if (adview != null) {
            // adview.destroy();
            adview.setVisibility(View.GONE);
          }
          addNewNode();
        }
      }

    } else if (item.getItemId() == R.id.menu_settings) {
      // launch prefs
      Intent gopref = new Intent(this, PreferencesActivity.class);
      gopref.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(gopref);
      finish();
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
예제 #2
0
 /** Login success for map editing */
 @Override
 public void onSuccess() {
   // TODO verify token
   addNewNode();
 }