Exemplo n.º 1
0
  public void onPostExecute(AnswerObject result) {
    if (scrape == null) {
      scrape = new ExamsScraper(this, result);
    } else {
      scrape.setNewAnswer(result);
    }

    try {
      setListAdapter(scrape.scrapeAdapter(mode));
    } catch (LostSessionException e) {
      Intent BackToLoginIntent = new Intent(this, TuCanMobileActivity.class);
      BackToLoginIntent.putExtra("lostSession", true);
      startActivity(BackToLoginIntent);
    } catch (TucanDownException e) {
      TucanMobile.alertOnTucanDown(this, e.getMessage());
    }

    setSpinner();
  }
Exemplo n.º 2
0
  private void setSpinner() {
    if (mode == 10 || mode == 1 || mode == 2) {

      Spinner semesterSpinner = (Spinner) findViewById(R.id.exam_semester_spinner);
      semesterSpinner.setVisibility(View.VISIBLE);
      semesterSpinner.setAdapter(scrape.spinnerAdapter());
      semesterSpinner.setOnItemSelectedListener(null);

      semesterSpinner.setSelection(scrape.SemesterOptionSelected);
      semesterSpinner.setOnItemSelectedListener(new OnItemSelectedListener());
    }
  }
Exemplo n.º 3
0
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    if (scrape != null && mode == 0) {
      SimpleSecureBrowser callOverviewBrowser = new SimpleSecureBrowser(this);
      RequestObject thisRequest;
      switch (position) {
        case 0:
          mode = 10;
          thisRequest =
              new RequestObject(
                  TucanMobile.TUCAN_PROT + TucanMobile.TUCAN_HOST + scrape.examLinks.get(0),
                  scrape.getCookieManager(),
                  RequestObject.METHOD_GET,
                  "");
          callOverviewBrowser.execute(thisRequest);
          break;
        case 1:
          mode = 1;
          Log.i(LOG_TAG, "Exam Names hat: " + scrape.examNames.size() + " Elemente");

          thisRequest =
              new RequestObject(
                  TucanMobile.TUCAN_PROT + TucanMobile.TUCAN_HOST + scrape.examLinks.get(1),
                  scrape.getCookieManager(),
                  RequestObject.METHOD_GET,
                  "");
          callOverviewBrowser.execute(thisRequest);
          Log.i(LOG_TAG, "Exam Names hat: " + scrape.examNames.size() + " Elemente");
          break;
        case 2:
          mode = 2;
          Log.i(LOG_TAG, "Exam Names hat: " + scrape.examNames.size() + " Elemente");
          thisRequest =
              new RequestObject(
                  TucanMobile.TUCAN_PROT + TucanMobile.TUCAN_HOST + scrape.examLinks.get(2),
                  scrape.getCookieManager(),
                  RequestObject.METHOD_GET,
                  "");
          callOverviewBrowser.execute(thisRequest);
          Log.i(LOG_TAG, "Exam Names hat: " + scrape.examNames.size() + " Elemente");
          break;
        case 3:
          mode = 3;
          thisRequest =
              new RequestObject(
                  TucanMobile.TUCAN_PROT + TucanMobile.TUCAN_HOST + scrape.examLinks.get(3),
                  scrape.getCookieManager(),
                  RequestObject.METHOD_GET,
                  "");
          callOverviewBrowser.execute(thisRequest);
          break;
        case 4:
          Intent callRegisterExams = new Intent(this, RegisterExams.class);
          callRegisterExams.putExtra("URL", scrape.examLinks.get(4));
          callRegisterExams.putExtra(
              "Cookie", scrape.getCookieManager().getCookieHTTPString(TucanMobile.TUCAN_HOST));
          callRegisterExams.putExtra("UserName", UserName);
          startActivity(callRegisterExams);
          // TODO: Call RegisterEvents
        default:
          break;
      }
    }
  }