예제 #1
0
  /** 打开配置对话框. */
  public void openSettingDlg() {
    daemonSignal++;
    spinnerStop();
    if (settingDialog != null && settingDialog.isShowing()) {
      return;
    }

    Builder settingBuilder = new AlertDialog.Builder(this);
    settingBuilder.setTitle(R.string.settingDlgTitle);
    final TableLayout loginSettingForm =
        (TableLayout) getLayoutInflater().inflate(R.layout.settingdlg, null);
    settingBuilder.setView(loginSettingForm);
    settingBuilder.setPositiveButton(
        R.string.save,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            String url =
                StringUtils.toBj(
                    ((EditText) loginSettingForm.findViewById(R.id.url)).getText().toString());
            String newUser =
                ((EditText) loginSettingForm.findViewById(R.id.userName)).getText().toString();
            String newPassword =
                ((EditText) loginSettingForm.findViewById(R.id.password)).getText().toString();

            sharedEditor.putString(F_URL, url);
            sharedEditor.putString(F_USERNAME, newUser);
            sharedEditor.putString(F_PASSWORD, newPassword);
            sharedEditor.commit();
            contentWebView.clearView();
            dialog.dismiss();
            loadSystem();
          }
        });
    settingBuilder.setNegativeButton(
        R.string.close,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            System.out.println(loadSuccess);
            System.out.println(PortalActivity.this.loadSuccess);
            if (!loadSuccess) {
              confirmExit();
            }
          }
        });

    String url = sharedPreferences.getString(F_URL, DF_URL);
    url = StringUtils.toBj(url);
    String userName = sharedPreferences.getString(F_USERNAME, DF_USERNAME);
    String password = sharedPreferences.getString(F_PASSWORD, DF_PASSWORD);

    ((EditText) loginSettingForm.findViewById(R.id.url)).setText(url);
    ((EditText) loginSettingForm.findViewById(R.id.userName)).setText(userName);
    ((EditText) loginSettingForm.findViewById(R.id.password)).setText(password);
    settingDialog = settingBuilder.create();
    settingDialog.show();
  }
예제 #2
0
  /**
   * -=========================================/ generateOutput() -- Fill R.id.numberBox with bases
   * and squares and cubes. Note that this method simply assumes that start >= end. This should
   * always be the case, as setLimits() does this error checking.
   * /==========================================-
   */
  private void generateOutput(int start, int end) {
    ViewGroup.LayoutParams widthHeightSettings =
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    // I will later pass this object to TableRows (as they are created) to define their width and
    // height.
    TableLayout numberContainer = (TableLayout) findViewById(R.id.numberBox);
    numberContainer.removeAllViews();
    int row, column;
    Context appContext = getApplicationContext();

    for (row = 0; row <= (end - start); row++) {
      // Create a TableRow row.
      TableRow aRow = new TableRow(appContext);
      aRow.setId(row);
      aRow.setLayoutParams(widthHeightSettings);
      numberContainer.addView(aRow);

      for (column = 0; column < 3; column++) {
        // Create a TextView column, and place it in the just-created TableRow row.
        TextView aNumber = new TextView(appContext);
        // aNumber.setLayoutParams(widthHeightSettings);
        // Fails. I don't know why.
        aNumber.setText(Double.toString(Math.pow(start + row, 1 + column)));
        ((TableRow) numberContainer.findViewById(row)).addView(aNumber);
      }
    }
  }
예제 #3
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Retrieve course object and associated semester.
    s = (Show) getIntent().getExtras().getSerializable("show");
    setContentView(R.layout.show);

    // Show details
    TextView showName = (TextView) findViewById(R.id.show_name);
    showName.setText(s.getName());

    TableLayout details = (TableLayout) findViewById(R.id.info_table);
    TextView classification = (TextView) details.findViewById(R.id.classi);
    classification.setText(s.getClassification());

    TextView genres = (TextView) details.findViewById(R.id.genres);
    genres.setText(s.getGenreString());

    TextView airs = (TextView) details.findViewById(R.id.airs);
    airs.setText(s.getAirInfo());

    TextView runtime = (TextView) details.findViewById(R.id.runtime);
    runtime.setText(s.getRuntime() + " min");

    // Episodes
    TableLayout eps = (TableLayout) findViewById(R.id.ep_table);
    TextView last = (TextView) eps.findViewById(R.id.lastEp);
    last.setText(s.getLastEpisode());

    TextView next = (TextView) eps.findViewById(R.id.nextEp);
    next.setText(s.getNextEpisode());

    ExpandableListView seas = (ExpandableListView) findViewById(R.id.season_list);
    mAdapter = new SeasonListAdapter();
    seas.setAdapter(mAdapter);
    seas.setOnChildClickListener(
        new OnChildClickListener() {
          public boolean onChildClick(ExpandableListView parent, View v, int s, int e, long id) {
            Intent browse =
                new Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse(((SeasonListAdapter) mAdapter).getChild(s, e).getLink()));
            startActivity(browse);
            return true;
          }
        });
  }
예제 #4
0
  private void setUpCourseTable() {
    isHoliday = false;
    isNight = false;
    isHolidayNight = false;
    isB = false;
    isHolidayB = false;

    mScrollView.removeAllViews();
    if (mList.size() == 0) {
      if (isRetry) {
        mNoCourseTextView.setText(R.string.click_to_retry);
      } else {
        mNoCourseTextView.setText(getString(R.string.course_no_course, "\uD83D\uDE0B"));
      }
      mProgressWheel.setVisibility(View.GONE);
      mSwipeRefreshLayout.setEnabled(true);
      mSwipeRefreshLayout.setRefreshing(false);
      mNoCourseLinearLayout.setVisibility(View.VISIBLE);
      mScrollView.setVisibility(View.VISIBLE);
      mHolidayTextView.setVisibility(View.GONE);
      return;
    } else {
      mNoCourseLinearLayout.setVisibility(View.GONE);
    }
    checkCourseTableType();
    TableLayout table = selectCourseTable();

    for (int i = 0; i < mList.size(); i++) {
      if (mList.get(i) != null) {
        for (int j = 0; j < mList.get(i).size(); j++) {
          int id =
              getResources().getIdentifier("textView" + j + "_" + (i + 1), "id", getPackageName());
          final TextView courseTextView = (TextView) table.findViewById(id);
          if (mList.get(i).get(j) != null) {
            if (courseTextView == null) {
              continue;
            }
            courseTextView.setText(mList.get(i).get(j).title.substring(0, 2));

            final int weekday = i;
            final int section = j;
            courseTextView.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    showCourseDialog(weekday, section);
                  }
                });
          } else {
            if (courseTextView != null) {
              courseTextView.setText("  ");
            }
          }
        }
      } else {
        List<String> sections =
            new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.course_sections)));
        for (int j = 0; j < sections.size(); j++) {
          int id =
              getResources().getIdentifier("textView" + j + "_" + (i + 1), "id", getPackageName());
          final TextView courseTextView = (TextView) table.findViewById(id);
          if (courseTextView != null) {
            courseTextView.setText("  ");
          }
        }
      }
    }

    mScrollView.addView(table);
    mProgressWheel.setVisibility(View.GONE);
    mSwipeRefreshLayout.setEnabled(true);
    mSwipeRefreshLayout.setRefreshing(false);
    mScrollView.setVisibility(View.VISIBLE);
  }
예제 #5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.results);

    resultsTable = (TableLayout) findViewById(R.id.relativeLayout1).findViewById(R.id.tableLayout1);

    TableRow tr = (TableRow) resultsTable.findViewById(R.id.tableRow2);
    TextView tv = (TextView) tr.findViewById(R.id.textView2_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa1"));
    tv = (TextView) tr.findViewById(R.id.textView2_3);
    tv.setText((String) plikWynikowy.getProperty("wynik1"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow3);
    tv = (TextView) tr.findViewById(R.id.textView3_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa2"));
    tv = (TextView) tr.findViewById(R.id.textView3_3);
    tv.setText((String) plikWynikowy.getProperty("wynik2"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow4);
    tv = (TextView) tr.findViewById(R.id.textView4_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa3"));
    tv = (TextView) tr.findViewById(R.id.textView4_3);
    tv.setText((String) plikWynikowy.getProperty("wynik3"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow5);
    tv = (TextView) tr.findViewById(R.id.textView5_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa4"));
    tv = (TextView) tr.findViewById(R.id.textView5_3);
    tv.setText((String) plikWynikowy.getProperty("wynik4"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow6);
    tv = (TextView) tr.findViewById(R.id.textView6_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa5"));
    tv = (TextView) tr.findViewById(R.id.textView6_3);
    tv.setText((String) plikWynikowy.getProperty("wynik5"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow7);
    tv = (TextView) tr.findViewById(R.id.textView7_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa6"));
    tv = (TextView) tr.findViewById(R.id.textView7_3);
    tv.setText((String) plikWynikowy.getProperty("wynik6"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow8);
    tv = (TextView) tr.findViewById(R.id.textView8_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa7"));
    tv = (TextView) tr.findViewById(R.id.textView8_3);
    tv.setText((String) plikWynikowy.getProperty("wynik7"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow9);
    tv = (TextView) tr.findViewById(R.id.textView9_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa8"));
    tv = (TextView) tr.findViewById(R.id.textView9_3);
    tv.setText((String) plikWynikowy.getProperty("wynik8"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow10);
    tv = (TextView) tr.findViewById(R.id.textView10_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa9"));
    tv = (TextView) tr.findViewById(R.id.textView10_3);
    tv.setText((String) plikWynikowy.getProperty("wynik9"));

    tr = (TableRow) resultsTable.findViewById(R.id.tableRow11);
    tv = (TextView) tr.findViewById(R.id.textView11_2);
    tv.setText((String) plikWynikowy.getProperty("wynikNazwa10"));
    tv = (TextView) tr.findViewById(R.id.textView11_3);
    tv.setText((String) plikWynikowy.getProperty("wynik10"));

    findViewById(R.id.relativeLayout1)
        .findViewById(R.id.button1)
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                setResult(RESULT_OK);
                finish();
              }
            });
  }