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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package safeluck.drive.evaluation.fragment;
 
 
import android.os.Bundle;
 
import android.view.Gravity;
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 me.yokeyword.fragmentation.ISupportFragment;
import me.yokeyword.fragmentation.SupportFragment;
import safeluck.drive.evaluation.BuildConfig;
import safeluck.drive.evaluation.R;
 
 
/**
 * 首页
 * MyApplication2
 * Created by lzw on 2019/3/15. 10:21:58
 * 邮箱:632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class HomeFragment extends SupportFragment implements View.OnClickListener {
 
    private static final String TAG = HomeFragment.class.getSimpleName();
    private TextView tv_app_version;
    public static ISupportFragment newInstance() {
        return new HomeFragment();
    }
 
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
 
        View view = inflater.inflate(R.layout.layout_home_fragment, container, false);
        initView(view);
 
        return view;
    }
 
    private void initView(View view) {
        view.findViewById(R.id.network_train).setOnClickListener(this);
        view.findViewById(R.id.car_train).setOnClickListener(this);
        view.findViewById(R.id.system_setting).setOnClickListener(this);
        view.findViewById(R.id.exit_sys).setOnClickListener(this);
        tv_app_version = view.findViewById(R.id.tv_app_version);
 
        tv_app_version.setText(getResources().getString(R.string.version_name,BuildConfig.VERSION_NAME));
    }
 
 
 
 
 
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.car_train:
                //单机训练
                TrainFragment trainFragment = findFragment(TrainFragment.class);
                if (trainFragment == null) {
                    trainFragment = (TrainFragment) TrainFragment.newInstance();
                    start(trainFragment);
                } else {
                    start(trainFragment);
                }
                break;
            case R.id.network_train:
                NetWorkTrainFragment netWorkTrainFragment = findFragment(NetWorkTrainFragment.class);
                if (netWorkTrainFragment == null) {
                    netWorkTrainFragment = (NetWorkTrainFragment) NetWorkTrainFragment.newInstance();
                    start(netWorkTrainFragment);
                } else {
                    start(netWorkTrainFragment);
                }
                //联网考试
                break;
            case R.id.exit_sys:
                //退出系统
//                AlertDialog.Builder builder = new AlertDialog.Builder(_mActivity);
//                builder.setMessage("您将退出系统,请确认数据已保存").setPositiveButton("确定", new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        _mActivity.finish();
//                    }
//                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        dialog.dismiss();
//                    }
//                }).show();
                    TakePhotoFragment takePhotoFragment = findFragment(TakePhotoFragment.class);
                    if (takePhotoFragment == null){
                        takePhotoFragment = TakePhotoFragment.newInstance();
                    }
                    start(takePhotoFragment);
 
                break;
            case R.id.system_setting:
                //打开输入密码界面
//                PasswordFragment passwordFragment = findFragment(PasswordFragment.class);
//                if (passwordFragment == null) {
//                    passwordFragment = (PasswordFragment) PasswordFragment.newInstance();
//                    start(passwordFragment);
//                } else {
//                    start(passwordFragment);
//                }
                BaseSettingFragment sysSetingFragment = findFragment(BaseSettingFragment.class);
                if (sysSetingFragment == null) {
                    sysSetingFragment = (BaseSettingFragment) BaseSettingFragment.newInstance();
                }
                start(sysSetingFragment);
 
                break;
        }
    }
}