Search in sources :

Example 1 with EventViewModel

use of com.thebluealliance.androidclient.viewmodels.EventViewModel in project the-blue-alliance-android by the-blue-alliance.

the class TeamEventsFragment method initializeAdapterCreator.

@Override
public void initializeAdapterCreator(SmartAdapter.MultiAdaptersCreator creator) {
    creator.map(EventViewModel.class, EventItemView.class);
    creator.map(ListSectionHeaderViewModel.class, ListSectionHeaderItemView.class);
    creator.listener((actionId, item, position, view) -> {
        if (actionId == Interactions.EVENT_CLICKED && item instanceof EventViewModel) {
            EventViewModel event = (EventViewModel) item;
            startActivity(TeamAtEventActivity.newInstance(getContext(), event.getKey(), mTeamKey));
        }
    });
}
Also used : EventViewModel(com.thebluealliance.androidclient.viewmodels.EventViewModel)

Example 2 with EventViewModel

use of com.thebluealliance.androidclient.viewmodels.EventViewModel in project the-blue-alliance-android by the-blue-alliance.

the class EventListFragment method initializeAdapterCreator.

@Override
public void initializeAdapterCreator(SmartAdapter.MultiAdaptersCreator creator) {
    creator.map(EventViewModel.class, EventItemView.class);
    creator.map(ListSectionHeaderViewModel.class, ListSectionHeaderItemView.class);
    creator.listener((actionId, item, position, view) -> {
        if (actionId == Interactions.EVENT_CLICKED && item instanceof EventViewModel) {
            EventViewModel event = (EventViewModel) item;
            startActivity(ViewEventActivity.newInstance(getContext(), event.getKey()));
        }
    });
}
Also used : EventViewModel(com.thebluealliance.androidclient.viewmodels.EventViewModel)

Example 3 with EventViewModel

use of com.thebluealliance.androidclient.viewmodels.EventViewModel in project the-blue-alliance-android by the-blue-alliance.

the class DistrictEventsFragment method initializeAdapterCreator.

@Override
public void initializeAdapterCreator(SmartAdapter.MultiAdaptersCreator creator) {
    creator.map(EventViewModel.class, EventItemView.class);
    creator.map(ListSectionHeaderViewModel.class, ListSectionHeaderItemView.class);
    creator.listener((actionId, item, position, view) -> {
        if (actionId == Interactions.EVENT_CLICKED && item instanceof EventViewModel) {
            EventViewModel event = (EventViewModel) item;
            startActivity(ViewEventActivity.newInstance(getContext(), event.getKey()));
        }
    });
}
Also used : EventViewModel(com.thebluealliance.androidclient.viewmodels.EventViewModel)

Example 4 with EventViewModel

use of com.thebluealliance.androidclient.viewmodels.EventViewModel in project the-blue-alliance-android by the-blue-alliance.

the class DistrictEventsBinder method updateData.

@Override
public void updateData(@Nullable List<Object> data) {
    super.updateData(data);
    // Because we don't want to rely on the key -> constant mappings
    if (isDataBound() && mList != null) {
        for (int i = 0; i < mList.size(); i++) {
            Object item = mList.get(i);
            if (item instanceof EventViewModel) {
                EventViewModel viewModel = ((EventViewModel) item);
                String district = viewModel.getDistrictString();
                int year = viewModel.getYear();
                if (district != null && !district.isEmpty()) {
                    String title = mResources.getString(R.string.district_title_format, year, district);
                    mEventBus.post(new ActionBarTitleEvent(title));
                    return;
                }
            }
        }
    }
}
Also used : EventViewModel(com.thebluealliance.androidclient.viewmodels.EventViewModel) ActionBarTitleEvent(com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent)

Example 5 with EventViewModel

use of com.thebluealliance.androidclient.viewmodels.EventViewModel in project the-blue-alliance-android by the-blue-alliance.

the class Event method renderToViewModel.

@Nullable
@Override
public EventViewModel renderToViewModel(Context context, @Nullable @RenderType Integer renderType) {
    if (renderType == null) {
        return null;
    }
    EventViewModel model;
    model = new EventViewModel(getKey(), getYear(), getShortName(), getDateString(), getLocation(), getEventDistrictString());
    switch(renderType) {
        case RENDER_MYTBA_BUTTON:
            model.setShowMyTbaSettings(true);
    }
    return model;
}
Also used : EventViewModel(com.thebluealliance.androidclient.viewmodels.EventViewModel) Nullable(javax.annotation.Nullable)

Aggregations

EventViewModel (com.thebluealliance.androidclient.viewmodels.EventViewModel)5 ActionBarTitleEvent (com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent)1 Nullable (javax.annotation.Nullable)1