package safeluck.drive.evaluation.customview; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; import safeluck.drive.evaluation.R; /** * @ProjectName: DriveJudge * @Package: safeluck.drive.evaluation.customview * @ClassName: LoadProgressDialog * @Description: java类作用描述 * @Author: 李占伟 * @CreateDate: 2020-04-16 09:57 * @UpdateUser: 更新者 * @UpdateDate: 2020-04-16 09:57 * @UpdateRemark: 更新说明 * @Version: 1.0 */ public class LoadProgressDialog extends DialogFragment { private String message="正在加载..."; private boolean canCancel= false; private TextView textView; private Handler handler = new Handler(Looper.getMainLooper()){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.what==1) dismiss(); } }; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.layout_dialog_loading,container,false); initView(view); setCancelable(canCancel); Message message = Message.obtain(); message.what = 1; handler.sendMessageDelayed(message,10*1000); return view; } private void initView(View view) { textView =view.findViewById(R.id.tv_message); } public static LoadProgressDialog newInstance(String message){ LoadProgressDialog fragment = new LoadProgressDialog(); Bundle bundle = new Bundle(); bundle.putString("tittle", message); fragment.setArguments(bundle); return fragment; } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { message = getArguments().getString("title"); textView.setText(message); } }