package cn.net.caoyao.cpzshandset.test;

import android.content.Context;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.ImageView;
import cn.net.caoyao.cpzshandset.R;
import cn.net.caoyao.cpzshandset.common.bitmap.MBitmapService;
import cn.net.caoyao.cpzshandset.common.config.SDCardConfig;
import cn.net.caoyao.cpzshandset.common.config.TConfig;
import cn.net.caoyao.cpzshandset.common.util.LogUtil;
import cn.net.caoyao.cpzshandset.ui.activity.base.BaseActivity;
import cn.net.caoyao.cpzshandset.ui.adapter.ProductImageAdapter;

public class TestActivity extends BaseActivity implements OnClickListener{
	private View btn_download_image,btn_download_show,btn_clear_cache;
	private Context context;
	private MBitmapService bitmapService;
	private ImageView image_show;
	private GridView gv_test;
	private ProductImageAdapter adapter;
	private Handler mHandler = new Handler(){
		public void handleMessage(android.os.Message msg) {};
	};

	@Override
	public int loadView() {
		init();
		return R.layout.activity_echo_test;
	}

	private void init() {
		context = this;
		bitmapService = MBitmapService.create(MBitmapService.getInstance(context), context, SDCardConfig.getImageCachePath(context));
	}

	@Override
	public void initTitleView() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void initView() {
		btn_download_image = findViewById(R.id.btn_download_image);
		btn_download_show = findViewById(R.id.btn_download_show);
		image_show = (ImageView) findViewById(R.id.image_show);
		gv_test = (GridView) findViewById(R.id.gv_test);
		btn_clear_cache = findViewById(R.id.btn_clear_cache);
	}

	@Override
	public void initPresenter() {
		
	}

	@Override
	public void setListener() {
		btn_download_image.setOnClickListener(this);
		btn_download_show.setOnClickListener(this);	
		btn_clear_cache.setOnClickListener(this);
	}

	@Override
	public void initData() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_download_image:
//			FileUtils.delDir(SDCardConfig.getImageCachePath(context));
//			ThreadPoolManager.getThreadPool().execute(new DownloadImageRunable(mHandler, Images.imageUrls, bitmapService));
			break;
		case R.id.btn_download_show:
//			adapter = new ProductImageAdapter(Images.imageUrls, bitmapService);
//			gv_test.setAdapter(adapter);
//			bitmapService.display(image_show, Images.imageUrls[0]);
			break;
		case R.id.btn_clear_cache:
			LogUtil.v(TConfig.Echo, "清除图片缓存");
			bitmapService.clearCache(Images.imageUrls[10]);
			break;
		}
	}

}
