Esempio n. 1
0
 public void setData(Vector programData) {
   listData = programData;
   int size = listData.size();
   if (size > 10) size = 11;
   listField.setSize(size);
   listField.setFocus();
 }
Esempio n. 2
0
 private void increaseListFieldSize() {
   int currentSize = listField.getSize();
   int maxSize = listData.size();
   int newSize = currentSize + 10;
   if (newSize > maxSize) newSize = maxSize;
   listField.setSize(newSize);
   listField.setSelectedIndex(currentSize - 1);
 }
Esempio n. 3
0
 private void llenaLista() {
   int n, m;
   n = jerarquia.size();
   lista = new Vector();
   for (int i = 0; i < n; i++) {
     Item padre = (Item) jerarquia.elementAt(i);
     lista.addElement(padre);
     if (padre.isColapsado() == false) {
       m = padre.getItems().size();
       for (int j = 0; j < m; j++) {
         Item hijo = (Item) padre.getItems().elementAt(j);
         lista.addElement(hijo);
       }
     }
   }
   _listaConsulResumen.setSize(lista.size());
   _listaConsulResumen.invalidate();
 }
Esempio n. 4
0
  public SearchView(HomeScreen homeScreen) {
    this.homeScreen = homeScreen;
    manager =
        new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL) {
          public boolean keyChar(char c, int status, int time) {
            if (!searchField.isFocus()) {
              String oldText = searchField.getText();
              searchField.setFocus();
              String newText = c == Keypad.KEY_DELETE ? oldText : oldText + c;
              searchField.setText(newText.trim());
              return true;
            } else if (c == Keypad.KEY_ESCAPE) {
              if (searchField.getText().length() > 0) {
                searchField.setText("");
                return true;
              }
            }
            return super.keyChar(c, status, time);
          }
        };
    searchField =
        new BasicEditField(Field.USE_ALL_WIDTH) {
          public boolean navigationClick(int status, int time) {
            if (getText().trim().length() > 0) {
              SearchView.this.homeScreen.fireActionSearch();
              return true;
            }
            return super.navigationClick(status, time);
          }

          public boolean keyChar(char c, int status, int time) {
            if (c == Keypad.KEY_ENTER) {
              if (getText().trim().length() > 0) {
                SearchView.this.homeScreen.fireActionSearch();
                return true;
              }
            } else if (getText().length() == 0 && c == Keypad.KEY_SPACE) {
              return true;
            }
            return super.keyChar(c, status, time);
          }

          public void paint(Graphics g) {
            if (getText().length() == 0) {
              g.setColor(0xbbbbbb);
              g.drawText(" Search", 0, 0);
            } else {
              g.setColor(0);
              super.paint(g);
            }
          }
        };

    // int defaultFontHeight = Font.getDefault().getHeight();
    // searchField.setFont(Font.getDefault().derive(Font.PLAIN, defaultFontHeight+8));
    Border border = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4));
    searchField.setBorder(border);
    searchField.setBackground(BackgroundFactory.createSolidBackground(0xffffff));
    manager.add(searchField);
    manager.add(new SeparatorField());

    // manager.setBackground(HomeScreen.mainBackground);
    listField =
        new ListField(0, Manager.USE_ALL_HEIGHT) {
          public boolean navigationClick(int status, int time) {
            if (SearchView.this.listData.size() > 0) {
              int index = getSelectedIndex();
              if (isMoreButton(index)) {
                increaseListFieldSize();
                invalidate();
                return true;
              }
              ProgramData data = (ProgramData) SearchView.this.listData.elementAt(index);
              data.isFavorite = !data.isFavorite;
              if (data.isFavorite) {
                FavoritePersistent.addFavorite(data.id);
                PIMEvent.addEvent(data);
              } else {
                FavoritePersistent.removeFavorite(data.id);
                PIMEvent.removeEvent(data);
              }
              invalidate();
              return true;
            }
            return super.navigationClick(status, time);
          }

          public void paint(Graphics g) {
            int ty = getContentTop() + getContentHeight() / 2 - g.getFont().getHeight() / 2;
            if (ThaiTVSchedule.isFetching()) {
              ThaiTVSchedule.paintFetching(g, ty);
            } else if (this.getSize() < 1) {
              g.setColor(0);
              int x = (getWidth() - g.getFont().getAdvance("No data")) / 2;
              g.drawText("No data", x, ty);
            } else {
              super.paint(g);
            }
          }

          public boolean isFocusable() {
            return !ThaiTVSchedule.isFetching();
          }
        };
    // listField.setBackground(HomeScreen.mainBackground);
    listField.setRowHeight(ScheduleScreen.LIST_HEIGHT);
    listField.setCallback(this);
    listData = new Vector();
    listField.setSize(0);
    listField.setFont(Font.getDefault().derive(Font.PLAIN, 20));
    VerticalFieldManager _vfm =
        new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    _vfm.add(listField);
    manager.add(_vfm);

    // autoFocus();
  }