Search in sources :

Example 1 with DrawerGroupItem

use of com.simplecity.amp_library.model.DrawerGroupItem in project Shuttle by timusus.

the class NavigationDrawerAdapter method getRealChildView.

@Override
public View getRealChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
    final ChildViewHolder viewHolder;
    if (convertView == null) {
        convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_drawer, parent, false);
        viewHolder = new ChildViewHolder(convertView);
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ChildViewHolder) convertView.getTag();
    }
    DrawerGroupItem groupItem = getGroup(groupPosition);
    Playlist playlist = groupItem.children.get(childPosition);
    if (playlist != null && mSelectedPlaylist != null) {
        if (playlist.name.equals(mSelectedPlaylist.name)) {
            if (ColorUtils.isPrimaryColorLowContrast(parent.getContext())) {
                viewHolder.lineOne.setTextColor(ColorUtils.getAccentColor());
            } else {
                viewHolder.lineOne.setTextColor(ColorUtils.getPrimaryColor());
            }
        } else {
            viewHolder.lineOne.setTextColor(ColorUtils.getTextColorPrimary());
        }
    }
    convertView.setClickable(true);
    viewHolder.groupPosition = groupPosition;
    viewHolder.childPosition = childPosition;
    viewHolder.expandableIcon.setVisibility(View.GONE);
    viewHolder.lineOne.setText(playlist.name);
    viewHolder.lineOne.setAlpha(0.54f);
    return convertView;
}
Also used : Playlist(com.simplecity.amp_library.model.Playlist) DrawerGroupItem(com.simplecity.amp_library.model.DrawerGroupItem)

Example 2 with DrawerGroupItem

use of com.simplecity.amp_library.model.DrawerGroupItem in project Shuttle by timusus.

the class NavigationDrawerAdapter method setPlaylistData.

public void setPlaylistData(List<Playlist> playlists) {
    for (DrawerGroupItem groupItem : mDrawerGroupItems) {
        if (groupItem.type == DrawerGroupItem.Type.PLAYLISTS) {
            groupItem.children.clear();
            groupItem.addChildren(playlists);
            break;
        }
    }
    notifyDataSetChanged();
}
Also used : DrawerGroupItem(com.simplecity.amp_library.model.DrawerGroupItem)

Example 3 with DrawerGroupItem

use of com.simplecity.amp_library.model.DrawerGroupItem in project Shuttle by timusus.

the class NavigationDrawerAdapter method getGroupView.

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    final GroupViewHolder viewHolder;
    DrawerGroupItem groupItem = getGroup(groupPosition);
    if (groupItem.type == DrawerGroupItem.Type.DIVIDER) {
        convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_drawer_divider, parent, false);
    } else {
        convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_drawer, parent, false);
        viewHolder = new GroupViewHolder(convertView);
        viewHolder.position = groupPosition;
        convertView.setClickable(groupItem.getChildCount() == 0);
        int imageResourceId = isExpanded ? R.drawable.ic_arrow_up : R.drawable.ic_arrow_down;
        viewHolder.expandableIcon.setImageDrawable(parent.getResources().getDrawable(imageResourceId));
        viewHolder.expandableIcon.setVisibility(groupItem.getChildCount() == 0 ? View.GONE : View.VISIBLE);
        if (groupItem.iconResId != -1) {
            viewHolder.icon.setImageDrawable(DrawableUtils.themeLightOrDark(parent.getContext(), parent.getResources().getDrawable(groupItem.iconResId)));
            viewHolder.icon.setVisibility(View.VISIBLE);
        } else {
            viewHolder.icon.setVisibility(View.GONE);
        }
        viewHolder.lineOne.setText(parent.getResources().getString(groupItem.titleResId));
        viewHolder.lineOne.setTypeface(TypefaceManager.getInstance().getTypeface(TypefaceManager.SANS_SERIF_MEDIUM));
        if (mSelectedDrawerGroupItem != null && groupItem.type == mSelectedDrawerGroupItem.type) {
            viewHolder.itemView.setActivated(true);
            if (ColorUtils.isPrimaryColorLowContrast(parent.getContext())) {
                viewHolder.lineOne.setTextColor(ColorUtils.getAccentColor());
                viewHolder.icon.setColorFilter(ColorUtils.getAccentColor(), PorterDuff.Mode.MULTIPLY);
            } else {
                viewHolder.lineOne.setTextColor(ColorUtils.getPrimaryColor());
                viewHolder.icon.setColorFilter(ColorUtils.getPrimaryColor(), PorterDuff.Mode.MULTIPLY);
            }
        } else {
            viewHolder.itemView.setActivated(false);
            viewHolder.lineOne.setTextColor(ColorUtils.getTextColorPrimary());
            viewHolder.icon.setColorFilter(new LightingColorFilter(ThemeUtils.getBaseColor(parent.getContext()), 0));
            viewHolder.icon.setAlpha(0.6f);
        }
        if (groupItem.type == DrawerGroupItem.Type.FOLDERS && !ShuttleUtils.isUpgraded()) {
            viewHolder.itemView.setAlpha(0.4f);
        } else {
            viewHolder.itemView.setAlpha(1.0f);
        }
        if (groupItem.type == DrawerGroupItem.Type.PLAYLISTS) {
            viewHolder.itemView.setAlpha(groupItem.children.isEmpty() ? 0.4f : 1.0f);
            viewHolder.itemView.setEnabled(!groupItem.children.isEmpty());
        }
    }
    return convertView;
}
Also used : LightingColorFilter(android.graphics.LightingColorFilter) DrawerGroupItem(com.simplecity.amp_library.model.DrawerGroupItem)

Aggregations

DrawerGroupItem (com.simplecity.amp_library.model.DrawerGroupItem)3 LightingColorFilter (android.graphics.LightingColorFilter)1 Playlist (com.simplecity.amp_library.model.Playlist)1