Massive adapter clean up. Lots of stuff unfinished there yet. Don't mess around with it yet.
This commit is contained in:
parent
98dcdf2d47
commit
0650df6250
35 changed files with 847 additions and 1438 deletions
|
|
@ -0,0 +1,34 @@
|
|||
package com.kabouzeid.gramophone.helper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class HorizontalAdapterHelper {
|
||||
public static final int LAYOUT_RES = R.layout.item_grid_card_horizontal;
|
||||
|
||||
public static final int TYPE_FIRST = 1;
|
||||
public static final int TYPE_MIDDLE = 2;
|
||||
public static final int TYPE_LAST = 3;
|
||||
|
||||
public static void applyMarginToLayoutParams(Context context, ViewGroup.MarginLayoutParams layoutParams, int viewType) {
|
||||
int listMargin = context.getResources().getDimensionPixelSize(R.dimen.default_item_margin);
|
||||
if (viewType == TYPE_FIRST) {
|
||||
layoutParams.leftMargin = listMargin;
|
||||
} else if (viewType == TYPE_LAST) {
|
||||
layoutParams.rightMargin = listMargin;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue