コード例 #1
0
  @Override
  public void citySelected(City city) {
    // update user profile!
    MyCredentials.Me.getProfile().setCity_id(city.getId());
    final CustomAsyncTask asyncTask = new CustomAsyncTask(this);
    asyncTask.setTaskCallBacks(
        new TaskCallBacks() {
          @Override
          public String doInBackground() {
            TMultiplexedProtocol mp = null;
            try {
              mp = asyncTask.openTransport(SuperAsyncTask.SERVICE_USER);
              UserSvc.Client client = new UserSvc.Client(mp);
              client.setProfile(myCredentials.getToken(), MyCredentials.Me.getProfile());
            } catch (Exception e) {
              e.printStackTrace();
            }
            return null;
          }

          @Override
          public void onPreExecute() {}

          @Override
          public void onPostExecute() {
            loadingView.stopAnimation();
            startMainActivity();
          }
        });
    asyncTask.execute();
  }
コード例 #2
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();
    }
  }