public void setData(Vector programData) {
   listData = programData;
   int size = listData.size();
   if (size > 10) size = 11;
   listField.setSize(size);
   listField.setFocus();
 }
  protected boolean navigationClick(int status, int time) {
    Field field = this.getFieldWithFocus();
    if (field == _listaConsulResumen) {
      int index = _listaConsulResumen.getSelectedIndex();
      Item item = (Item) get(_listaConsulResumen, index);
      if (item.isCabecera()) {
        item.setColapsado(!item.isColapsado());
        llenaLista();
        _listaConsulResumen.setSelectedIndex(index);
        return true;
      } else {
        item = (Item) jerarquia.elementAt(item.getIndexPadre());
        int op = getCategoria(index);
        if (op >= 0) {
          int cant = Integer.parseInt(((Item) get(_listaConsulResumen, index)).getValor());
          if (cant > 0) {
            String campana =
                item.getDescripcion().substring(4) + item.getDescripcion().substring(1, 3);
            progress.setTitle("Buscando... ");
            progress.open();
            progress.close();
            try {
              Estilos.pushScreen(new ConsultaSeccion(campana, "", "", "", "", "" + op));
            } catch (Exception e) {

            }
          }
        }
        return true;
      }
    }
    return super.navigationClick(status, time);
  }
  public void drawListRow(ListField listField, Graphics graphics, int index, int y, int width) {
    Object[] childImagePair = (Object[]) this.get(listField, index);
    Child child = (Child) childImagePair[0];
    Bitmap image = (Bitmap) childImagePair[1];

    drawStatusBox(listField, graphics, index, child);

    drawChildImage(graphics, listField, index, image);

    graphics.setColor(Color.BLACK);

    graphics.setFont(titleFont);

    // Takes 5 params 1:display text, 2:horizontal position,
    // 3: vertical position, 4: flags, 5: text display width
    graphics.drawText(
        (String) child.getField("name"),
        firstRowPosition,
        y,
        (DrawStyle.LEFT | DrawStyle.ELLIPSIS | DrawStyle.TOP),
        screenWidth - firstRowPosition - 4);

    int yStartForText = y + (this.getFont()).getHeight() + 1;
    drawFieldRow(graphics, width, child, yStartForText, "age");

    yStartForText = yStartForText + (this.getFont()).getHeight() + 1;
    drawFieldRow(
        graphics, width - secondRowPosition - 4, child, yStartForText, "last_known_location");

    yStartForText = yStartForText + (this.getFont()).getHeight() + 1;
    graphics.drawLine(
        0, (index * listField.getRowHeight()), width, (index * listField.getRowHeight()));
  }
 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);
 }
Exemple #5
0
 protected boolean navigationMovement(int dx, int dy, int status, int time) {
   Field field = this.getFieldWithFocus();
   if (field == menu) {
     menu.invalidate(menu.getSelectedIndex() + dy);
     menu.invalidate(menu.getSelectedIndex());
   }
   return super.navigationMovement(dx, dy, status, time);
 }
 protected boolean navigationMovement(int dx, int dy, int status, int time) {
   Field field = this.getFieldWithFocus();
   if (field == _listaConsulResumen) {
     _listaConsulResumen.invalidate(_listaConsulResumen.getSelectedIndex() + dy);
     _listaConsulResumen.invalidate(_listaConsulResumen.getSelectedIndex());
   }
   return super.navigationMovement(dx, dy, status, time);
 }
Exemple #7
0
  public void drawListRow(ListField list, Graphics g, int index, int y, int w) {

    Font font = g.getFont();
    int xPos = 30;
    int yPos = y + (list.getRowHeight() - imagee1.getHeight()) / 2;
    int yPosTxt = y + (list.getRowHeight() - font.getHeight()) / 2;

    if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
      g.setBackgroundColor(0x005A6971);
      // g.setBackgroundColor(0x005A6971);
      // g.drawRoundRect(0, 0, 630, 80, 15, 15);
      g.clear();
    } else {
      g.setColor(Color.WHITE);
      // g.drawRoundRect(0, 0, 630, 80, 15, 15);
    }

    for (int i = 0; i < bit.length; i++) {
      image = bit[index];
      g.drawBitmap(5, yPos + 3, image.getWidth(), image.getHeight(), image, 0, 0);
    }

    g.setFont(Constants.fontBold);
    xPos = xPos + image.getWidth();
    String text = (String) listElements.elementAt(index);
    g.drawText(text, xPos, yPosTxt);
    g.setFont(Constants.fontVerySmall);

    //		for (int i = 0; i < bit.length; i++) {
    //			xPos = 30 + image.getWidth();
    //			String textSubText = Constants.selectedBranch;
    //			g.drawText(textSubText, xPos, yPosTxt + 25);
    //		}

    xPos = 30 + image.getWidth();

    switch (index) {
      case 0:
        String textSubText = Constants.selectedBranch;
        g.drawText(textSubText, xPos, yPosTxt + 25);
        break;

      case 1:
        String textProcessText = Constants.selectedProcess;
        g.drawText(textProcessText, xPos, yPosTxt + 25);
        break;

      case 2:
        String textLocationText = Constants.selectedLocation;
        g.drawText(textLocationText, xPos, yPosTxt + 25);
        break;
    }

    g.drawBitmap(580, yPos + 3, arrowImage.getWidth(), arrowImage.getHeight(), arrowImage, 0, 0);
  }
Exemple #8
0
 private void seleccion() {
   if (opciones[menu.getSelectedIndex()].equals(MetodosGlobales.opciones[1])) { // Atracciones
     Estilos.pushScreen(new Atracciones());
   } else if (opciones[menu.getSelectedIndex()].equals(MetodosGlobales.opciones[2])) { // Nuevas
     Estilos.pushScreen(new MenuContactos());
   } else if (opciones[menu.getSelectedIndex()].equals(MetodosGlobales.opciones[3])) { // Buscar
     Estilos.pushScreen(new Establecidas(MetodosGlobales.establecidasTitulo()));
   } else if (opciones[menu.getSelectedIndex()].equals(
       MetodosGlobales.opciones[5])) { // Facturacion
     Estilos.pushScreen(new FacturaResumen());
   } else if (opciones[menu.getSelectedIndex()].equals(
       MetodosGlobales.opciones[6])) { // Indicadores
     Estilos.pushScreen(new IndicadorDetalle());
   }
 }
 public FacturaResumen() {
   _listaConsulResumen =
       new ListField(
           0, ListField.FIELD_HCENTER | ListField.USE_ALL_WIDTH | ListField.USE_ALL_HEIGHT);
   _listaConsulResumen.setCallback(this);
   _listaConsulResumen.setSearchable(true);
   add(
       new BitmapField(
           Bitmap.getBitmapResource("img/titulos/facturacionresumen.png"),
           BitmapField.FIELD_HCENTER));
   add(_listaConsulResumen);
   addMenuItem(_Secciones);
   llenaJerarquia();
   Sistema.addEstadistica(Cadenas.FAC_CAMPANA);
 }
Exemple #10
0
 public void drawListRow(ListField listField, Graphics g, int index, int y, int w) {
   String sColapsado = "";
   Item item = (Item) get(listField, index);
   if (listField.getSelectedIndex() == index) {
     g.setColor(Color.WHITE);
     g.setBackgroundColor(Estilos.getBGSelected());
   } else {
     if (item.isCabecera()) {
       g.setColor(Estilos.getColorInterlinea(0));
       g.setBackgroundColor(Estilos.getBGInterlinea(0));
     } else {
       g.setColor(Estilos.getColorInterlinea(1));
       g.setBackgroundColor(Estilos.getBGInterlinea(1));
     }
     g.clear();
   }
   if (item.isCabecera()) {
     if (item.isColapsado()) {
       sColapsado = Characters.BLACK_RIGHT_POINTING_TRIANGLE + " ";
     } else {
       sColapsado = Characters.BLACK_DOWN_POINTING_TRIANGLE + " ";
     }
   } else {
     sColapsado = Characters.SPACE + "";
   }
   g.drawText(sColapsado + item.getDescripcion(), 0, y, DrawStyle.LEFT, w);
   g.drawText(item.getValor(), 0, y, DrawStyle.RIGHT, w);
 }
Exemple #11
0
 private int getCategoria(int index) {
   int i, j, n = 0, m = 0, avance = 0;
   j = _listaConsulResumen.getSize();
   for (i = 0; i < j; i++) {
     Item item = (Item) get(_listaConsulResumen, i);
     if (item.isCabecera()) {
       if (item.isColapsado()) m++;
       else n++;
       avance = ((9 * n) + (1 * m));
       if (avance > index) {
         break;
       }
     }
   }
   int elemento = avance - (9 - index);
   int estado = -1;
   switch (elemento) {
     case 4:
       estado = 0;
       break;
     case 5:
       estado = 1;
       break;
     case 6:
       estado = 2;
       break;
     case 7:
       estado = 3;
       break;
     case 9:
       estado = 4;
       break;
   }
   return estado;
 }
 private void drawChildImage(Graphics graphics, ListField listField, int index, Bitmap image) {
   if (image == null) {
     return;
   }
   try {
     graphics.drawBitmap(
         2,
         ((index) * listField.getRowHeight() + 2),
         (listField.getRowHeight() - 4),
         (listField.getRowHeight() - 4),
         image,
         0,
         0);
   } catch (NullPointerException n) {
     return;
   }
 }
Exemple #13
0
 public void run() {
   int index = _listaConsulResumen.getSelectedIndex();
   Item item = (Item) get(_listaConsulResumen, index);
   if (!item.isCabecera()) {
     item = (Item) jerarquia.elementAt(item.getIndexPadre());
   }
   UiApplication.getUiApplication()
       .pushScreen(new FacturacionDetalle(item.getDescripcion()));
 }
 public boolean isMoreButton(int index) {
   int maxSize = listData.size();
   int currentSize = listField.getSize();
   //		if(index<currentSize-1 && index<maxSize-1)
   //			return false;
   //		return true;
   if (maxSize > currentSize && index == currentSize - 1) return true;
   return false;
 }
Exemple #15
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();
 }
Exemple #16
0
 public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
   if (list.getSelectedIndex() == index) {
   } else {
     g.setColor(Color.WHITE);
     if (get(index).equals("Consultoras") || get(index).equals("Pedidos")) {
       g.setBackgroundColor(Estilos.getBGModulo());
     } else {
       g.setBackgroundColor(Estilos.getBGSubModulo());
     }
     g.clear();
   }
   g.drawText(get(index), 0, y, 0, w);
 }
Exemple #17
0
  public void drawListRow(ListField list, Graphics g, int index, int y, int w) {

    Font font = g.getFont();
    int xPos = 30;
    //		int yPos = y + (list.getRowHeight() - bit[1].getHeight()) / 2;
    int yPos = y + (list.getRowHeight() - imagee2.getHeight()) / 2;
    int yPosTxt = y + (list.getRowHeight() - font.getHeight()) / 2;

    // Bitmap imageBackground = Bitmap
    // .getBitmapResource("button_for_thumbnails_inactive.png");
    // if (list.getSelectedIndex() != index) {
    // g.drawBitmap(0, 0, 640, 80, imageBackground, 0, 0);
    // }

    if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
      g.setBackgroundColor(0x005A6971);
      // g.drawRoundRect(0, 0, 630, 80, 15, 15);
      g.clear();
    } else {
      g.setColor(Color.WHITE);
      // g.drawRoundRect(0, 0, 630, 80, 15, 15);
    }

    //		for (int i = 0; i < bit.length; i++) {
    //			image = bit[index];
    //			g.drawBitmap(5, yPos + 3, image.getWidth(), image.getHeight(),
    //					image, 0, 0);
    //		}

    g.drawBitmap(5, yPos + 3, imagee2.getWidth(), imagee2.getHeight(), imagee2, 0, 0);

    xPos = xPos + imagee2.getWidth();
    String text = (String) listElements.elementAt(index);
    g.drawText(text, xPos, yPosTxt + 3);

    g.drawBitmap(580, yPos + 7, arrowImage.getWidth(), arrowImage.getHeight(), arrowImage, 0, 0);
  }
  private void drawStatusBox(ListField listField, Graphics graphics, int index, Child child) {

    String childStatusString = child.childStatus().getStatusString();
    int boxHeight = getFont().getHeight() + 4;
    int boxWidth = getFont().getAdvance(childStatusString) + 4;
    int boxX = screenWidth - 10 - boxWidth;
    int boxY = ((index) * listField.getRowHeight()) + getFont().getHeight() + 2;

    graphics.setColor(child.childStatus().getStatusColor());
    graphics.drawRoundRect(boxX, boxY, boxWidth, boxHeight, 10, 10);
    graphics.fillRoundRect(boxX, boxY, boxWidth, boxHeight, 10, 10);

    graphics.setColor(16777215);
    graphics.setFont(rowFont);
    graphics.drawText(
        childStatusString,
        boxX,
        boxY + 2,
        (DrawStyle.HCENTER | DrawStyle.ELLIPSIS | DrawStyle.TOP),
        boxWidth);
  }
  public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
    if (isMoreButton(index)) {
      Font bold = Font.getDefault().derive(Font.BOLD);
      g.setFont(bold);
      String strMore = "More";
      int xx = (width - bold.getAdvance(strMore)) / 2;
      int yy = y + (ScheduleScreen.LIST_HEIGHT - bold.getHeight()) / 2;
      if (listField.getSelectedIndex() == index) {
        g.setColor(0);
        g.drawText(strMore, xx + 1, yy + 1);
        g.setColor(0xffffff);
        g.drawText(strMore, xx, yy);
      } else {
        g.setColor(0);
        g.drawText(strMore, xx, yy);
      }
      return;
    }
    ProgramData data = (ProgramData) listData.elementAt(index);
    //		if(!listField.isFocus() || index!=listField.getSelectedIndex()){
    //			for(int x=0; x<Display.getWidth(); x+= ScheduleScreen.LIST_BACKGROUND.getWidth())
    //				g.drawBitmap(x, y, ScheduleScreen.LIST_BACKGROUND.getWidth(),
    // ScheduleScreen.LIST_BACKGROUND.getHeight(), ScheduleScreen.LIST_BACKGROUND, 0, 0);
    //		}
    if (!listField.isFocus() || index != listField.getSelectedIndex()) {
      for (int x = 0; x < Display.getWidth(); x += ScheduleScreen.LIST_BACKGROUND.getWidth())
        g.drawBitmap(
            x,
            y,
            ScheduleScreen.LIST_BACKGROUND.getWidth(),
            ScheduleScreen.LIST_BACKGROUND.getHeight(),
            ScheduleScreen.LIST_BACKGROUND,
            0,
            0);
    }
    Bitmap thumb = TVApi.getChannelThumbnail(data.channelId);
    if (thumb != null) {
      int padding = (ScheduleScreen.LIST_HEIGHT - thumb.getHeight()) / 2;
      int ty = y + padding;
      int tx = padding;
      g.drawBitmap(tx, ty, thumb.getWidth(), thumb.getHeight(), thumb, 0, 0);
      g.setColor(0);
      g.drawText(data.beginTime + " - " + data.endTime, tx + thumb.getWidth() + tx, ty);
      Bitmap favorite =
          data.isFavorite ? ScheduleScreen.LIST_FAVORITE_ON : ScheduleScreen.LIST_FAVORITE_OFF;
      int titleMaxWidth = width - thumb.getWidth() - favorite.getWidth() - (padding * 4);
      g.drawText(
          data.title,
          tx + thumb.getWidth() + tx,
          ty + thumb.getHeight(),
          DrawStyle.BASELINE | DrawStyle.ELLIPSIS,
          titleMaxWidth);

      g.drawBitmap(
          width - padding - favorite.getWidth(),
          y + (ScheduleScreen.LIST_HEIGHT - favorite.getHeight()) / 2,
          favorite.getWidth(),
          favorite.getHeight(),
          favorite,
          0,
          0);
    }
  }
Exemple #20
0
  public MenuOpciones() {
    VerticalFieldManager vField = new VerticalFieldManager();
    UsuarioDB usuarios = new UsuarioDB();
    usuario = usuarios.getUsuario();
    usuarios = null;
    //		meGlobales.setPerfil(perfil);

    HorizontalFieldManager hField =
        new HorizontalFieldManager() {
          protected void sublayout(int width, int height) {
            super.sublayout(super.getScreen().getWidth(), height);
            super.setExtent(super.getScreen().getWidth(), getField(1).getHeight());
            Field field;

            field = getField(0);
            layoutChild(field, width / 2, height);
            // setPositionChild(field, (width / 4) - ( field.getPreferredWidth() / 2), 0);
            setPositionChild(field, 5, 0);

            field = getField(1);
            layoutChild(field, width, height);
            setPositionChild(field, (width / 2) + (width / 4) - (field.getPreferredWidth() / 2), 0);
          }
        };

    vField.add(new LabelField("", LabelField.FIELD_LEFT));
    vField.add(
        new mkpyLabelField(
            usuario.getNombre(),
            LabelField.ELLIPSIS | LabelField.FIELD_LEFT,
            Color.BLACK,
            Color.WHITE,
            true));
    vField.add(new LabelField(usuario.getZonaRegionPais(), LabelField.FIELD_LEFT));
    vField.add(new LabelField(usuario.getCampanaFormato(), LabelField.FIELD_LEFT));

    hField.add(vField);
    hField.add(
        new BitmapField(
            Bitmap.getBitmapResource("img/logo.png"),
            BitmapField.FIELD_LEFT | BitmapField.FIELD_VCENTER));

    opciones = MetodosGlobales.menuOpcionesxPerfil();
    menu = new ListField(opciones.length, ListField.FIELD_HCENTER);
    menu.setCallback(this);

    add(
        new BitmapField(
            Bitmap.getBitmapResource("img/titulos/menuprincipal.png"), BitmapField.FIELD_HCENTER));
    add(hField);
    add(menu);
    addMenuItem(mnSincronizar);
    addMenuItem(mnAcerca);
    addMenuItem(mnCerrarSesion);

    Sistema.addEstadistica(Cadenas.MENUPRINCIPAL);

    if (usuario != null) {
      // MBL : Timer de sincronización
      long tiempo = usuario.getTiempoDatosConsultora() * 60 * 60000; // mbl: En horas
      // long tiempo = 3*60*1000;
      timer = new Timer();
      timer.schedule(new Sicronizacion(), tiempo, tiempo);
    }
  }
  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();
  }