Search in sources :

Example 1 with GamedayTickerFilterCheckbox

use of com.thebluealliance.androidclient.listitems.gameday.GamedayTickerFilterCheckbox 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 2 with GamedayTickerFilterCheckbox

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

the class FirebaseTickerFragment method getEnabledNotificationKeys.

private Set<String> getEnabledNotificationKeys() {
    final Set<String> enabledNotificationKeys = new HashSet<>();
    int filterItemCount = mFilterListView.getAdapter().getCount();
    for (int i = 0; i < filterItemCount; i++) {
        GamedayTickerFilterCheckbox checkbox = ((GamedayTickerFilterCheckbox) mFilterListView.getAdapter().getItem(i));
        if (checkbox.isChecked()) {
            enabledNotificationKeys.add(checkbox.getKey());
        }
    }
    return enabledNotificationKeys;
}
Also used : AndroidEntryPoint(dagger.hilt.android.AndroidEntryPoint) HashSet(java.util.HashSet) GamedayTickerFilterCheckbox(com.thebluealliance.androidclient.listitems.gameday.GamedayTickerFilterCheckbox)

Aggregations

GamedayTickerFilterCheckbox (com.thebluealliance.androidclient.listitems.gameday.GamedayTickerFilterCheckbox)2 ListViewAdapter (com.thebluealliance.androidclient.adapters.ListViewAdapter)1 ListItem (com.thebluealliance.androidclient.listitems.ListItem)1 AndroidEntryPoint (dagger.hilt.android.AndroidEntryPoint)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1