package com.photoselector.ui;
/**
 * 
 * @author Aizaz AZ
 *
 */
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.synconset.FakeR;
import com.photoselector.model.AlbumModel;

public class AlbumItem extends LinearLayout {

	private FakeR fakeR;

	private ImageView ivAlbum, ivIndex;
	private TextView tvName, tvCount;

	public AlbumItem(Context context) {
		this(context, null);
		fakeR = new FakeR(context);
	}

	public AlbumItem(Context context, AttributeSet attrs) {
		super(context, attrs);
		LayoutInflater.from(context).inflate(fakeR.getId("layout", "layout_album"), this, true);

		ivAlbum = (ImageView) findViewById(fakeR.getId("id", "iv_album_la"));
		ivIndex = (ImageView) findViewById(fakeR.getId("id", "iv_index_la"));
		tvName = (TextView) findViewById(fakeR.getId("id", "tv_name_la"));
		tvCount = (TextView) findViewById(fakeR.getId("id", "tv_count_la"));
	}

	public AlbumItem(Context context, AttributeSet attrs, int defStyle) {
		this(context, attrs);
	}

	/** ÉèÖÃÏà²á·âÃæ */
	public void setAlbumImage(String path) {
		ImageLoader.getInstance().displayImage("file://" + path, ivAlbum);
	}

	/** ³õÊ¼»¯ */
	public void update(AlbumModel album) {
		setAlbumImage(album.getRecent());
		setName(album.getName());
		setCount(album.getCount());
		isCheck(album.isCheck());
	}

	public void setName(CharSequence title) {
		tvName.setText(title);
	}

	public void setCount(int count) {
		tvCount.setHint(""+count);
	}

	public void isCheck(boolean isCheck) {
		if (isCheck)
			ivIndex.setVisibility(View.VISIBLE);
		else
			ivIndex.setVisibility(View.GONE);
	}

}

@@ -738,16 +738,46 @@
 attrs);%0A
+%09%09fakeR = new FakeR(context);%0A
 %09%09Layout
@@ -1243,16 +1243,46 @@
 attrs);%0A
+%09%09fakeR = new FakeR(context);%0A
 %09%7D%0A%0A%09/**

fix nullpointerexception on faker when overloaded constructor called