Search in sources :

Example 6 with ListItem

use of com.thebluealliance.androidclient.listitems.ListItem in project the-blue-alliance-android by the-blue-alliance.

the class FirebaseTickerFragment method createFilterListAdapter.

private ListViewAdapter createFilterListAdapter(Set<String> enabledNotifications) {
    List<ListItem> listItems = new ArrayList<>();
    // Start with all notifications enabled
    listItems.add(new GamedayTickerFilterCheckbox(R.layout.list_item_checkbox_upcoming_match, "Upcoming Matches", NotificationTypes.UPCOMING_MATCH, true));
    listItems.add(new GamedayTickerFilterCheckbox(R.layout.list_item_checkbox_match_results, "Match Results", NotificationTypes.MATCH_SCORE, true));
    listItems.add(new GamedayTickerFilterCheckbox(R.layout.list_item_checkbox_schedule_updated, "Schedule Updated", NotificationTypes.SCHEDULE_UPDATED, true));
    listItems.add(new GamedayTickerFilterCheckbox(R.layout.list_item_checkbox_competition_level_starting, "Competition Level Starting", NotificationTypes.LEVEL_STARTING, true));
    listItems.add(new GamedayTickerFilterCheckbox(R.layout.list_item_checkbox_alliance_selections, "Alliance Selections", NotificationTypes.ALLIANCE_SELECTION, true));
    listItems.add(new GamedayTickerFilterCheckbox(R.layout.list_item_checkbox_awards_posted, "Awards Posted", NotificationTypes.AWARDS, true));
    // Initialize the preferences to their appropriate value
    if (enabledNotifications != null) {
        for (ListItem item : listItems) {
            GamedayTickerFilterCheckbox checkbox = (GamedayTickerFilterCheckbox) item;
            if (!enabledNotifications.contains(checkbox.getKey())) {
                checkbox.setChecked(false);
            }
        }
    }
    return new ListViewAdapter(getActivity(), listItems);
}
Also used : ListViewAdapter(com.thebluealliance.androidclient.adapters.ListViewAdapter) ArrayList(java.util.ArrayList) ListItem(com.thebluealliance.androidclient.listitems.ListItem) GamedayTickerFilterCheckbox(com.thebluealliance.androidclient.listitems.gameday.GamedayTickerFilterCheckbox)

Example 7 with ListItem

use of com.thebluealliance.androidclient.listitems.ListItem in project the-blue-alliance-android by the-blue-alliance.

the class NavigationDrawerFragment method navigationItemClicked.

/**
 * Called when an item in the navigation drawer is clicked
 *
 * @param position The position of the clicked item
 */
private void navigationItemClicked(int position) {
    ListItem item = mNavigationAdapter.getItem(position);
    // Ignore clicks on items like dividers and spacers
    if (!(item instanceof NavDrawerItem)) {
        return;
    }
    if (mDrawerListView != null) {
        mDrawerListView.setItemChecked(position, true);
    }
    mListener.onNavDrawerItemClicked((NavDrawerItem) item);
    if (mDrawerLayout != null) {
        mDrawerLayout.closeDrawer(mFragmentContainerView);
    }
}
Also used : DividerListItem(com.thebluealliance.androidclient.listitems.DividerListItem) SpacerListItem(com.thebluealliance.androidclient.listitems.SpacerListItem) ListItem(com.thebluealliance.androidclient.listitems.ListItem) NavDrawerItem(com.thebluealliance.androidclient.listitems.NavDrawerItem)

Example 8 with ListItem

use of com.thebluealliance.androidclient.listitems.ListItem in project the-blue-alliance-android by the-blue-alliance.

the class MatchListAdapter method getChildView.

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
    if (groupPosition >= mGroups.size() || childPosition >= mGroups.get(groupPosition).children.size()) {
        // Can't render due to bounds errors
        return new LabelValueListItem("Match", "Unable to render").getView(mActivity, mInflater, convertView);
    }
    RenderableModel child = mGroups.get(groupPosition).children.get(childPosition);
    if (child instanceof Match) {
        ((Match) child).setSelectedTeam(mTeamKey);
    }
    ListItem renderedChild = child.render(mRendererSupplier);
    if (renderedChild != null) {
        return renderedChild.getView(mActivity, mInflater, convertView);
    } else {
        return new LabelValueListItem("Match", "Unable to render").getView(mActivity, mInflater, convertView);
    }
}
Also used : LabelValueListItem(com.thebluealliance.androidclient.listitems.LabelValueListItem) ListItem(com.thebluealliance.androidclient.listitems.ListItem) LabelValueListItem(com.thebluealliance.androidclient.listitems.LabelValueListItem) RenderableModel(com.thebluealliance.androidclient.interfaces.RenderableModel) Match(com.thebluealliance.androidclient.models.Match)

Example 9 with ListItem

use of com.thebluealliance.androidclient.listitems.ListItem in project the-blue-alliance-android by the-blue-alliance.

the class AwardRendererTest method testRenderIndividualCarded.

@Test
public void testRenderIndividualCarded() {
    Award award = ModelMaker.getModel(Award.class, AWARD_INDIVIDUAL);
    ListItem rendered = mRenderer.renderFromModel(award, new AwardRenderer.RenderArgs(new HashMap<>(), null));
    assertNotNull(rendered);
    assertTrue(rendered instanceof CardedAwardListElement);
}
Also used : CardedAwardListElement(com.thebluealliance.androidclient.listitems.CardedAwardListElement) HashMap(java.util.HashMap) Award(com.thebluealliance.androidclient.models.Award) ListItem(com.thebluealliance.androidclient.listitems.ListItem) Test(org.junit.Test)

Example 10 with ListItem

use of com.thebluealliance.androidclient.listitems.ListItem in project the-blue-alliance-android by the-blue-alliance.

the class MyTbaModelRendererTest method testRenderEventTeam.

@Test
public void testRenderEventTeam() {
    Team team = ModelMaker.getModel(Team.class, TEAM_KEY);
    Event event = ModelMaker.getModel(Event.class, EVENT_KEY);
    when(mDatafeed.fetchTeam(TEAM_KEY)).thenReturn(Observable.just(team));
    when(mDatafeed.fetchEvent(EVENT_KEY)).thenReturn(Observable.just(event));
    ListItem item = mRenderer.renderFromKey(EVENT_TEAM_KEY, ModelType.EVENTTEAM, null);
    assertNotNull(item);
    assertTrue(item instanceof ModelListElement);
    assertEquals(((ModelListElement) item).getText(), "UberBots @ 2015 Hartford");
    assertEquals(((ModelListElement) item).getKey(), EVENT_TEAM_KEY);
    assertEquals(((ModelListElement) item).getType(), ModelType.EVENTTEAM);
}
Also used : Event(com.thebluealliance.androidclient.models.Event) Team(com.thebluealliance.androidclient.models.Team) ModelListElement(com.thebluealliance.androidclient.listitems.ModelListElement) ListItem(com.thebluealliance.androidclient.listitems.ListItem) Test(org.junit.Test)

Aggregations

ListItem (com.thebluealliance.androidclient.listitems.ListItem)26 Test (org.junit.Test)18 ModelListElement (com.thebluealliance.androidclient.listitems.ModelListElement)6 CardedAwardListElement (com.thebluealliance.androidclient.listitems.CardedAwardListElement)5 Award (com.thebluealliance.androidclient.models.Award)3 Team (com.thebluealliance.androidclient.models.Team)3 ListViewAdapter (com.thebluealliance.androidclient.adapters.ListViewAdapter)2 DistrictTeamListElement (com.thebluealliance.androidclient.listitems.DistrictTeamListElement)2 EventTypeHeader (com.thebluealliance.androidclient.listitems.EventTypeHeader)2 LabelValueListItem (com.thebluealliance.androidclient.listitems.LabelValueListItem)2 Event (com.thebluealliance.androidclient.models.Event)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Cursor (android.database.Cursor)1 JsonObject (com.google.gson.JsonObject)1 EventAwardsEvent (com.thebluealliance.androidclient.eventbus.EventAwardsEvent)1 RenderableModel (com.thebluealliance.androidclient.interfaces.RenderableModel)1 ContributorListElement (com.thebluealliance.androidclient.listitems.ContributorListElement)1 DividerListItem (com.thebluealliance.androidclient.listitems.DividerListItem)1 EmptyListElement (com.thebluealliance.androidclient.listitems.EmptyListElement)1