由于在项目开发时,有这样的简单需求,问谷歌,网络上也有好多Utils工具类,但是比较冗余。自己就简单的写了一个简单帮助类。
/**
* 下载文件,更新UI简单帮助类
*
* @author jarlen
*
*/
public class DownLoadHelper
{
private static final int DOWN_BEGIN = 0;
private static final int DOWN_UPDATA = 1;
private static final int DOWN_FINISH = 2;
private static final int DOWN_ERROR = 3;
private Context mContext;
private TextView mTextView;
private ProgressBar mBar;
private Handler handler = new Handler()
{
public void handleMessage(Message msg)
{
if (!Thread.currentThread().isInterrupted())
{
switch (msg.what)
{
case DOWN_BEGIN:
if (mTextView != null)
{
mTextView.setText("开始下载");
}
if(mBar != null)
{
mBar.setProgress(