clean up horizontal card layout
This commit is contained in:
parent
023b4a1184
commit
94f5478316
5 changed files with 15 additions and 10 deletions
|
|
@ -35,7 +35,7 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
|||
@Override
|
||||
protected void setColors(int color, ViewHolder holder) {
|
||||
if (holder.itemView != null) {
|
||||
CardView card=(CardView)holder.itemView;
|
||||
CardView card = (CardView) holder.itemView;
|
||||
card.setCardBackgroundColor(color);
|
||||
if (holder.title != null) {
|
||||
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||
|
|
@ -79,6 +79,6 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return HorizontalAdapterHelper.getItemViewtype(position, getItemCount());
|
||||
return HorizontalAdapterHelper.getItemViewType(position, getItemCount());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ public class HorizontalAdapterHelper {
|
|||
|
||||
public static void applyMarginToLayoutParams(Context context, ViewGroup.MarginLayoutParams layoutParams, int viewType) {
|
||||
int listMargin = context.getResources().getDimensionPixelSize(R.dimen.default_item_margin);
|
||||
|
||||
layoutParams.leftMargin = listMargin / 3;
|
||||
layoutParams.rightMargin = listMargin / 3;
|
||||
if (viewType == TYPE_FIRST) {
|
||||
layoutParams.leftMargin = listMargin;
|
||||
} else if (viewType == TYPE_LAST) {
|
||||
|
|
@ -21,11 +24,13 @@ public class HorizontalAdapterHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getItemViewtype(int position, int itemCount) {
|
||||
public static int getItemViewType(int position, int itemCount) {
|
||||
if (position == 0) {
|
||||
return TYPE_FIRST;
|
||||
} else if (position == itemCount - 1) {
|
||||
return TYPE_LAST;
|
||||
} else return TYPE_MIDDLE;
|
||||
} else {
|
||||
return TYPE_MIDDLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue