Ejemplo n.º 1
0
        @Override
        public void onClick(View arg0) {
          TableRow parentTableRow = (TableRow) arg0.getParent();
          TableLayout parentTableLayout = (TableLayout) parentTableRow.getParent();
          int index = parentTableLayout.indexOfChild(parentTableRow);

          // Getting The String of the removed

          TextView parentTextView = (TextView) parentTableRow.getChildAt(0);
          String parentString = parentTextView.getText().toString();

          parentTableLayout.removeViewAt(index);

          if (parentTableLayout == adSearchMustTableLayout) {
            mustTermsCount--;
            mustTerms.remove(parentString);
            if (mustTermsCount == 0) {
              adSearchMustTableLayout.removeViewAt(0);
              mustTermsPresent = false;
            }
          }
          if (parentTableLayout == adSearchNotTableLayout) {
            notTermsCount--;
            notTerms.remove(parentString);
            if (notTermsCount == 0) {
              adSearchNotTableLayout.removeViewAt(0);
              notTermsPresent = false;
            }
          }
          if (parentTableLayout == adSearchWebsiteTebleLayout) {
            adSearchWebsiteTebleLayout.removeAllViews();
            websitePresent = false;
            websiteToSearch = "";
          }
        }
Ejemplo n.º 2
0
  private void DetayDoldur(TableRow tr) {

    ObDataBase db = new ObDataBase(this);
    TextView x = (TextView) tr.getChildAt(0);
    YeDatabase yDbUpdate = new YeDatabase(this);
    yDbUpdate.open();
    Cursor crx = yDbUpdate.QueryTbDataBases();
    while (crx.moveToNext()) {
      if (x.getText().equals(crx.getString(8))) {
        db.ID = crx.getInt(0);
        db.Name = crx.getString(1);
        db.Instance = crx.getString(2);
        db.Ip = crx.getString(3);
        db.Port = crx.getString(4);
        db.User = crx.getString(5);
        db.Pass = crx.getString(6);
        db.InUse = 1;
        db.Description = crx.getString(8);
      }
    }
    etID.setText(db.ID + "");
    etDatabase.setText(db.Name.toString());
    etDesc.setText(db.Description.toString());
    etInstance.setText(db.Instance.toString());
    etIpAdresi.setText(db.Ip.toString());
    etKullaniciAdi.setText(db.User.toString());
    etPort.setText(db.Port.toString());
    etSifre.setText(db.Pass.toString());
  }
 private void resetButton(TableRow row) {
   Resources resource = getApplicationContext().getResources();
   row.setBackgroundColor(Color.TRANSPARENT); // make the background transparent
   TextView tv = (TextView) row.getChildAt(0);
   tv.setTextColor(resource.getColor(R.color.white));
   // tv.setTextColor(resource.getColor(R));
 }
    @Override
    protected void onCreate() {
      // inflate layout
      LayoutInflater inflater =
          (LayoutInflater)
              this.anchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      ViewGroup root = (ViewGroup) inflater.inflate(R.layout.popup_grid_layout, null);

      // setup button events
      for (int i = 0, icount = root.getChildCount(); i < icount; i++) {
        View v = root.getChildAt(i);

        if (v instanceof TableRow) {
          TableRow row = (TableRow) v;

          for (int j = 0, jcount = row.getChildCount(); j < jcount; j++) {
            View item = row.getChildAt(j);
            if (item instanceof Button) {
              Button b = (Button) item;
              b.setOnClickListener(this);
            }
          }
        }
      }

      // set the inflated view as what we want to display
      this.setContentView(root);
    }
Ejemplo n.º 5
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 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);
 }
Ejemplo n.º 7
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;
  }
Ejemplo n.º 8
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;
  }
  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));
        }
      }
    }
  }
Ejemplo n.º 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);
 }
Ejemplo n.º 11
0
  private void SetAktifVeriTabani(TableRow ndb) {
    try {
      // View vi = ndb.getChildAt(0);
      TextView x = (TextView) ndb.getChildAt(0);

      YeDatabase yDbUpdate = new YeDatabase(this);
      yDbUpdate.open();
      Cursor crx = yDbUpdate.QueryTbDataBases();
      ObDataBase db = new ObDataBase(this);
      while (crx.moveToNext()) {

        if (x.getText().equals(crx.getString(8))) {
          db.ID = crx.getInt(0);
          db.Name = crx.getString(1);
          db.Instance = crx.getString(2);
          db.Ip = crx.getString(3);
          db.Port = crx.getString(4);
          db.User = crx.getString(5);
          db.Pass = crx.getString(6);
          db.InUse = 1;
          db.Description = crx.getString(8);
        } else {
          db.ID = crx.getInt(0);
          db.Name = crx.getString(1);
          db.Instance = crx.getString(2);
          db.Ip = crx.getString(3);
          db.Port = crx.getString(4);
          db.User = crx.getString(5);
          db.Pass = crx.getString(6);
          db.InUse = 0;
          db.Description = crx.getString(8);
        }
        yDbUpdate.UpdateTbDataBases(db);
      }

      yDbUpdate.close();
      TabloDoldur();
      ShowMessage(db.Description + " Aktive edildi..", 0);
    } catch (Exception e) {
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
    }
  }
  /**
   * 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);
    }
  }
Ejemplo n.º 13
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);
  }
Ejemplo n.º 14
0
  @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;
  }
Ejemplo n.º 15
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);
   }
 }
Ejemplo n.º 16
0
  public View getView(int position, View convertView, ViewGroup parent) {

    // Inflate le layout de l'offre si nécessaire
    if (convertView == null) {
      LayoutInflater inflater = ((Activity) context).getLayoutInflater();
      convertView = inflater.inflate(viewID, parent, false);
    }

    Offre offre = getItem(position);

    if (offre != null) {

      // Set le font des indicateurs qui apparaissent sur les offres.
      ((TextView) convertView.findViewById(R.id.item_apply_indicator)).setTypeface(indiatorFont);
      ((TextView) convertView.findViewById(R.id.item_ignore_indicator)).setTypeface(indiatorFont);

      // Les valeurs venant de l'offre à mettre dans le layout
      String titre = offre.getTitre();
      String description = offre.getDescription();
      String organisme = offre.getOrganismeName();
      PersonneContact personne = offre.getPersonneContact();
      Lieu lieu = offre.getLieu();
      Disponibilite horaire = offre.getDisponibilite();
      Duree duree = offre.getDuree();
      Calendar dateDebut = offre.getDateDebut();
      Calendar dateFin = offre.getDateFin();
      int ageMin = offre.getAgeMinimum();
      int places = offre.getNombrePlaces();
      List<String> competences = offre.getCompetences();
      String typeActivite = offre.getType();

      // Les views à changer dans le layout offre
      TextView titreView = (TextView) convertView.findViewById(R.id.lbl_titleValue);
      TextView descriptionView = (TextView) convertView.findViewById(R.id.lbl_descriptionValue);
      TextView organismeView = (TextView) convertView.findViewById(R.id.lbl_organismeName);
      TextView personneNameView = (TextView) convertView.findViewById(R.id.lbl_personneName);
      TextView personneEmailView = (TextView) convertView.findViewById(R.id.lbl_personneEmail);
      TableRow lieuView = (TableRow) convertView.findViewById(R.id.row_lieu);
      TableRow horaireView = (TableRow) convertView.findViewById(R.id.row_horaire);
      TableRow dureeView = (TableRow) convertView.findViewById(R.id.row_duree);
      TableRow dateDebutView = (TableRow) convertView.findViewById(R.id.row_dateDebut);
      TableRow dateFinView = (TableRow) convertView.findViewById(R.id.row_dateFin);
      TableRow ageMinView = (TableRow) convertView.findViewById(R.id.row_ageMin);
      TableRow placesView = (TableRow) convertView.findViewById(R.id.row_places);
      TableRow competencesView = (TableRow) convertView.findViewById(R.id.row_competences);
      TableRow typeActiviteView = (TableRow) convertView.findViewById(R.id.row_typeActivite);

      // Changement des valeurs du layout
      titreView.setText(titre);
      if (description != null) descriptionView.setText(description);
      else descriptionView.setHeight(0);
      organismeView.setText(organisme);
      if (personne != null) {
        personneNameView.setText(personne.getFullName());
        personneEmailView.setText(personne.getEmail());
      } else {
        personneNameView.setText(offre.getOrganismeName());
        personneEmailView.setVisibility(View.GONE);
      }
      if (lieu != null) ((TextView) lieuView.getChildAt(1)).setText(lieu.toString());
      else lieuView.setVisibility(View.GONE);
      if (horaire != null) ((TextView) horaireView.getChildAt(1)).setText(horaire.toString());
      else horaireView.setVisibility(View.GONE);
      if (duree != null) ((TextView) dureeView.getChildAt(1)).setText(duree.toString());
      else dureeView.setVisibility(View.GONE);
      if (dateDebut != null)
        ((TextView) dateDebutView.getChildAt(1))
            .setText(
                dateDebut.get(Calendar.DAY_OF_MONTH)
                    + " "
                    + Mois.get(dateDebut.get(Calendar.MONTH))
                    + " "
                    + dateDebut.get(Calendar.YEAR));
      else dateDebutView.setVisibility(View.GONE);
      if (dateFin != null)
        ((TextView) dateFinView.getChildAt(1))
            .setText(
                dateFin.get(Calendar.DAY_OF_MONTH)
                    + " "
                    + Mois.get(dateFin.get(Calendar.MONTH))
                    + " "
                    + dateFin.get(Calendar.YEAR));
      else dateFinView.setVisibility(View.GONE);
      if (ageMin > 0)
        ((TextView) ageMinView.getChildAt(1)).setText(ageMin + " an" + ((ageMin > 1) ? "s" : ""));
      else ageMinView.setVisibility(View.GONE);
      if (places > 0)
        ((TextView) placesView.getChildAt(1))
            .setText(places + " place" + ((places > 1) ? "s" : ""));
      else placesView.setVisibility(View.GONE);
      if (competences.size() > 0) {
        String competencesString = competences.get(0);
        for (int i = 1; i < competences.size(); i++) competencesString += ", " + competences.get(i);
        ((TextView) competencesView.getChildAt(1)).setText(competencesString);
      } else competencesView.setVisibility(View.GONE);
      if (typeActivite != null) ((TextView) typeActiviteView.getChildAt(1)).setText(typeActivite);
      else typeActiviteView.setVisibility(View.GONE);
    }

    // Retourne le view pour l'offre courante
    return convertView;
  }
Ejemplo n.º 17
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 activateButton(TableRow row) {
   Resources resource = getApplicationContext().getResources();
   row.setBackgroundColor(resource.getColor(R.color.buttonBackground));
   TextView tv = (TextView) row.getChildAt(0);
   tv.setTextColor(R.color.black);
 }
Ejemplo n.º 19
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();
  }
Ejemplo n.º 20
0
    protected void onPostExecute(String stream) {

      //  table is the 4x3 table which displays incoming bus data
      // increasing the table size requires addition of rows in content_bus_stop_info.xml
      // TableLayout table = (TableLayout)findViewById(R.id.result_table_layout);
      TableLayout scrollableLayout = (TableLayout) findViewById(R.id.ScrollableTableLayout);
      // setting table invisible to avoid showing filtering during updates. Set to visible after
      // filtering.
      scrollableLayout.setVisibility(View.GONE);
      if (stream != null) {
        try {
          // Get the full HTTP Data as JSONObject
          JSONObject reader = new JSONObject(stream);
          // tv.setText("."+reader+".");
          // Get the JSONArray busses
          JSONArray bussesArray = reader.getJSONArray("result");
          // store temporarily all line numbers in this list
          List<String> allLinesList = new ArrayList<String>();

          // using i<5 means that only 5 next busses will be displayed
          for (int i = 0; i < 20; i++) {
            if (i < bussesArray.length()) {
              // Get the busses array first JSONObject
              JSONObject busses_object_0 = bussesArray.getJSONObject(i);
              String busses_0_lineNumber = busses_object_0.getString("lineref");
              String busses_0_lineDestination = busses_object_0.getString("destinationdisplay");
              String busses_0_expectedTime = busses_object_0.getString("expectedarrivaltime");

              long timestamp = System.currentTimeMillis();
              long eta = Long.parseLong(busses_0_expectedTime) * 1000 - timestamp;

              // if the eta is negative, skip adding it
              if (eta < 0) {
                continue;
              }
              // adding this bus in the temp list for results filtering
              allLinesList.add(busses_0_lineNumber);

              int seconds = (int) (eta / 1000) % 60;
              int minutes = (int) ((eta / (1000 * 60)) % 60);
              int hours = (int) (eta / (1000 * 60 * 60)) % 24;

              String etaString;

              if (hours < 1) {
                etaString = minutes + "min " + seconds + "s";
              } else {
                SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
                etaString =
                    formatter.format(new Date(Long.parseLong(busses_0_expectedTime) * 1000));
              }

              // tv.setText(tv.getText()+"\nLine "+busses_0_lineNumber+" "+busses_0_lineDestination+
              // " "+etaString);
              // using row plus 1 means that we dont mess with the title row
              // TableRow row = (TableRow)table.getChildAt(i+1);
              TableRow row =
                  (TableRow)
                      LayoutInflater.from(ResultActivity.this).inflate(R.layout.result_row, null);
              scrollableLayout.addView(row);
              TextView tvLine = (TextView) row.getChildAt(0); // the first column of this row
              TextView tvDest = (TextView) row.getChildAt(1); // the second
              TextView tvEta = (TextView) row.getChildAt(2); // the third
              // setting the text data in the table cells
              tvLine.setText(busses_0_lineNumber);
              // breaking destination on first word ... must be a better way to do this
              String[] strArr = busses_0_lineDestination.split("\\s+", 0);
              tvDest.setText(strArr[0]);
              tvDest.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
              tvEta.setText(etaString);
              tvEta.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
            }
          }

          if (allLinesList != null) {
            List<String> newList = new ArrayList<String>(new HashSet<String>(allLinesList));
            Collections.sort(newList);
            addItemsOnSpinner(newList);
            if (lastSpinnerSelection != null) {
              for (int i = 0; i < filterSpinner.getCount(); i++) {
                if (filterSpinner.getItemAtPosition(i).equals(lastSpinnerSelection)) {
                  filterSpinner.setSelection(i);
                }
              }
            }
          }

        } catch (JSONException e) {
          e.printStackTrace();
        }
      } // if statement end
    } // onPostExecute() end
Ejemplo n.º 21
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);
  }