コード例 #1
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == START_ACTIVITY_LIST) {
     if (resultCode == Activity.RESULT_OK) {
       completedCount = data.getIntExtra("count", 0);
       trainee.setTotalCompleted(trainee.getTotalCompleted() + completedCount);
       Log.i(LOG, "onActivityResult setting activity count " + completedCount);
       courseListFragment.setActivityCompleted(completedCount);
     }
   }
 }
コード例 #2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_skills:
        Intent i = new Intent(this, TraineeSkillsActivity.class);
        i.putExtra("trainee", trainee);
        Log.i(
            LOG,
            "@@@@@@@@ about to start TraineeSkillsActivity skills: "
                + trainee.getTraineeSkillList().size());
        startActivity(i);

        return true;
      case R.id.menu_refresh:
        getTraineeData();
        return true;
      case R.id.menu_info:
        return true;

      case android.R.id.home:
        Intent intent = new Intent(this, MainPagerActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
コード例 #3
0
  private void getTraineeData() {

    RequestDTO req = new RequestDTO();
    req.setRequestType(RequestDTO.GET_TRAINEE_DATA);
    req.setTraineeID(trainee.getTraineeID());
    req.setTrainingClassID(trainee.getTrainingClassID());
    req.setCompanyID(trainee.getCompanyID());
    req.setCountryCode(Locale.getDefault().getCountry());

    if (!BaseVolley.checkNetworkOnDevice(ctx)) return;
    setRefreshActionButtonState(true);
    WebSocketUtil.sendRequest(
        ctx,
        Statics.INSTRUCTOR_ENDPOINT,
        req,
        new WebSocketUtil.WebSocketListener() {
          @Override
          public void onMessage(final ResponseDTO response) {
            runOnUiThread(
                new Runnable() {
                  @Override
                  public void run() {
                    setRefreshActionButtonState(false);
                    if (response.getStatusCode() > 0) {
                      ToastUtil.errorToast(ctx, response.getMessage());
                      return;
                    }
                    for (TraineeDTO t : response.getTraineeList()) {
                      if (t.getTraineeID() == trainee.getTraineeID()) {
                        trainee = t;
                        break;
                      }
                    }
                    courseListFragment.setData(response);
                  }
                });
          }

          @Override
          public void onClose() {}

          @Override
          public void onError(final String message) {
            runOnUiThread(
                new Runnable() {
                  @Override
                  public void run() {
                    setRefreshActionButtonState(false);
                    ToastUtil.errorToast(ctx, message);
                  }
                });
          }
        });
    //		BaseVolley.getRemoteData(Statics.SERVLET_TRAINEE, req, ctx, new
    // BaseVolley.BohaVolleyListener() {
    //
    //			@Override
    //			public void onVolleyError(VolleyError error) {
    //				setRefreshActionButtonState(false);
    //				ToastUtil.errorToast(ctx, ctx.getResources().getString(R.string.error_server_comms));
    //			}
    //
    //			@Override
    //			public void onResponseReceived(ResponseDTO response) {
    //				setRefreshActionButtonState(false);
    //				if (response.getStatusCode() > 0) {
    //					ToastUtil.errorToast(ctx, response.getMessage());
    //					return;
    //				}
    //				courseListFragment.setData(response);
    //			}
    //		});
  }