Android Open Source - Pimp_my_Z1 Stack Adapter

From Project

Back to project page Pimp_my_Z1.


The source code is released under:

GNU General Public License

If you think the Android project Pimp_my_Z1 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.fima.cardsui;
//from  w  w  w  .  ja v  a  2s . c om
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.fima.cardsui.objects.AbstractCard;
import com.fima.cardsui.objects.CardStack;

import java.util.ArrayList;

public class StackAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<AbstractCard> mStacks;
    private boolean mSwipeable;

    public StackAdapter(Context context, ArrayList<AbstractCard> stacks,
                        boolean swipable) {
        mContext = context;
        mStacks = stacks;
        mSwipeable = swipable;


    public int getCount() {
        return mStacks.size();

    public CardStack getItem(int position) {
        return (CardStack) mStacks.get(position);

    public long getItemId(int position) {
        return 0;

    public View getView(int position, View convertView, ViewGroup parent) {
        final CardStack stack = getItem(position);

        // the CardStack can decide whether to use convertView or not
        convertView = stack.getView(mContext, convertView, mSwipeable);

        return convertView;

    public void setItems(ArrayList<AbstractCard> stacks) {
        mStacks = stacks;

    public void setSwipeable(boolean b) {
        mSwipeable = b;

    public void setItems(CardStack cardStack, int position) {
        mStacks.set(position, cardStack);


Java Source Code List