Highlight current selected item on playlist
This commit is contained in:
parent
5038720661
commit
0e90b731dc
|
@ -15,9 +15,12 @@
|
|||
*/
|
||||
package org.xbmc.kore.ui;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -440,6 +443,7 @@ public class PlaylistFragment extends Fragment
|
|||
if ((playlistItems.get(i).id == getItemResult.id) &&
|
||||
(playlistItems.get(i).type.equals(getItemResult.type))) {
|
||||
playlistGridView.setItemChecked(i, true);
|
||||
playlistGridView.setSelection(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -517,9 +521,19 @@ public class PlaylistFragment extends Fragment
|
|||
int artWidth = getResources().getDimensionPixelSize(R.dimen.playlist_art_width);
|
||||
int artHeight = getResources().getDimensionPixelSize(R.dimen.playlist_art_heigth);
|
||||
|
||||
int cardBackgroundColor, selectedCardBackgroundColor;
|
||||
|
||||
public PlayListAdapter(List<ListType.ItemsAll> playlistItems) {
|
||||
super();
|
||||
this.playlistItems = playlistItems;
|
||||
|
||||
Resources.Theme theme = getActivity().getTheme();
|
||||
TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] {
|
||||
R.attr.appCardBackgroundColor,
|
||||
R.attr.appSelectedCardBackgroundColor});
|
||||
cardBackgroundColor = styledAttributes.getColor(0, R.color.dark_content_background);
|
||||
selectedCardBackgroundColor = styledAttributes.getColor(1, R.color.dark_selected_content_background);
|
||||
styledAttributes.recycle();
|
||||
}
|
||||
|
||||
public PlayListAdapter() {
|
||||
|
@ -579,10 +593,11 @@ public class PlaylistFragment extends Fragment
|
|||
viewHolder.details = (TextView)convertView.findViewById(R.id.details);
|
||||
viewHolder.contextMenu = (ImageView)convertView.findViewById(R.id.list_context_menu);
|
||||
viewHolder.duration = (TextView)convertView.findViewById(R.id.duration);
|
||||
viewHolder.card = (CardView)convertView.findViewById(R.id.card);
|
||||
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder)convertView.getTag();
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
final ListType.ItemsAll item = this.getItem(position);
|
||||
|
@ -630,6 +645,10 @@ public class PlaylistFragment extends Fragment
|
|||
viewHolder.duration.setText((duration > 0) ? UIUtils.formatTime(duration) : "");
|
||||
viewHolder.position = position;
|
||||
|
||||
int cardColor = (position == playlistGridView.getCheckedItemPosition()) ?
|
||||
selectedCardBackgroundColor: cardBackgroundColor;
|
||||
viewHolder.card.setCardBackgroundColor(cardColor);
|
||||
|
||||
// If not video, change aspect ration of poster to a square
|
||||
boolean isVideo = (item.type.equals(ListType.ItemsAll.TYPE_MOVIE)) ||
|
||||
(item.type.equals(ListType.ItemsAll.TYPE_EPISODE));
|
||||
|
@ -640,8 +659,8 @@ public class PlaylistFragment extends Fragment
|
|||
artWidth = artHeight;
|
||||
}
|
||||
UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager,
|
||||
artUrl, title,
|
||||
viewHolder.art, artWidth, artHeight);
|
||||
artUrl, title,
|
||||
viewHolder.art, artWidth, artHeight);
|
||||
|
||||
// For the popupmenu
|
||||
viewHolder.contextMenu.setTag(position);
|
||||
|
@ -656,6 +675,7 @@ public class PlaylistFragment extends Fragment
|
|||
TextView details;
|
||||
ImageView contextMenu;
|
||||
TextView duration;
|
||||
CardView card;
|
||||
int position;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
card_view:cardElevation="@dimen/default_card_elevation"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
<attr name="contentBackgroundColor" format="reference|color" />
|
||||
<attr name="appCardBackgroundColor" format="reference|color" />
|
||||
<attr name="appSelectedCardBackgroundColor" format="reference|color" />
|
||||
<attr name="buttonBarBackgroundColor" format="reference|color" />
|
||||
|
||||
<attr name="fabColorNormal" format="reference|color" />
|
||||
|
|
|
@ -33,12 +33,15 @@
|
|||
<!--<color name="dark_content_background_dim_70pct">#b4222326</color>-->
|
||||
<color name="dark_content_background">#ff323232</color>
|
||||
<color name="dark_content_background_dim_70pct">#b4323232</color>
|
||||
<color name="dark_selected_content_background">#ff505050</color>
|
||||
|
||||
<color name="light_content_background">#ffffffff</color>
|
||||
<color name="light_content_background_dim_70pct">#b4ffffff</color>
|
||||
<color name="light_selected_content_background">#ffd1d1d1</color>
|
||||
|
||||
<color name="blue_grey_content_background">#ff263238</color>
|
||||
<color name="blue_grey_content_background_dim_70pct">#b4263238</color>
|
||||
<color name="blue_grey_selected_content_background">#ff43575d</color>
|
||||
|
||||
<color name="dark_separator">#ff505050</color>
|
||||
<color name="light_separator">#ffafafaf</color>
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
|
||||
<item name="contentBackgroundColor">@color/dark_content_background_dim_70pct</item>
|
||||
<item name="appCardBackgroundColor">@color/dark_content_background</item>
|
||||
<item name="appSelectedCardBackgroundColor">@color/dark_selected_content_background</item>
|
||||
<!--<item name="myCardBackgroundDrawable">@drawable/card_background_dark</item>-->
|
||||
<item name="buttonBarBackgroundColor">@color/dark_content_background_dim_70pct</item>
|
||||
|
||||
|
@ -165,6 +166,7 @@
|
|||
|
||||
<item name="contentBackgroundColor">@color/light_content_background_dim_70pct</item>
|
||||
<item name="appCardBackgroundColor">@color/light_content_background</item>
|
||||
<item name="appSelectedCardBackgroundColor">@color/light_selected_content_background</item>
|
||||
<!--<item name="myCardBackgroundDrawable">@drawable/card_background_light</item>-->
|
||||
<item name="buttonBarBackgroundColor">@color/light_content_background_dim_70pct</item>
|
||||
|
||||
|
@ -266,6 +268,7 @@
|
|||
|
||||
<item name="contentBackgroundColor">@color/blue_grey_content_background_dim_70pct</item>
|
||||
<item name="appCardBackgroundColor">@color/blue_grey_content_background</item>
|
||||
<item name="appSelectedCardBackgroundColor">@color/blue_grey_selected_content_background</item>
|
||||
<item name="buttonBarBackgroundColor">@color/blue_grey_content_background_dim_70pct</item>
|
||||
|
||||
<!-- Color for the Navigation Drawer -->
|
||||
|
@ -287,6 +290,7 @@
|
|||
|
||||
<item name="contentBackgroundColor">@color/solarized_base3_dim70pct</item>
|
||||
<item name="appCardBackgroundColor">@color/solarized_base3</item>
|
||||
<item name="appSelectedCardBackgroundColor">@color/white</item>
|
||||
<item name="buttonBarBackgroundColor">@color/solarized_base3_dim70pct</item>
|
||||
|
||||
<!-- Color for the Navigation Drawer -->
|
||||
|
@ -311,6 +315,7 @@
|
|||
<item name="contentBackgroundColor">@color/solarized_base02_dim70pct</item>
|
||||
<item name="appCardBackgroundColor">@color/solarized_base02</item>
|
||||
<item name="buttonBarBackgroundColor">@color/solarized_base02_dim70pct</item>
|
||||
<item name="appSelectedCardBackgroundColor">@color/solarized_base01</item>
|
||||
|
||||
<!-- Color for the Navigation Drawer -->
|
||||
<item name="drawerBackgroundColor">@color/solarized_base02</item>
|
||||
|
|
Loading…
Reference in New Issue