package com.wasu.cs.widget; import android.content.Context; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import com.wasu.frescoimagefetchermodule.FrescoImageFetcherModule; import cn.com.wasu.main.R; public class PosterItemLayout extends RelativeLayout { private ImageView mPosterImgV; private TextView mPosterTV; public PosterItemLayout(Context context) { super(context); initLayout(context); } public PosterItemLayout(Context context, AttributeSet attrs) { super(context, attrs); initLayout(context); } public PosterItemLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initLayout(context); } private void initLayout(Context context) { LayoutInflater.from(context).inflate(R.layout.item_poster, this, true); mPosterImgV = (ImageView) findViewById(R.id.poster_imgv); mPosterTV = (TextView) findViewById(R.id.poster_tv); } public void setImageUrl(String url) { if (TextUtils.isEmpty(url)) { return; } // ImageFetcherModule.getInstance().cancelTask(mPosterImgV); FrescoImageFetcherModule.getInstance().attachImage(url, mPosterImgV); } public void setName(String name) { if (TextUtils.isEmpty(name)) { return; } mPosterTV.setText(name); } }