コード例 #1
0
  public void startTimer() {

    int millis = challenge.getTimeLimit() * 1000;

    cdTimer =
        new CountDownTimer(millis, 1000) {

          public void onTick(long millisUntilFinished) {
            txtTimer.setText(app.formatTimer(millisUntilFinished));
          }

          public void onFinish() {
            txtTimer.setText("Sorry!");

            ArrayList<NameValuePair> data = new ArrayList<NameValuePair>();
            data.add(
                new BasicNameValuePair(
                    "username", settings.getString(FoggyMix.PREF_USER_NAME, "")));
            data.add(
                new BasicNameValuePair("password", settings.getString(FoggyMix.PREF_USER_PW, "")));
            data.add(new BasicNameValuePair("challengeid", String.valueOf(challenge.getId())));

            // Actual Servercall
            app.httpWorker.apiCall(getActivity(), null, data, HttpWorker.CANCEL_CHALLENGE);

            ((ChallengeDetailActivity) getActivity()).showLoading(false);
            ((ChallengeDetailActivity) getActivity()).setChallengeRunning(false);
            ChallengeLostDialog lostFragment = ChallengeLostDialog.newInstance();
            lostFragment.show(getFragmentManager(), "dialog");
          }
        }.start();
  }
コード例 #2
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 0) {
      if (resultCode == Activity.RESULT_OK) {
        String contents = intent.getStringExtra("SCAN_RESULT");
        Log.d(
            getClass().getSimpleName(),
            "contents: " + contents + " verifyCode: " + challenge.getVerifyCode());
        if (contents.equals(challenge.getVerifyCode())) {

          ((ChallengeDetailActivity) getActivity()).showLoading(true);
          btnFinished.setEnabled(false);

          ArrayList<NameValuePair> data = new ArrayList<NameValuePair>();
          data.add(
              new BasicNameValuePair("username", settings.getString(FoggyMix.PREF_USER_NAME, "")));
          data.add(
              new BasicNameValuePair("password", settings.getString(FoggyMix.PREF_USER_PW, "")));
          data.add(new BasicNameValuePair("challengeid", String.valueOf(challenge.getId())));

          // Actual Servercall
          app.httpWorker.apiCall(getActivity(), handler, data, HttpWorker.FINISH_CHALLENGE);

        } else {
          Log.d(getClass().getSimpleName(), "damn!");
          Toast.makeText(
                  getActivity(),
                  getActivity().getResources().getString(R.string.txt_invalid_verifiy_code),
                  Toast.LENGTH_LONG)
              .show();
        }
        //		         String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
      } else if (resultCode == Activity.RESULT_CANCELED) {
        // Handle cancel
      }
    }
  }
コード例 #3
0
  private void fillTextViews() {
    app.setIcon(challenge.getIcon(), imgIcon);

    app.fillTextViews(txtName, challenge.getName());
  }