예제 #1
0
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.btnAddPeople:
        final TableRow tr = new TableRow(this);
        tr.setId(1);

        EditText editText = new EditText(this);
        editText.setId(200);
        editText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
        editText.setMinWidth(100);
        //			labelTV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
        // LayoutParams.WRAP_CONTENT));

        tr.addView(editText);
        editText.requestFocus();

        Button deleteButton = new Button(this);
        deleteButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.delete));
        deleteButton.setId(200);
        deleteButton.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                tblPersons.removeView(tr);
              }
            });

        tr.addView(deleteButton);

        tblPersons.addView(tr);

        break;
      case R.id.btnContinue:
        String names = "";

        for (int i = 0; i < tblPersons.getChildCount(); i++) {
          TableRow row = (TableRow) tblPersons.getChildAt(i);
          String name = ((EditText) (row.getChildAt(0))).getText().toString();
          if (name != null && name.trim() != "") {
            names = names + name.trim();
          }

          if (i < tblPersons.getChildCount() - 1) {
            names = names + ",";
          }
        }

        System.out.println("!!!!!!!!!!names:" + names);

        Intent intentExpenses = new Intent();
        intentExpenses.setClassName("com.expenses", "com.expenses.ExpensesShareActivity");
        intentExpenses.putExtra("com.expenses.PersonNames", names);
        startActivity(intentExpenses);

        break;
      default:
        break;
    }
  }
 private BaseSkillEditor findSkillEditor(ISkill sk) {
   TableLayout tableSkills = (TableLayout) findViewById(R.id.tableSkills);
   int rows = tableSkills.getChildCount();
   for (int i = 0; i < rows; i++) {
     BaseSkillEditor editor = (BaseSkillEditor) tableSkills.getChildAt(i);
     if (editor.isEditorFor(sk)) return editor;
   }
   return null;
 }
예제 #3
0
  /**
   * * Get the ImageView (cell) from the given coordinates
   *
   * @param row
   * @param col
   * @return
   */
  private ImageView getCaseView(int row, int col) {
    ImageView imgView;

    // Get case view from coord.
    TableRow tableRow = (TableRow) tableLayout.getChildAt(row);
    imgView = (ImageView) tableRow.getChildAt(col);

    // if (view instanceof TableRow) //Peut etre mieux

    return imgView;
  }
  /**
   * Set the visibility of the extra metadata view.
   *
   * @param visible True to show, false to hide
   */
  private void setExtraInfoVisible(boolean visible) {
    TableLayout table = mInfoTable;
    if (table == null) return;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD_MR1) visible = false;

    table.setColumnCollapsed(0, !visible);
    // Make title, album, and artist multi-line when extra info is visible
    boolean singleLine = !visible;
    for (int i = 0; i != 3; ++i) {
      TableRow row = (TableRow) table.getChildAt(i);
      ((TextView) row.getChildAt(1)).setSingleLine(singleLine);
    }
    // toggle visibility of all but the first three rows (the title/artist/
    // album rows) and the last row (the seek bar)
    int visibility = visible ? View.VISIBLE : View.GONE;
    for (int i = table.getChildCount() - 1; --i != 2; ) {
      table.getChildAt(i).setVisibility(visibility);
    }
    mExtraInfoVisible = visible;
    if (visible && !mHandler.hasMessages(MSG_LOAD_EXTRA_INFO)) {
      mHandler.sendEmptyMessage(MSG_LOAD_EXTRA_INFO);
    }
  }
예제 #5
0
  /**
   * * Get move with coords relative to the view supplied
   *
   * @param view : is a ImageView (cell) in a rowView in a TableLayout
   * @return move coordinates
   */
  private Move getMoveFromCase(ImageView view) {
    Move move = null;

    for (int j = 0; j < tableLayout.getChildCount(); j++) {
      TableRow rowView = (TableRow) tableLayout.getChildAt(j);
      for (int i = 0; i < rowView.getChildCount(); i++) {
        if (view.equals(rowView.getChildAt(i))) { // verifier la comparaison
          move = new Move(j, i);
        }
      }
    }

    return move;
  }
예제 #6
0
  /**
   * Filters result table rows by given bus line. Filtered bus lines are hidden. If given bus line
   * is null then all result table rows are shown.
   *
   * @param busLine is the bus line number which will be shown in results
   */
  private void filterResultTable(String busLine) {

    TableLayout scrollableLayout = (TableLayout) findViewById(R.id.ScrollableTableLayout);
    // if busLine isn't null show only wanted bus line else show all
    if (busLine != null) {
      CharSequence line = busLine;
      for (int i = 0; i < scrollableLayout.getChildCount(); i++) {
        TableRow row = (TableRow) scrollableLayout.getChildAt(i);
        if (((TextView) row.getChildAt(0)).getText().equals(line)) {
          row.setVisibility(View.VISIBLE);
        } else {
          row.setVisibility(View.GONE);
        }
      }
    } else {
      for (int i = 0; i < scrollableLayout.getChildCount(); i++) {
        TableRow row = (TableRow) scrollableLayout.getChildAt(i);
        row.setVisibility(View.VISIBLE);
      }
    }
    // setting table to visible because it was set invisible in data retrieval
    scrollableLayout.setVisibility(View.VISIBLE);
  }
  public void altTableRow(int alt_row) {
    int childViewCount = tablelayout.getChildCount();

    for (int i = 0; i < childViewCount; i++) {
      TableRow row = (TableRow) tablelayout.getChildAt(i);

      for (int j = 0; j < row.getChildCount(); j++) {

        TextView tv = (TextView) row.getChildAt(j);
        if (i % alt_row != 0) {
          tv.setBackground(getResources().getDrawable(R.drawable.alt_row_color));
        } else {
          tv.setBackground(getResources().getDrawable(R.drawable.row_color));
        }
      }
    }
  }
  private static TableRow findProductTableRow(TableLayout tableLayout, dbProduct product) {
    // Get the number of rows in the table
    int rowCount = tableLayout.getChildCount();

    // Loop through the rows in the table searching for the one
    // with the matching product
    for (int rowIndex = 1; rowIndex < rowCount; rowIndex++) {
      // Get the row at the index
      TableRow row = (TableRow) tableLayout.getChildAt(rowIndex);

      // Test if the tag matches - if it does return the row
      if (row.getTag().equals(product)) {
        return row;
      }
    }

    // Row was not found therefore return null
    return null;
  }
 private void updateColor(String psType) {
   ColorNameService oColors = new ColorNameService();
   Map<String, String> mapColors = oColors.getAllType();
   String psColor = mapColors.get(psType);
   TableRow oRow = (TableRow) moEditTable.getChildAt(this.miLine);
   LinearLayout oCellName =
       (LinearLayout) oRow.getChildAt(getResources().getInteger(R.integer.IDX_NAME));
   TextView oTxtName = (TextView) oCellName.getChildAt(0);
   ImageView oImgColor = (ImageView) oCellName.getChildAt(1);
   LinearLayout oCellId =
       (LinearLayout) oRow.getChildAt(getResources().getInteger(R.integer.IDX_ID));
   TextView oTxtId = (TextView) oCellId.getChildAt(0);
   Log.d("TYPE", psType);
   Log.d("COLOR", psColor == null ? "NULL" : psColor);
   oTxtName.setTextColor(Color.parseColor(psColor));
   oImgColor.setBackgroundColor(Color.parseColor(psColor));
   MoyenFragment oMoyenFrag = MoyenFragment.getInstance();
   oMoyenFrag.changeColor(oTxtId.getText().toString(), psColor);
 }
예제 #10
0
 private void loadNextFlag() {
   String nextImageName = quizCountriesList.remove(0);
   correctAnswer = nextImageName;
   answerTextView.setText("");
   questionNumberTextView.setText(
       getResources().getString(R.string.question)
           + " "
           + (correctAnswers + 1)
           + " "
           + getResources().getString(R.string.of)
           + " 10");
   String region = nextImageName.substring(0, nextImageName.indexOf('-'));
   AssetManager assets = getAssets();
   InputStream stream;
   try {
     stream = assets.open(region + "/" + nextImageName + ".png");
     Drawable flag = Drawable.createFromStream(stream, nextImageName);
     flagImageView.setImageDrawable(flag);
   } catch (IOException e) {
     Log.e(TAG, "Error loading " + nextImageName, e);
   }
   for (int row = 0; row < buttonTableLayout.getChildCount(); ++row)
     ((TableRow) buttonTableLayout.getChildAt(row)).removeAllViews();
   Collections.shuffle(filenameList);
   int correct = filenameList.indexOf(correctAnswer);
   filenameList.add(filenameList.remove(correct));
   LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   for (int row = 0; row < guessRows; row++) {
     TableRow currentTableRow = getTableRow(row);
     for (int column = 0; column < 3; column++) {
       Button newGuessButton = (Button) inflater.inflate(R.layout.guess_button, null);
       String fileName = filenameList.get((row * 3) + column);
       newGuessButton.setText(getCountryName(fileName));
       newGuessButton.setOnClickListener(guessButtonListener);
       currentTableRow.addView(newGuessButton);
     }
   }
   int row = random.nextInt(guessRows);
   int column = random.nextInt(3);
   TableRow randomTableRow = getTableRow(row);
   String countryName = getCountryName(correctAnswer);
   ((Button) randomTableRow.getChildAt(column)).setText(countryName);
 }
예제 #11
0
 private void updateSavedTucList() {
   // System.out.println("updateSavedTucList");
   ArrayList<HashMap<String, String>> tucList = dbTools.getAllTucs();
   tucTableScrollView.removeAllViews();
   // Display saved tuc list
   int i = 0;
   for (HashMap<String, String> s : tucList) {
     int lineId = insertTucInScrollView(s, i++);
     View newTucRow = tucTableScrollView.getChildAt(lineId);
     TextView currSaldo = (TextView) newTucRow.findViewById(R.id.tucSaldoTextView);
     if (currSaldo.getText() == null
         || currSaldo.getText().length() == 1
         || currSaldo
             .getText()
             .toString()
             .equals(getApplicationContext().getString(R.string.pending))) {
       // System.out.println("Updating saldo for line "+lineId);
       new UpdateSaldo(lineId).execute();
     }
   }
 }
예제 #12
0
 private void disableButtons() {
   for (int row = 0; row < buttonTableLayout.getChildCount(); ++row) {
     TableRow tableRow = (TableRow) buttonTableLayout.getChildAt(row);
     for (int i = 0; i < tableRow.getChildCount(); ++i) tableRow.getChildAt(i).setEnabled(false);
   }
 }
예제 #13
0
 private TableRow getTableRow(int row) {
   return (TableRow) buttonTableLayout.getChildAt(row);
 }
예제 #14
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.user_modify);
    mContext = this;

    /*
     * selectImage = (Button) this.findViewById(R.id.selectImage);
     * uploadImage = (Button) this.findViewById(R.id.uploadImage);
     */
    // selectImage.setOnClickListener(this);
    // uploadImage.setOnClickListener(this);

    imageView = (ImageView) this.findViewById(R.id.imageView);
    userNameText = (TextView) this.findViewById(R.id.userNameEditText);
    pwdText = (TextView) this.findViewById(R.id.pwdEditText);
    maleRadio = (RadioButton) this.findViewById(R.id.radioMale);
    femaleRadio = (RadioButton) this.findViewById(R.id.radioFemale);
    locationPublicYesRadio = (RadioButton) this.findViewById(R.id.radioLocationPublicYes);
    locationPublicNoRadio = (RadioButton) this.findViewById(R.id.radioLocationPublicNo);
    userModifyButton = (Button) this.findViewById(R.id.userModifyButton);
    userModifyButton.setOnClickListener(this);
    cancelButton = (Button) this.findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(this);

    phoneText = (TextView) this.findViewById(R.id.phoneText);

    // 获取本地存储的登录用户信息.
    user = UserService.getUserInfoFromSession(UserModifyActivity.this);
    phone = user.getPhone();
    if (!StringUtils.isEmpty(phone)) {
      user = UserService.getUserInfo(phone);
      phoneText.setEnabled(false);
      phoneText.setText(phone);
    } else if (!StringUtils.isEmpty(user.getUid())) {
      user = UserService.getUserInfoByUid(user.getUid());
      if (StringUtils.isEmpty(user.getPhone())) {
        phoneText.setEnabled(true);
        // 增加验证码控件
        TableLayout tableLayout = (TableLayout) this.findViewById(R.id.userModifyLayout);
        TableRow phoneTableRow = (TableRow) tableLayout.getChildAt(1);
        //	TableRow verifyCodeTableRow = new TableRow(this);

        Button verifyCodeSendButton = new Button(this);
        verifyCodeSendButton.setText("发送验证码");
        verifyCodeSendButton.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {

                String phone = phoneText.getText().toString();
                if (phone.equals("")) {
                  showDialog("手机号是必填项!");
                } else {
                  String sentResult = requestSendVerifyCode(phone);
                  if (JsonUtil.RESULT_TRUE_VALUE.equals(sentResult)) {

                    showDialog("验证码发送成功,请注意查收短信");
                  } else {
                    showDialog("验证码发送失败:" + sentResult);
                  }
                }
              }
            });
        phoneTableRow.addView(verifyCodeSendButton);
        // tableLayout.addView(verifyCodeTableRow, 2);

        // 添加验证码输入控件
        TableRow verifyCodeTextTableRow = new TableRow(this);
        TextView verifyCodeTextView = new TextView(this);
        verifyCodeTextView.setText("输入验证码:");
        verifyCodeTextTableRow.addView(verifyCodeTextView);
        verifyCodeEditText = new EditText(this);
        verifyCodeEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
        verifyCodeTextTableRow.addView(verifyCodeEditText);
        /*    Button verifyConfirmButton = new Button(this);
                    verifyConfirmButton.setText("验证");
                    verifyConfirmButton.setOnClickListener(new OnClickListener() {
        	@Override
        	public void onClick(View v) {

        		String phone = phoneText.getText().toString();
        		if (phone.equals("")) {
        			showDialog("手机号是必填项!");
        		} else {
        			String sentResult = requestSendVerifyCode(phone);
        			if (JsonUtil.RESULT_TRUE_VALUE.equals(sentResult)) {

        				showDialog("验证码发送成功,请注意查收短信");
        			} else {
        				showDialog("验证码发送失败:" + sentResult);
        			}
        		}
        	}
        });*/
        tableLayout.addView(verifyCodeTextTableRow, 2);
      }
    }

    // 异步获取头像数据
    AsyncFetchUserImgTask fetchImgTask = new AsyncFetchUserImgTask(user);
    fetchImgTask.execute(this);
    RadioGroup sexRadioGroup = (RadioGroup) this.findViewById(R.id.sexRadioGroup);
    sexRadioGroup.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(RadioGroup arg0, int arg1) {
            // TODO Auto-generated method stub
            // 获取变更后的选中项的ID
            int radioButtonId = arg0.getCheckedRadioButtonId();
            // 根据ID获取RadioButton的实例
            RadioButton rb = (RadioButton) UserModifyActivity.this.findViewById(radioButtonId);
            sex = rb.getText().toString();
          }
        });

    RadioGroup locationRadioGroup = (RadioGroup) this.findViewById(R.id.locationRadioGroup);
    locationRadioGroup.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(RadioGroup arg0, int arg1) {
            // TODO Auto-generated method stub
            // 获取变更后的选中项的ID
            int radioButtonId = arg0.getCheckedRadioButtonId();
            // 根据ID获取RadioButton的实例
            RadioButton rb = (RadioButton) UserModifyActivity.this.findViewById(radioButtonId);
            locationPublic = rb.getText().toString();
          }
        });
    if (!StringUtils.isEmpty(user.getUserName())) {
      userNameText.setText(user.getUserName());
    } else if (!StringUtils.isEmpty(user.getScreenName())) {
      userNameText.setText(user.getScreenName());
    }

    if (this.getString(R.string.sex_female).equals(user.getUserSex())) {
      femaleRadio.setChecked(true);
    } else if (this.getString(R.string.sex_male).equals(user.getUserSex())) {
      maleRadio.setChecked(true);
    }
    if (this.getString(R.string.no).equals(user.getLocationPublic())) {
      locationPublicNoRadio.setChecked(true);
    } else {
      locationPublicYesRadio.setChecked(true);
    }
    // 设置locationPublic默认值.
    RadioButton checkedLocationButton =
        (RadioButton) this.findViewById(locationRadioGroup.getCheckedRadioButtonId());
    locationPublic = checkedLocationButton.getText().toString();
  }
예제 #15
0
  @Override
  public void onStart() {
    formulaEditorKeyboard.setClickable(true);

    getView().requestFocus();
    View.OnTouchListener touchListener =
        new View.OnTouchListener() {
          private Handler handler;
          private Runnable deleteAction;

          private boolean handleLongClick(final View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              if (handler == null) {
                return true;
              }
              handler.removeCallbacks(deleteAction);
              handler = null;
            }
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              deleteAction =
                  new Runnable() {
                    @Override
                    public void run() {
                      handler.postDelayed(this, 100);
                      if (formulaEditorEditText.isThereSomethingToDelete()) {
                        formulaEditorEditText.handleKeyEvent(view.getId(), "");
                      }
                    }
                  };

              if (handler != null) {
                return true;
              }
              handler = new Handler();
              handler.postDelayed(deleteAction, 400);
            }
            return true;
          }

          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              updateButtonsOnKeyboardAndInvalidateOptionsMenu();
              view.setPressed(false);
              handleLongClick(view, event);
              return true;
            }

            if (event.getAction() == MotionEvent.ACTION_DOWN) {

              view.setPressed(true);

              switch (view.getId()) {
                case R.id.formula_editor_keyboard_compute:
                  InternFormulaParser internFormulaParser =
                      formulaEditorEditText.getFormulaParser();
                  FormulaElement formulaElement = internFormulaParser.parseFormula();
                  if (formulaElement == null) {
                    if (internFormulaParser.getErrorTokenIndex() >= 0) {
                      formulaEditorEditText.setParseErrorCursorAndSelection();
                    }
                    return false;
                  }
                  Formula formulaToCompute = new Formula(formulaElement);
                  FormulaEditorComputeDialog computeDialog =
                      new FormulaEditorComputeDialog(context);
                  computeDialog.setFormula(formulaToCompute);
                  computeDialog.show();
                  return true;
                case R.id.formula_editor_keyboard_function:
                  showFormularEditorCategorylistFragment(
                      FormulaEditorCategoryListFragment.FUNCTION_TAG,
                      R.string.formula_editor_functions);
                  return true;
                case R.id.formula_editor_keyboard_logic:
                  showFormularEditorCategorylistFragment(
                      FormulaEditorCategoryListFragment.LOGIC_TAG, R.string.formula_editor_logic);
                  return true;
                case R.id.formula_editor_keyboard_object:
                  showFormularEditorCategorylistFragment(
                      FormulaEditorCategoryListFragment.OBJECT_TAG,
                      R.string.formula_editor_choose_object_variable);
                  return true;
                case R.id.formula_editor_keyboard_sensors:
                  showFormularEditorCategorylistFragment(
                      FormulaEditorCategoryListFragment.SENSOR_TAG, R.string.formula_editor_device);
                  return true;
                case R.id.formula_editor_keyboard_data:
                  showFormulaEditorDataFragment(
                      FormulaEditorDataFragment.USER_DATA_TAG, R.string.formula_editor_data);
                  return true;
                case R.id.formula_editor_keyboard_ok:
                  endFormulaEditor();
                  return true;
                case R.id.formula_editor_keyboard_string:
                  FragmentManager fragmentManager = ((Activity) context).getFragmentManager();
                  Fragment dialogFragment =
                      fragmentManager.findFragmentByTag(NewStringDialog.DIALOG_FRAGMENT_TAG);

                  if (dialogFragment == null) {
                    dialogFragment = NewStringDialog.newInstance();
                  }

                  ((NewStringDialog) dialogFragment)
                      .show(fragmentManager, NewStringDialog.DIALOG_FRAGMENT_TAG);
                  return true;
                case R.id.formula_editor_keyboard_delete:
                  formulaEditorEditText.handleKeyEvent(view.getId(), "");
                  return handleLongClick(view, event);
                default:
                  formulaEditorEditText.handleKeyEvent(view.getId(), "");
                  return true;
              }
            }
            return false;
          }
        };

    for (int index = 0; index < formulaEditorKeyboard.getChildCount(); index++) {
      View tableRow = formulaEditorKeyboard.getChildAt(index);
      if (tableRow instanceof TableRow) {
        TableRow row = (TableRow) tableRow;
        for (int indexRow = 0; indexRow < row.getChildCount(); indexRow++) {
          row.getChildAt(indexRow).setOnTouchListener(touchListener);
        }
      }
    }

    updateButtonsOnKeyboardAndInvalidateOptionsMenu();

    super.onStart();
  }
예제 #16
0
  public void testTableLayout() {

    AndroidMetawidget androidMetawidget = new AndroidMetawidget(null);

    Stub stub = new Stub(null);
    stub.setTag("stubMe");
    androidMetawidget.addView(stub);

    Facet buttonsFacet = new Facet(null);
    buttonsFacet.setName("buttons");
    androidMetawidget.addView(buttonsFacet);

    Foo foo = new Foo();
    foo.nestedFoo = new Foo();
    androidMetawidget.setToInspect(foo);

    android.widget.TableLayout tableLayout =
        (android.widget.TableLayout) androidMetawidget.getChildAt(0);
    TableRow tableRow = (TableRow) tableLayout.getChildAt(0);
    assertEquals("Bar: ", ((TextView) tableRow.getChildAt(0)).getText());
    assertTrue(tableRow.getChildAt(1) instanceof EditText);
    tableRow = (TableRow) tableLayout.getChildAt(1);
    assertEquals("Baz: ", ((TextView) tableRow.getChildAt(0)).getText());
    assertTrue(tableRow.getChildAt(1) instanceof CheckBox);

    tableRow = (TableRow) tableLayout.getChildAt(2);
    assertEquals("Foo Section", ((TextView) tableRow.getChildAt(0)).getText());
    tableRow = (TableRow) tableLayout.getChildAt(3);
    android.widget.LinearLayout linearLayout = (android.widget.LinearLayout) tableRow.getChildAt(0);
    tableLayout = (android.widget.TableLayout) linearLayout.getChildAt(0);
    tableRow = (TableRow) tableLayout.getChildAt(0);
    assertEquals("Abc: ", ((TextView) tableRow.getChildAt(0)).getText());
    assertTrue(tableRow.getChildAt(1) instanceof Spinner);
    tableRow = (TableRow) tableLayout.getChildAt(1);
    assertEquals("Nested foo: ", ((TextView) tableRow.getChildAt(0)).getText());
    assertTrue(buttonsFacet == androidMetawidget.getChildAt(1));
    assertTrue(2 == androidMetawidget.getChildCount());

    // nestedFoo

    AndroidMetawidget nestedMetawidget = (AndroidMetawidget) tableRow.getChildAt(1);
    tableLayout = (android.widget.TableLayout) nestedMetawidget.getChildAt(0);
    tableRow = (TableRow) tableLayout.getChildAt(0);
    assertEquals("Bar: ", ((TextView) tableRow.getChildAt(0)).getText());
    assertTrue(tableRow.getChildAt(1) instanceof EditText);
    tableRow = (TableRow) tableLayout.getChildAt(1);
    assertEquals("Baz: ", ((TextView) tableRow.getChildAt(0)).getText());
    assertTrue(tableRow.getChildAt(1) instanceof CheckBox);

    tableRow = (TableRow) tableLayout.getChildAt(2);
    assertEquals("Foo Section", ((TextView) tableRow.getChildAt(0)).getText());
    tableRow = (TableRow) tableLayout.getChildAt(3);
    linearLayout = (android.widget.LinearLayout) tableRow.getChildAt(0);
    tableLayout = (android.widget.TableLayout) linearLayout.getChildAt(0);
    tableRow = (TableRow) tableLayout.getChildAt(0);
    assertEquals("Abc: ", ((TextView) tableRow.getChildAt(0)).getText());
    AdapterView<?> adapterView = (Spinner) tableRow.getChildAt(1);
    assertTrue(tableRow.getChildAt(1) instanceof Spinner);
    tableRow = (TableRow) tableLayout.getChildAt(1);
    assertEquals("Stub me: ", ((TextView) tableRow.getChildAt(0)).getText());
    assertTrue(tableRow.getChildAt(1) instanceof EditText);
    tableRow = (TableRow) tableLayout.getChildAt(2);
    assertEquals("Nested foo: ", ((TextView) tableRow.getChildAt(0)).getText());
    assertTrue(tableRow.getChildAt(1) instanceof AndroidMetawidget);
    assertTrue(3 == tableLayout.getChildCount());

    AndroidMetawidget nestedNestedMetawidget = (AndroidMetawidget) tableRow.getChildAt(1);
    assertTrue(1 == nestedNestedMetawidget.getChildCount());

    // (spacer)

    assertTrue(null == ((TextView) nestedNestedMetawidget.getChildAt(0)).getText());
    assertTrue(1 == nestedNestedMetawidget.getChildCount());

    // Get/set nested value

    assertTrue(null == adapterView.getSelectedItem());
    assertTrue(null == adapterView.getAdapter().getItem(0));
    assertEquals("one", adapterView.getAdapter().getItem(1));
    assertEquals("two", adapterView.getAdapter().getItem(2));
    assertEquals("three", adapterView.getAdapter().getItem(3));
    androidMetawidget.setValue("two", "nestedFoo", "abc");
    assertEquals("two", adapterView.getSelectedItem());
    assertEquals("two", androidMetawidget.getValue("nestedFoo", "abc"));
  }
 private void clearMeasurementSpecificViews(TableLayout table) {
   for (int i = NUMBER_OF_COMMON_VIEWS; i < table.getChildCount(); i++) {
     View v = table.getChildAt(i);
     v.setVisibility(View.GONE);
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_remote_control, container, false);
    mSelectedTextView = (TextView) v.findViewById(R.id.fragment_remote_control_selectedTextView);
    mWorkingTextView = (TextView) v.findViewById(R.id.fragment_remote_control_workingTextView);

    View.OnClickListener numberButtonListener =
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            TextView textView = (TextView) view;
            String working = mWorkingTextView.getText().toString();
            String text = textView.getText().toString();
            if (working.equals("0")) {
              mWorkingTextView.setText(text);
            } else {
              mWorkingTextView.setText(working + text);
            }
          }
        };

    TableLayout tableLayout =
        (TableLayout) v.findViewById(R.id.fragment_remote_control_tablelayout);
    int number = 1;
    for (int i = 2; i < tableLayout.getChildCount() - 1; i++) {
      TableRow tableRow = (TableRow) tableLayout.getChildAt(i);
      for (int j = 0; j < tableRow.getChildCount(); j++) {
        Button button = (Button) tableRow.getChildAt(j);
        button.setText("" + number);
        button.setOnClickListener(numberButtonListener);
        number++;
      }
    }

    // Now lets handle the Delete and the Enter Button
    TableRow buttonRow = (TableRow) tableLayout.getChildAt(tableLayout.getChildCount() - 1);
    Button deleteButton = (Button) buttonRow.getChildAt(0);
    deleteButton.setText("Delete");
    deleteButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mWorkingTextView.setText("0");
          }
        });

    Button zeroButton = (Button) buttonRow.getChildAt(1);
    zeroButton.setText("0");
    zeroButton.setOnClickListener(numberButtonListener);

    Button enterButton = (Button) buttonRow.getChildAt(2);
    enterButton.setText("Enter");
    enterButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            CharSequence working = mWorkingTextView.getText();
            if (working.length() > 0) mSelectedTextView.setText(working);
            mWorkingTextView.setText("0");
          }
        });

    return v;
  }
  public void updateStock() {
    try {
      CrashReporter.leaveBreadcrumb("MyStockSummary : updateStock");

      //
      // Step 1 - Clear existing data.
      //

      clearTable(byProductTable);
      clearTable(tlByCompartmentTable);

      //
      // Step 2 - Add any compartment stock.
      //

      if (Active.vehicle.StockByCompartment) {
        tvByCompartment.setVisibility(View.VISIBLE);
        tlByCompartmentTable.setVisibility(View.VISIBLE);

        // Add hosereel product.
        if (Active.vehicle.getHasHosereel()) {
          dbProduct product = Active.vehicle.getHosereelProduct();

          int capacity = Active.vehicle.getHosereelCapacity();

          // Add product to 'by product' table.
          addByProduct(product, capacity);

          // Add product to 'by compartment' table.
          addByCompartment(product, 0, capacity, capacity);
        }

        // Set number of compartments on tanker image.
        tanker.setCompartmentCount(Active.vehicle.getCompartmentCount());

        // Set product types and levels on tanker image.
        for (int tankerIdx = 0, compartmentIdx = Active.vehicle.getCompartmentStartIdx();
            compartmentIdx < Active.vehicle.getCompartmentEndIdx();
            tankerIdx++, compartmentIdx++) {
          dbProduct product = Active.vehicle.getCompartmentProduct(compartmentIdx);
          int no = Active.vehicle.getCompartmentNo(compartmentIdx);
          int capacity = Active.vehicle.getCompartmentCapacity(compartmentIdx);
          int onboard = Active.vehicle.getCompartmentOnboard(compartmentIdx);
          int colour = Active.vehicle.getCompartmentColour(compartmentIdx);

          // Update compartment on vehicle image.
          tanker.setCompartmentNo(tankerIdx, no);
          tanker.setCompartmentCapacity(tankerIdx, capacity);
          tanker.setCompartmentOnboard(tankerIdx, onboard);
          tanker.setCompartmentColour(tankerIdx, colour);

          // Add product to 'by product' table.
          addByProduct(product, onboard);

          // Add product to 'by compartment' table.
          if (Active.vehicle.StockByCompartment) {
            addByCompartment(product, no, capacity, onboard);
          }
        }
      }

      //
      // Step 3 - Add any non-compartment stock.
      //

      for (dbVehicleStock vs : dbVehicleStock.findAllNonCompartmentStock(Active.vehicle)) {
        addByProduct(vs.Product, vs.CurrentStock);
      }

      if (!Active.vehicle.StockByCompartment) {
        tvByCompartment.setVisibility(View.GONE);
        tlByCompartmentTable.setVisibility(View.GONE);

        if (Active.vehicle.getHasHosereel()) {
          // Add product to 'by product' table.
          addByProduct(Active.vehicle.getHosereelProduct(), Active.vehicle.getHosereelCapacity());
        }
      }

      //
      // Step 4 - find orders on this trip, and updated required.
      //

      // Find all undelivered orders on this trip.
      if (Active.trip != null) {
        for (dbTripOrder order : Active.trip.getUndelivered()) {
          // Find all order lines.
          for (dbTripOrderLine orderLine : order.getTripOrderLines()) {
            TableRow myTr = null;

            // Skip null products.
            // Skip non-deliverable products. e.g. credit card fees
            if (orderLine.Product == null || orderLine.Product.MobileOil == 3) {
              continue;
            }

            // Check if product already exists.
            for (int row = 1; row < byProductTable.getChildCount(); row++) {
              TableRow tr = (TableRow) byProductTable.getChildAt(row);

              if (tr.getTag().equals(orderLine.Product)) {
                myTr = tr;

                break;
              }
            }

            // Create new row, if not exists.
            if (myTr == null) {
              myTr = createByProductRow(orderLine.Product, 0);
            }

            // Find previous required.
            MyTextView tvRequired =
                (MyTextView) myTr.findViewById(R.id.stock_summary_by_product_tablerow_required);

            int prevRequired = 0;

            try {
              String text = tvRequired.getText().toString();

              if (text.length() > 0) {
                prevRequired = formatDecimal.parse(text).intValue();
              }
            } catch (ParseException e) {
              e.printStackTrace();
            }

            // Update required to include this order line.
            int required = prevRequired + orderLine.OrderedQty;
            tvRequired.setText(formatDecimal.format(required));

            // Find total onboard.
            MyTextView tvOnboard =
                (MyTextView) myTr.findViewById(R.id.stock_summary_by_product_tablerow_onboard);

            int onboard = 0;

            try {
              onboard = formatDecimal.parse((String) tvOnboard.getText()).intValue();
            } catch (ParseException e) {
              e.printStackTrace();
            }

            // Update the 'To Load' column.
            MyTextView toLoad =
                (MyTextView) myTr.findViewById(R.id.stock_summary_by_product_tablerow_to_load);

            if (required > onboard) {
              toLoad.setText(formatDecimal.format(required - onboard));
            } else {
              toLoad.setText(formatDecimal.format(0));
            }
          }
        }
      }
    } catch (Exception e) {
      CrashReporter.logHandledException(e);
    }
  }
예제 #20
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mLockObect = new Object();

    mPreference = getPreferences(MODE_PRIVATE);
    mOppacity = mPreference.getInt(PREFERENCE_OPPACITY_KEY, 0);
    mVerticalLogLinesWeight = mPreference.getInt(PREFERENCE_VERTICAL_WEIGHT_KEY, 0);
    mVerticalLogLinesOffset = mPreference.getInt(PREFERENCE_VERTICAL_OFFSET_KEY, 0);
    mHorizontalLogLinesWeight = mPreference.getInt(PREFERENCE_HORIZONTAL_WEIGHT_KEY, 0);
    mHorizontalLogLinesOffset = mPreference.getInt(PREFERENCE_HOZITONTAL_OFFSET_KEY, 0);
    mSelectedFontSizePosition = mPreference.getInt(PREFERENCE_SELECTED_FONT_SIZE_POSITION_KEY, 0);
    mSelectedFontColorPosition = mPreference.getInt(PREFERENCE_SELECTED_FONT_COLOR_POSITION_KEY, 0);
    mDisplayContentsCheckBoxState =
        mPreference.getInt(PREFERENCE_DISPLAY_CONTENTS_CHECKBOX_STATE_KEY, 0);
    mGrepEnable = mPreference.getBoolean(PREFERENCE_GREP_ENABLE_KEY, false);
    mGrepText = mPreference.getString(PREFERENCE_GREP_TEXT_KEY, "");

    ToggleButton tb = (ToggleButton) findViewById(R.id.enableButton);
    tb.setChecked(LoggerService.isRunning(this));
    tb.setOnCheckedChangeListener(mEnableButtonListener);

    Spinner fontSizeSpinner = (Spinner) findViewById(R.id.fontSizeSpinner);
    fontSizeSpinner.setSelection(mSelectedFontSizePosition);
    fontSizeSpinner.setOnItemSelectedListener(mFontsizeSpinnerListener);
    mFontSize =
        getResources().obtainTypedArray(R.array.fontsize).getInt(mSelectedFontSizePosition, 8);

    Spinner fontColorSpinner = (Spinner) findViewById(R.id.fontColorSpinner);
    fontColorSpinner.setOnItemSelectedListener(mFontColorSpinnerListener);
    fontColorSpinner.setSelection(mSelectedFontColorPosition);
    mFontColor =
        getResources()
            .obtainTypedArray(R.array.fontcolor_value)
            .getIndex(mSelectedFontColorPosition);

    TableLayout tblLayout = (TableLayout) findViewById(R.id.logContentCheckBox);
    int checkBoxCount = 0;
    for (int i = 0; i < tblLayout.getChildCount(); i++) {
      TableRow row = (TableRow) tblLayout.getChildAt(i);
      final int rowChildCound = row.getChildCount();
      for (int j = 0; j < rowChildCound; j++) {
        CheckBox checkBox = (CheckBox) row.getChildAt(j);
        checkBox.setOnCheckedChangeListener(mContentsCheckBoxListener);
        checkBox.setTag(checkBoxCount);
        if ((mDisplayContentsCheckBoxState & (1 << checkBoxCount)) != 0) {
          mDisplayContents |= (1 << LOGCAT_COLUMN_POS[checkBoxCount]);
          checkBox.setChecked(true);
        }
        checkBoxCount++;
      }
    }

    ToggleButton grepEnableButton = (ToggleButton) findViewById(R.id.grepEnableButton);
    grepEnableButton.setOnCheckedChangeListener(mGrepEnableButtonListener);
    grepEnableButton.setChecked(mGrepEnable);

    EditText grepEditText = (EditText) findViewById(R.id.grepEditText);
    grepEditText.addTextChangedListener(mGrepTextWatcher);
    grepEditText.setText(mGrepText);

    SeekBar horizontalLogLinesWeightSB = (SeekBar) findViewById(R.id.horizontalSizeSlider);
    horizontalLogLinesWeightSB.setOnSeekBarChangeListener(mHorizontalLogLinesWeightSliderListener);
    horizontalLogLinesWeightSB.setProgress(mHorizontalLogLinesWeight);

    SeekBar verticalLogLinesWeightSB = (SeekBar) findViewById(R.id.logLinesSlider);
    verticalLogLinesWeightSB.setOnSeekBarChangeListener(mVerticalLogLinesWeightSliderListener);
    verticalLogLinesWeightSB.setProgress(mVerticalLogLinesWeight);

    SeekBar horizontalLogLinesOffsetSB = (SeekBar) findViewById(R.id.horizontalOffsetSlider);
    horizontalLogLinesOffsetSB.setOnSeekBarChangeListener(mHorizontalLogLinesOffsetSliderListener);
    horizontalLogLinesOffsetSB.setProgress(mHorizontalLogLinesOffset);

    SeekBar verticalLogLinesOffsetSB = (SeekBar) findViewById(R.id.verticalOffsetSlider);
    verticalLogLinesOffsetSB.setOnSeekBarChangeListener(mVerticalLogLinesOffsetSliderListener);
    verticalLogLinesOffsetSB.setProgress(mVerticalLogLinesOffset);

    SeekBar sb = (SeekBar) findViewById(R.id.opacitySlider);
    sb.setOnSeekBarChangeListener(mOpacitySliderListener);
    sb.setProgress(mOppacity);
  }