| | |
| | | package com.dayu.pipirrapp.view; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.os.Build; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.dayu.pipirrapp.MyApplication; |
| | | import com.dayu.pipirrapp.R; |
| | | |
| | | |
| | | public class TipUtil { |
| | | private static Dialog loadingDialog; |
| | | |
| | | public interface TipListener { |
| | | void onCancle(); |
| | | } |
| | | |
| | | /** |
| | | * 显示加载动画 |
| | | * |
| | | * @param activity Activity |
| | | * @param loadingText 加载提示文字 |
| | | */ |
| | | public static void showLoading(Activity activity, String loadingText) { |
| | | if (isDestroy(activity)) { |
| | | return; |
| | | } |
| | | |
| | | dismissLoading(); |
| | | |
| | | View view = LayoutInflater.from(activity).inflate(R.layout.dialog_loading, null); |
| | | TextView tvLoading = view.findViewById(R.id.tv_loading_text); |
| | | tvLoading.setText(loadingText); |
| | | |
| | | loadingDialog = new Dialog(activity, R.style.LoadingDialog); |
| | | loadingDialog.setCancelable(false); |
| | | loadingDialog.setContentView(view); |
| | | |
| | | if (!activity.isFinishing()) { |
| | | loadingDialog.show(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 隐藏加载动画 |
| | | */ |
| | | public static void dismissLoading() { |
| | | if (loadingDialog != null && loadingDialog.isShowing()) { |
| | | loadingDialog.dismiss(); |
| | | loadingDialog = null; |
| | | } |
| | | } |
| | | |
| | | public static void show(Activity mActivity, String data) { |
| | | // Toast.makeText(context, data, Toast.LENGTH_LONG).show(); |
| | | try { |