Пример #1
0
  private void addLocalClassToUser(ShowClass inClass) {
    ArrayList<ShowClass> classes = getModel().getEventClasses(getCurrentEvent().getId());
    ShowClass showClass = null;
    for (ShowClass c : classes) {
      if (c.getId() == inClass.getId()) {
        showClass = c;
        break;
      }
    }

    if (showClass == null) return;

    Participant participant = getSelectedRider();
    participant.addClass(showClass);
    Participation participation = new Participation();
    participation.setUser(participant);
    participation.setHorse("Deja vu");
    showClass.addParticipation(participation);
  }
Пример #2
0
  private void setupEventListAdapters() {
    if (getCurrentEvent() == null) return;

    Participant[] participants = getCurrentEvent().getParticipants();
    ListView participantsListView =
        (ListView) findViewById(R.id.admin_event_participants_list_view);
    participantsListView.setAdapter(
        new UserListAdapter(this, getParticipantsWithoutCurrentUser(participants), false));
    participantsListView.setOnItemClickListener(this);

    ListView classesListView =
        (ListView) findViewById(R.id.admin_event_participant_classes_list_view);

    ArrayList<ShowClass> classes = getModel().getEventClasses(getCurrentEvent().getId());
    if (classes == null) classes = new ArrayList<ShowClass>();

    ArrayList<ShowClassParticipator> checkableClasses = new ArrayList<ShowClassParticipator>();
    for (ShowClass showClass : classes) {
      boolean riding = false;
      if (getSelectedRider() != null && showClass.getParticipations() != null) {
        for (Participation p : showClass.getParticipations()) {
          if (p.getRider().getId() == getSelectedRider().getId()) riding = true;
        }
      }

      ShowClassParticipator item = new ShowClassParticipator(showClass, riding);
      item.addListener(ShowClassParticipator.EventMeta.PARTICIPATING_CHANGED, this);

      checkableClasses.add(item);
    }

    classesListView.setAdapter(new CheckableShowClassAdapter(this, checkableClasses));
    classesListView.setOnItemClickListener(this);

    Division[] divisions = getCurrentEvent().getDivisions();
    ListView divisionsListView = (ListView) findViewById(R.id.admin_divisions_list_view);
    divisionsListView.setAdapter(new NameListAdapter(this, divisions));
    divisionsListView.setOnItemClickListener(this);
  }