lizhanwei
2020-04-20 7815e8d838fcd1bca3792671dc20dde77125a343
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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);
    }
}