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.iconCollapse
});
final int iconCollapseResId = styledAttributes.getResourceId(0,
R.drawable.ic_expand_less_white_24dp);
final int iconExpandResId = styledAttributes.getResourceId(1,
R.drawable.ic_expand_more_white_24dp);
final int iconCollapseResId =
styledAttributes.getResourceId(styledAttributes.getIndex(0), R.drawable.ic_expand_less_white_24dp);
final int iconExpandResId =
styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_expand_more_white_24dp);
styledAttributes.recycle();
mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -119,7 +119,7 @@ public class EditHostActivity extends BaseActivity implements
if (actionBar != null) {
actionBar.setTitle(R.string.edit_xbmc);
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();
actionBar.setDisplayHomeAsUpEnabled(true);
}

View File

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