Example #1
0
 public void addAction(int id, CharSequence title, MenuItemClickListener listener) {
   final Action action = new Action();
   action.setId(id);
   action.setTitle(title);
   action.setListener(listener);
   actions.add(action);
 }
Example #2
0
 public void addAction(int id, int titleResource, MenuItemClickListener listener) {
   final Action action = new Action();
   action.setId(id);
   action.setTitle(titleResource);
   action.setListener(listener);
   actions.add(action);
 }
Example #3
0
 private Action getReloadAction() {
   final Action reload = new Action();
   reload.setId(-501);
   reload.setTitle(R.string.imm__reload);
   reload.setListener(
       new MenuItemClickListener() {
         public void onClick(ImageMenu imageMenu, int menuItemId) {
           imageLoader.reload();
         }
       });
   return reload;
 }
Example #4
0
  @Override
  public void onClick(View v) {
    final LoadStatus status = getStatus();

    final List<Action> clickActions = new LinkedList<Action>(actions);

    if (status == LoadStatus.ERROR) {
      clickActions.add(0, getReloadAction());
    } else if (clickActions.size() == 1) {
      // If there is only one action, force using it and exit.
      final Action onlyAction = clickActions.get(0);
      onlyAction.getListener().onClick(this, onlyAction.getId());
      return;
    }

    if (!clickActions.isEmpty()) {
      MenuFactoryHolder.getFactory().makeMenu(getContext(), this, clickActions);
    }
  }