package com.sipai.jspatrol.utils;

import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;

public class ProgressForAll {
    public static ProgressDialog progressDialog = null;//进度条

    public static ProgressDialog myProgressDialog = null;//进度条

    //显示进度提示
    public static void showCountProgress(Context context,String title, int total) {
        try {
            if (progressDialog != null) {
                progressDialog.cancel();
            }
            progressDialog = new ProgressDialog(context);
            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressDialog.setMessage(title);
            progressDialog.setMax((int) total);
            progressDialog.show();
//            progressDialog.setProgressNumberFormat("");
        } catch (Exception e) {
        } finally {
        }
    }


    //更新进度提示
    @SuppressLint("SuspiciousIndentation")
    public static void updateCountProgress(int current) {
        try {
            if (progressDialog!=null)
            progressDialog.setProgress((int) current);
        } catch (Exception e) {
        } finally {
        }
    }


    //取消进度提示
    public static void cancelCountProgress() {
        try {
            if (progressDialog != null) {
                progressDialog.dismiss();
                progressDialog.cancel();
            }
        } catch (Exception e) {
        } finally {
        }
    }

    //显示进度提示
    public static void showProgress(Context context,String title, String msg) {
        try {
            if (myProgressDialog != null) {
                myProgressDialog.cancel();
            }
            myProgressDialog = ProgressDialog.show(context, title, msg);
            myProgressDialog.setCancelable(true);
        } catch (Exception e) {
        } finally {
        }
    }

    //取消进度提示
    public static void cancelProgress() {
        try {
            if (myProgressDialog != null) {
                myProgressDialog.dismiss();
                myProgressDialog.cancel();
            }
        } catch (Exception e) {
        } finally {
        }
    }
}
