コード例 #1
0
  @Override
  public void onFinish() {
    if (MyCredentials.Me == null) {
      // this can only happen, if user is not connected to the internet:
      msg_txt.setText(getResources().getString(R.string.no_connection));
      retry_btn.setVisibility(View.VISIBLE);
      retry_btn.setActivated(true);
      return;
    }
    LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (!service.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
      msg_txt.setText(getResources().getString(R.string.no_location));
      retry_btn.setVisibility(View.VISIBLE);
      retry_btn.setActivated(true);
      return;
    }

    if (loadingView != null) loadingView.stopAnimation();

    if (MyCredentials.Me.getProfile() != null
        && MyCredentials.Me.getProfile().getCity_id() != null) {
      Uri data = getIntent().getData();
      if (data != null) {
        List<String> params = data.getPathSegments();
        Intent intent = new Intent(this, TabActivity.class);
        intent.putExtra("USER", params.get(params.size() - 1));
        startActivity(intent);
      } else {
        startMainActivity();
      }
    } else {
      if (loadingView != null) loadingView.startAnimation();
      Log.i("Entry", "no city for user exists");
      getFragmentManager()
          .beginTransaction()
          .replace(R.id.select_city_container, new SelectCityFragment())
          .commit();
    }
  }
コード例 #2
0
  private void guiInit() {
    loadingView = (LoadingView) findViewById(R.id.loading_view);
    loadingView.startAnimation();
    msg_txt = (TextView) findViewById(R.id.msg_txt);

    retry_btn = (Button) findViewById(R.id.retry_btn);
    retry_btn.setVisibility(View.GONE);
    retry_btn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            myCredentials.getMe(true);
            retry_btn.setActivated(false);
          }
        });

    myCredentials = new MyCredentials(this, this);
  }