Source:
<code>private void updateViews() { for (int i = getChildCount() - 1; i >= 3; i--) { removeViewAt(i); } if (mappedTrackInfo == null) { disableView.setEnabled(false); defaultView.setEnabled(false); return; } disableView.setEnabled(true); defaultView.setEnabled(true); trackGroups = mappedTrackInfo.getTrackGroups(rendererIndex); <START> sortedTrackGroups = sortedTrackGroups != null ? sortedTrackGroups : initSortedTrackGroups(trackGroups); <END> trackViews = new CheckedTextView[sortedTrackGroups.length][]; boolean enableMultipleChoiceForMultipleOverrides = shouldEnableMultiGroupSelection(); for (int groupIndex = 0; groupIndex < sortedTrackGroups.length; groupIndex++) { TrackGroup group = sortedTrackGroups.get(groupIndex); boolean enableMultipleChoiceForAdaptiveSelections = shouldEnableAdaptiveSelection(groupIndex); trackViews[groupIndex] = new CheckedTextView[group.length]; for (int trackIndex = 0; trackIndex < group.length; trackIndex++) { if (trackIndex == 0) { addView(inflater.inflate(R.layout.exo_list_divider, this, false)); } int trackViewLayoutId = enableMultipleChoiceForAdaptiveSelections || enableMultipleChoiceForMultipleOverrides ? android.R.layout.simple_list_item_multiple_choice : android.R.layout.simple_list_item_single_choice; CheckedTextView trackView = (CheckedTextView) inflater.inflate(trackViewLayoutId, this, false); trackView.setBackgroundResource(selectableItemBackgroundResourceId); trackView.setText(trackNameProvider.getTrackName(group.getFormat(trackIndex))); if (mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex) == RendererCapabilities.FORMAT_HANDLED) { trackView.setFocusable(true); trackView.setTag(Pair.create(groupIndex, trackIndex)); trackView.setOnClickListener(componentListener); } else { trackView.setFocusable(false); trackView.setEnabled(false); } trackViews[groupIndex][trackIndex] = trackView; addView(trackView); } } updateViewStates(); }</code><technical_language>I this avoiding re-generating sortedTrackGroups if non-null. mappedTrackInfo changed this method called, for example due a call init. need re-generate sortedTrackGroups again</technical_language>

Target:
private void updateViews() { for (int i = getChildCount() - 1; i >= 3; i--) { removeViewAt(i); } if (mappedTrackInfo == null) { disableView.setEnabled(false); defaultView.setEnabled(false); return; } disableView.setEnabled(true); defaultView.setEnabled(true); trackGroups = mappedTrackInfo.getTrackGroups(rendererIndex); sortedTrackGroups = initSortedTrackGroups(trackGroups); trackViews = new CheckedTextView[sortedTrackGroups.length][]; boolean enableMultipleChoiceForMultipleOverrides = shouldEnableMultiGroupSelection(); for (int groupIndex = 0; groupIndex < sortedTrackGroups.length; groupIndex++) { TrackGroup group = sortedTrackGroups.get(groupIndex); boolean enableMultipleChoiceForAdaptiveSelections = shouldEnableAdaptiveSelection(groupIndex); trackViews[groupIndex] = new CheckedTextView[group.length]; for (int trackIndex = 0; trackIndex < group.length; trackIndex++) { if (trackIndex == 0) { addView(inflater.inflate(R.layout.exo_list_divider, this, false)); } int trackViewLayoutId = enableMultipleChoiceForAdaptiveSelections || enableMultipleChoiceForMultipleOverrides ? android.R.layout.simple_list_item_multiple_choice : android.R.layout.simple_list_item_single_choice; CheckedTextView trackView = (CheckedTextView) inflater.inflate(trackViewLayoutId, this, false); trackView.setBackgroundResource(selectableItemBackgroundResourceId); trackView.setText(trackNameProvider.getTrackName(group.getFormat(trackIndex))); if (mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex) == RendererCapabilities.FORMAT_HANDLED) { trackView.setFocusable(true); trackView.setTag(Pair.create(groupIndex, trackIndex)); trackView.setOnClickListener(componentListener); } else { trackView.setFocusable(false); trackView.setEnabled(false); } trackViews[groupIndex][trackIndex] = trackView; addView(trackView); } } updateViewStates(); }