Fix TypedArray.getResourceId warnings/errors

This commit is contained in:
Synced Synapse 2016-09-16 19:09:06 +01:00
parent 5a6b64b90f
commit cf5ab6335e
8 changed files with 39 additions and 37 deletions

View File

@ -437,10 +437,10 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
R.attr.iconExpand, R.attr.iconExpand,
R.attr.iconCollapse R.attr.iconCollapse
}); });
final int iconCollapseResId = styledAttributes.getResourceId(0, final int iconCollapseResId =
R.drawable.ic_expand_less_white_24dp); styledAttributes.getResourceId(styledAttributes.getIndex(0), R.drawable.ic_expand_less_white_24dp);
final int iconExpandResId = styledAttributes.getResourceId(1, final int iconExpandResId =
R.drawable.ic_expand_more_white_24dp); styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_expand_more_white_24dp);
styledAttributes.recycle(); styledAttributes.recycle();
mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() { mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() {

View File

@ -151,38 +151,38 @@ public class NavigationDrawerFragment extends Fragment {
ArrayList<DrawerItem> items = new ArrayList<>(15); ArrayList<DrawerItem> items = new ArrayList<>(15);
items.add(new DrawerItem(DrawerItem.TYPE_HOST, ACTIVITY_HOSTS, hostName, items.add(new DrawerItem(DrawerItem.TYPE_HOST, ACTIVITY_HOSTS, hostName,
styledAttributes.getResourceId(ACTIVITY_HOSTS, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_HOSTS), 0)));
items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_REMOTE, items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_REMOTE,
getString(R.string.remote), getString(R.string.remote),
styledAttributes.getResourceId(ACTIVITY_REMOTE, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_REMOTE), 0)));
if (shownItems.contains(String.valueOf(ACTIVITY_MOVIES))) if (shownItems.contains(String.valueOf(ACTIVITY_MOVIES)))
items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MOVIES, items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MOVIES,
getString(R.string.movies), getString(R.string.movies),
styledAttributes.getResourceId(ACTIVITY_MOVIES, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_MOVIES), 0)));
if (shownItems.contains(String.valueOf(ACTIVITY_TVSHOWS))) if (shownItems.contains(String.valueOf(ACTIVITY_TVSHOWS)))
items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_TVSHOWS, items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_TVSHOWS,
getString(R.string.tv_shows), getString(R.string.tv_shows),
styledAttributes.getResourceId(ACTIVITY_TVSHOWS, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_TVSHOWS), 0)));
if (shownItems.contains(String.valueOf(ACTIVITY_MUSIC))) if (shownItems.contains(String.valueOf(ACTIVITY_MUSIC)))
items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MUSIC, items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MUSIC,
getString(R.string.music), getString(R.string.music),
styledAttributes.getResourceId(ACTIVITY_MUSIC, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_MUSIC), 0)));
if (shownItems.contains(String.valueOf(ACTIVITY_PVR))) if (shownItems.contains(String.valueOf(ACTIVITY_PVR)))
items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_PVR, items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_PVR,
getString(R.string.pvr), getString(R.string.pvr),
styledAttributes.getResourceId(ACTIVITY_PVR, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_PVR), 0)));
if (shownItems.contains(String.valueOf(ACTIVITY_FILES))) if (shownItems.contains(String.valueOf(ACTIVITY_FILES)))
items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_FILES, items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_FILES,
getString(R.string.files), getString(R.string.files),
styledAttributes.getResourceId(ACTIVITY_FILES, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_FILES), 0)));
if (shownItems.contains(String.valueOf(ACTIVITY_ADDONS))) if (shownItems.contains(String.valueOf(ACTIVITY_ADDONS)))
items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_ADDONS, items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_ADDONS,
getString(R.string.addons), getString(R.string.addons),
styledAttributes.getResourceId(ACTIVITY_ADDONS, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_ADDONS), 0)));
items.add(new DrawerItem()); // Divider items.add(new DrawerItem()); // Divider
items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_SETTINGS, items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_SETTINGS,
getString(R.string.settings), getString(R.string.settings),
styledAttributes.getResourceId(ACTIVITY_SETTINGS, 0))); styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_SETTINGS), 0)));
styledAttributes.recycle(); styledAttributes.recycle();
mDrawerListView.setAdapter(new DrawerItemAdapter( mDrawerListView.setAdapter(new DrawerItemAdapter(
@ -456,8 +456,8 @@ public class NavigationDrawerFragment extends Fragment {
R.attr.textColorOverPrimary R.attr.textColorOverPrimary
}); });
Resources resources = context.getResources(); Resources resources = context.getResources();
selectedItemColor = styledAttributes.getColor(0, resources.getColor(R.color.accent_default)); selectedItemColor = styledAttributes.getColor(styledAttributes.getIndex(0), resources.getColor(R.color.accent_default));
hostItemColor = styledAttributes.getColor(1, resources.getColor(R.color.white)); hostItemColor = styledAttributes.getColor(styledAttributes.getIndex(1), resources.getColor(R.color.white));
styledAttributes.recycle(); styledAttributes.recycle();
} }

View File

@ -784,19 +784,19 @@ public class NowPlayingFragment extends Fragment
R.attr.iconRepeatOne}); R.attr.iconRepeatOne});
int accentDefaultColor = getResources().getColor(R.color.accent_default); int accentDefaultColor = getResources().getColor(R.color.accent_default);
if (getPropertiesResult.repeat.equals(PlayerType.Repeat.OFF)) { if (getPropertiesResult.repeat.equals(PlayerType.Repeat.OFF)) {
repeatButton.setImageResource(styledAttributes.getResourceId(1, R.drawable.ic_repeat_white_24dp)); repeatButton.setImageResource(styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_repeat_white_24dp));
repeatButton.clearColorFilter(); repeatButton.clearColorFilter();
} else if (getPropertiesResult.repeat.equals(PlayerType.Repeat.ONE)) { } else if (getPropertiesResult.repeat.equals(PlayerType.Repeat.ONE)) {
repeatButton.setImageResource(styledAttributes.getResourceId(2, R.drawable.ic_repeat_one_white_24dp)); repeatButton.setImageResource(styledAttributes.getResourceId(styledAttributes.getIndex(2), R.drawable.ic_repeat_one_white_24dp));
repeatButton.setColorFilter(styledAttributes.getColor(0, accentDefaultColor)); repeatButton.setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor));
} else { } else {
repeatButton.setImageResource(styledAttributes.getResourceId(1, R.drawable.ic_repeat_white_24dp)); repeatButton.setImageResource(styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_repeat_white_24dp));
repeatButton.setColorFilter(styledAttributes.getColor(0, accentDefaultColor)); repeatButton.setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor));
} }
if (!getPropertiesResult.shuffled) { if (!getPropertiesResult.shuffled) {
shuffleButton.clearColorFilter(); shuffleButton.clearColorFilter();
} else { } else {
shuffleButton.setColorFilter(styledAttributes.getColor(0, accentDefaultColor)); shuffleButton.setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor));
} }
styledAttributes.recycle(); styledAttributes.recycle();

View File

@ -457,10 +457,11 @@ public class PlaylistFragment extends Fragment
TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] {
R.attr.appCardBackgroundColor, R.attr.appCardBackgroundColor,
R.attr.appSelectedCardBackgroundColor}); R.attr.appSelectedCardBackgroundColor});
cardBackgroundColor = styledAttributes.getColor(0, Resources resources = getResources();
getResources().getColor(R.color.dark_content_background)); cardBackgroundColor =
selectedCardBackgroundColor = styledAttributes.getColor(1, styledAttributes.getColor(styledAttributes.getIndex(0), resources.getColor(R.color.dark_content_background));
getResources().getColor(R.color.dark_selected_content_background)); selectedCardBackgroundColor =
styledAttributes.getColor(styledAttributes.getIndex(1), resources.getColor(R.color.dark_selected_content_background));
styledAttributes.recycle(); styledAttributes.recycle();
} }

View File

@ -210,10 +210,10 @@ public class RemoteFragment extends Fragment
R.attr.iconNext, R.attr.iconNext,
R.attr.iconPrevious R.attr.iconPrevious
}); });
fastForwardIcon = styledAttributes.getResourceId(0, R.drawable.ic_fast_forward_white_24dp); fastForwardIcon = styledAttributes.getResourceId(styledAttributes.getIndex(0), R.drawable.ic_fast_forward_white_24dp);
rewindIcon = styledAttributes.getResourceId(1, R.drawable.ic_fast_rewind_white_24dp); rewindIcon = styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_fast_rewind_white_24dp);
skipNextIcon = styledAttributes.getResourceId(2, R.drawable.ic_skip_next_white_24dp); skipNextIcon = styledAttributes.getResourceId(styledAttributes.getIndex(2), R.drawable.ic_skip_next_white_24dp);
skipPreviousIcon = styledAttributes.getResourceId(3, R.drawable.ic_skip_previous_white_24dp); skipPreviousIcon = styledAttributes.getResourceId(styledAttributes.getIndex(3), R.drawable.ic_skip_previous_white_24dp);
styledAttributes.recycle(); styledAttributes.recycle();
// // Pad main content view to account for bottom system bar // // Pad main content view to account for bottom system bar
@ -233,8 +233,8 @@ public class RemoteFragment extends Fragment
R.attr.contentBackgroundColor}); R.attr.contentBackgroundColor});
// R.attr.remoteBackgroundColorFilter}); // R.attr.remoteBackgroundColorFilter});
Resources resources = getResources(); Resources resources = getResources();
int remoteButtonsColor = styledAttributes.getColor(0, resources.getColor(R.color.white)), int remoteButtonsColor = styledAttributes.getColor(styledAttributes.getIndex(0), resources.getColor(R.color.white)),
remoteBackgroundColor = styledAttributes.getColor(1, resources.getColor(R.color.dark_content_background_dim_70pct)); remoteBackgroundColor = styledAttributes.getColor(styledAttributes.getIndex(1), resources.getColor(R.color.dark_content_background_dim_70pct));
styledAttributes.recycle(); styledAttributes.recycle();
leftButton.setColorFilter(remoteButtonsColor); leftButton.setColorFilter(remoteButtonsColor);

View File

@ -465,9 +465,10 @@ public class TVShowEpisodeListFragment extends AbstractDetailsFragment
R.attr.iconCollapse, R.attr.iconCollapse,
R.attr.iconExpand, R.attr.iconExpand,
}); });
themeAccentColor = styledAttributes.getColor(0, getResources().getColor(R.color.accent_default));
iconCollapseResId = styledAttributes.getResourceId(1, R.drawable.ic_expand_less_white_24dp); themeAccentColor = styledAttributes.getColor(styledAttributes.getIndex(0), getResources().getColor(R.color.accent_default));
iconExpandResId = styledAttributes.getResourceId(2, R.drawable.ic_expand_more_white_24dp); iconCollapseResId = styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_expand_less_white_24dp);
iconExpandResId = styledAttributes.getResourceId(styledAttributes.getIndex(2), R.drawable.ic_expand_more_white_24dp);
styledAttributes.recycle(); styledAttributes.recycle();
this.hostManager = HostManager.getInstance(context); this.hostManager = HostManager.getInstance(context);

View File

@ -119,7 +119,7 @@ public class EditHostActivity extends BaseActivity implements
if (actionBar != null) { if (actionBar != null) {
actionBar.setTitle(R.string.edit_xbmc); actionBar.setTitle(R.string.edit_xbmc);
TypedArray styledAttrs = getTheme().obtainStyledAttributes(new int[] {R.attr.iconHosts}); TypedArray styledAttrs = getTheme().obtainStyledAttributes(new int[] {R.attr.iconHosts});
actionBar.setIcon(styledAttrs.getResourceId(0, R.drawable.ic_phonelink_white_24dp)); actionBar.setIcon(styledAttrs.getResourceId(styledAttrs.getIndex(0), R.drawable.ic_phonelink_white_24dp));
styledAttrs.recycle(); styledAttrs.recycle();
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
} }

View File

@ -214,8 +214,8 @@ public class UIUtils {
if (!playPauseIconsLoaded) { if (!playPauseIconsLoaded) {
TypedArray styledAttributes = context.obtainStyledAttributes(new int[]{R.attr.iconPause, R.attr.iconPlay}); TypedArray styledAttributes = context.obtainStyledAttributes(new int[]{R.attr.iconPause, R.attr.iconPlay});
iconPauseResId = styledAttributes.getResourceId(0, R.drawable.ic_pause_white_24dp); iconPauseResId = styledAttributes.getResourceId(styledAttributes.getIndex(0), R.drawable.ic_pause_white_24dp);
iconPlayResId = styledAttributes.getResourceId(1, R.drawable.ic_play_arrow_white_24dp); iconPlayResId = styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_play_arrow_white_24dp);
styledAttributes.recycle(); styledAttributes.recycle();
playPauseIconsLoaded = true; playPauseIconsLoaded = true;
} }