Ejemplo n.º 1
0
 private boolean needShowMore() {
   if (_max_show_item_count > _menu.count()) {
     return false;
   } else {
     return true;
   }
 }
Ejemplo n.º 2
0
  public void resetMenu(ScreenMenu menu, int show_count) {
    synchronized (this) {
      removeAllViews();

      _menu = menu;
      _max_show_item_count = show_count;

      int max_count = _max_show_item_count;
      if (max_count > menu.count()) {
        max_count = menu.count();
      }
      _buttons = new CustomButtonField[max_count + (needShowMore() ? 1 : 0)];
      System.out.println("resetMenu: max_count=" + max_count);
      for (int i = 0; i < max_count; i++) {
        ScreenMenuItem item = menu.getItem(i);
        _buttons[i] = new CustomButtonField(getContext(), item.getTitle(), this);
        String text_style = BASE_TEXT_STYLE;
        String focus_text_style = BASE_FOCUS_TEXT_STYLE;
        if (item.getBarIconName() != null && item.getBarIconName().length() > 0) {
          text_style += " icon=" + item.getBarIconName();
        }
        _buttons[i].setTextStyle(new TextStyleDescriptor(text_style));
        if (item.getFocusBarIconName() != null && item.getFocusBarIconName().length() > 0) {
          focus_text_style += " icon=" + item.getFocusBarIconName();
        } else if (item.getBarIconName() != null && item.getBarIconName().length() > 0) {
          focus_text_style += " icon=" + item.getBarIconName();
        }
        _buttons[i].setFocusTextStyle(new TextStyleDescriptor(focus_text_style));
        addView(_buttons[i]);
      }
      if (needShowMore()) {
        _buttons[max_count] =
            new CustomButtonField(
                getContext(), getContext().getString(R.string.screen_menu_bar_item_more), this);
        String text_style = BASE_TEXT_STYLE + " icon=menubar_icon_more.png";
        String focus_text_style = BASE_FOCUS_TEXT_STYLE + " icon=menubar_icon_more.png";
        _buttons[max_count].setTextStyle(new TextStyleDescriptor(text_style));
        _buttons[max_count].setFocusTextStyle(new TextStyleDescriptor(focus_text_style));
        addView(_buttons[max_count]);
      }
    }
  }
Ejemplo n.º 3
0
 public void onClick(View v) {
   for (int i = 0; _buttons != null && i < _buttons.length; i++) {
     if (v == _buttons[i]) {
       if (i == _buttons.length - 1 && needShowMore()) {
         ((UiApplication) getContext()).openOptionsMenu();
       } else {
         if (_menu != null) {
           _menu.getItem(i).run();
         }
       }
     }
   }
 }