diff options
Diffstat (limited to 'src/com/android/tv/ui/sidepanel/CustomizeChannelListFragment.java')
-rw-r--r-- | src/com/android/tv/ui/sidepanel/CustomizeChannelListFragment.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/com/android/tv/ui/sidepanel/CustomizeChannelListFragment.java b/src/com/android/tv/ui/sidepanel/CustomizeChannelListFragment.java index 85050dc4..b52302b6 100644 --- a/src/com/android/tv/ui/sidepanel/CustomizeChannelListFragment.java +++ b/src/com/android/tv/ui/sidepanel/CustomizeChannelListFragment.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Iterator; public class CustomizeChannelListFragment extends SideFragment { private static final int GROUP_BY_SOURCE = 0; @@ -157,6 +158,21 @@ public class CustomizeChannelListFragment extends SideFragment { return mItems; } + private void cleanUpOneChannelGroupItem(List<Item> items) { + Iterator<Item> iter = items.iterator(); + while (iter.hasNext()) { + Item item = iter.next(); + if (item instanceof SelectGroupItem) { + SelectGroupItem selectGroupItem = (SelectGroupItem) item; + if (selectGroupItem.mChannelItemsInGroup.size() == 1) { + ((ChannelItem) selectGroupItem.mChannelItemsInGroup.get(0)) + .mSelectGroupItem = null; + iter.remove(); + } + } + } + } + private void addItemForGroupBySource(List<Item> items) { items.add(new GroupBySubMenu(getString(R.string.edit_channels_group_by_sources))); SelectGroupItem selectGroupItem = null; @@ -177,6 +193,7 @@ public class CustomizeChannelListFragment extends SideFragment { items.add(channelItem); selectGroupItem.addChannelItem(channelItem); } + cleanUpOneChannelGroupItem(items); } private void addItemForGroupByHdSd(List<Item> items) { @@ -211,6 +228,7 @@ public class CustomizeChannelListFragment extends SideFragment { items.add(channelItem); selectGroupItem.addChannelItem(channelItem); } + cleanUpOneChannelGroupItem(items); } private static boolean isHdChannel(Channel channel) { @@ -275,7 +293,7 @@ public class CustomizeChannelListFragment extends SideFragment { } private class ChannelItem extends ChannelCheckItem { - private final SelectGroupItem mSelectGroupItem; + private SelectGroupItem mSelectGroupItem; public ChannelItem(Channel channel, SelectGroupItem selectGroupItem) { super(channel, getChannelDataManager(), getProgramDataManager()); @@ -292,7 +310,9 @@ public class CustomizeChannelListFragment extends SideFragment { protected void onSelected() { super.onSelected(); getChannelDataManager().updateBrowsable(getChannel().getId(), isChecked()); - mSelectGroupItem.notifyUpdated(); + if (mSelectGroupItem != null) { + mSelectGroupItem.notifyUpdated(); + } } @Override |