示例#1
0
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    // don't call the super implementation with the layout argument, as that would set the wrong
    // theme
    super.onCreate(savedInstanceState);

    // Disable the up navigation for this activity
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);

    setContentView(R.layout.main_activity);
    ButterKnife.inject(this);

    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
      // If we had been open already, start from the last used activity.
      finish();
      return;
    }

    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); // type to search

    version = Version.getVersionCode(this);
    Log.i(
        "Starting " + getPackageName() + ' ' + version + " a.k.a " + Version.getVersionName(this));

    init();

    checkShowChangelog();
  }
示例#2
0
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, R.layout.editwaypoint_activity);

    if (StringUtils.isBlank(geocode) && waypointId <= 0) {
      showToast(res.getString(R.string.err_waypoint_cache_unknown));

      finish();
      return;
    }

    if (waypointId <= 0) {
      setTitle(res.getString(R.string.waypoint_add_title));
    } else {
      setTitle(res.getString(R.string.waypoint_edit_title));
    }

    buttonLat.setOnClickListener(new CoordDialogListener());
    buttonLon.setOnClickListener(new CoordDialogListener());

    addWaypoint.setOnClickListener(new SaveWaypointListener());

    final List<String> wayPointNames = new ArrayList<>();
    for (final WaypointType wpt : WaypointType.ALL_TYPES_EXCEPT_OWN_AND_ORIGINAL) {
      wayPointNames.add(wpt.getL10n());
    }
    final ArrayAdapter<String> adapter =
        new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, wayPointNames);
    waypointName.setAdapter(adapter);

    if (savedInstanceState != null) {
      initViews = false;
    }

    if (geocode != null) {
      cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
      setCoordsModificationVisibility(ConnectorFactory.getConnector(geocode), cache);
    }
    if (waypointId > 0) { // existing waypoint
      waitDialog = ProgressDialog.show(this, null, res.getString(R.string.waypoint_loading), true);
      waitDialog.setCancelable(true);

      (new LoadWaypointThread()).start();

    } else { // new waypoint
      initializeWaypointTypeSelector();
    }

    initializeDistanceUnitSelector();

    disableSuggestions(distanceView);
  }