Android业务分类Holder

业务Holder的使用,使业务更方便管理和编码。


import android.content.Context;
import android.view.View;

public class BaseHolder {

    public static final String TAG = "BaseHolder";
    
    private View mContentView;

    private T mData;

    private Context mContext;
 
    public BaseHolder(View contentView) {

        this(null, contentView);
    }

    public BaseHolder(Context context, View contentView) {

        this.mContentView = contentView;
        this.mContext = context;
    }

    public void setData(T data) {

        this.mData = data;

    }

    public T getData() {
        return mData;
    }

    public View getContentView() {
        return mContentView;
    }

    public Context getContext() {
        if (mContentView == null){
            return mContext;
        }
        return mContext == null ? mContentView.getContext() : mContext;
    }
}

你可能感兴趣的:(Android业务分类Holder)