package com.yyrh.ui;


import android.app.Activity;
import android.app.Dialog;
import android.util.Log;
import android.widget.TextView;

 ;import com.yyrh.utils.ResourceUtil;

public class ProgressDialogUtils {
	private static Dialog progressDialog;
	private static Activity activity;
	

	
	public static void show(Activity _activity,final String _mesage){

		if(progressDialog != null && _activity != activity && progressDialog.isShowing()){
			progressDialog.dismiss();
		}

		if(progressDialog == null || _activity != activity){
			activity = _activity;

			progressDialog = new Dialog(_activity,ResourceUtil.getStyleId(_activity, "hnyy_progress_dialog"));
			progressDialog.setContentView(ResourceUtil.getLayoutId(_activity, "hnyy_dialog_progress"));
            progressDialog.setCancelable(false);
            progressDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
            TextView msg =  progressDialog.findViewById(ResourceUtil.getId(_activity, "id_tv_loadingmsg"));
            msg.setText(_mesage);
		}
		if(progressDialog!=null&&_activity == activity){
			 TextView msg = progressDialog.findViewById(ResourceUtil.getId(_activity, "id_tv_loadingmsg"));
	          msg.setText(_mesage);
		}
		_activity.runOnUiThread(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub

				progressDialog.show();
			}
		});
		
	}

	public static boolean isShowing(){
		if (progressDialog.isShowing()){
			return true;
		}else{
			return false;
		}
	}
	public static void dismiss(){

		if(progressDialog != null && activity != null){
			progressDialog.dismiss();
		}
	}
	public static void Destroy(){
		progressDialog=null;
	}
}
