package com.wasu.cs.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wasu.cs.model.DemandSeries;
import com.wasu.frescoimagefetchermodule.FrescoImageFetcherModule;

import cn.com.wasu.main.R;

/**
 * Created by LiuYang on 7/17/15.
 */
public class ColumnDetailListItem extends RelativeLayout implements View.OnClickListener{

    private TextView mTextView;
    private ImageView mImageView;
    private DemandSeries mData;

    public ColumnDetailListItem(Context context) {
        super(context);
        init(context);
    }

    public ColumnDetailListItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public ColumnDetailListItem(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context);
    }

    private void init(Context context) {
        LayoutInflater.from(context).inflate(R.layout.item_channel_news_list, this);

//        setFocusable(true);
//        setFocusableInTouchMode(true);
//        setClickable(true);

        mTextView = (TextView) findViewById(R.id.name);
        mImageView = (ImageView) findViewById(R.id.ivPic);

        setOnClickListener(this);
    }

    public void setData(DemandSeries data) {
        this.mData = data;
        mTextView.setText(mData.getTitle());
        FrescoImageFetcherModule.getInstance().attachImage(mData.getPicUrl(), mImageView,getResources().getDimensionPixelSize(R.dimen.d_3dp));
    }

    @Override
    public void onClick(View view) {
//        IntentMap.startIntent(getContext(), null, mData.getLayout(), mData.getJsonUrl(), null);
    }
}
