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
package safeluck.drive.evaluation.fragment;
 
import android.os.Bundle;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
 
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
 
import com.anyun.exam.lib.AYSdk;
import com.anyun.exam.lib.MyLog;
 
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
 
import me.yokeyword.fragmentation.SupportFragment;
import safeluck.drive.evaluation.DB.gps.GPSInfo;
import safeluck.drive.evaluation.DB.gps.GpsInfoViewModel;
import safeluck.drive.evaluation.DB.rtktb.RTKConfig;
import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.adapter.GpsInfoAdapter;
import safeluck.drive.evaluation.util.Utils;
 
/**
 * FTP配置UI
 * MyApplication2
 * Created by lzw on 2019/3/20. 11:22:39
 * 邮箱:632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class GpsInfoFragment extends SupportFragment {
 
    private static final String TAG = "RTKConfigFragment";
 
    private ListView lv;
    private GpsInfoAdapter gpsInfoAdapter;
    private List<String> gpsinfos = new ArrayList<>();
 
 
    public static SupportFragment newInstance() {
        return new GpsInfoFragment();
    }
 
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
 
        View view = inflater.inflate(R.layout.layout_gps_info, container, false);
        initView(view);
        GpsInfoViewModel gpsInfoViewModel = ViewModelProviders.of(this).get(GpsInfoViewModel.class);
        gpsInfoViewModel.getGpsInfo().observe(this, new Observer<GPSInfo>() {
            @Override
            public void onChanged(GPSInfo gpsInfo) {
                if (gpsInfo != null) {
                    MyLog.i(TAG, "gpsinfo=" + gpsInfo == null ? "null" : gpsInfo.toString());
                    gpsinfos.clear();
                    Field[] fields = gpsInfo.getClass().getDeclaredFields();
                    for (int i = 0; i < fields.length; i++) {
                        //设置是否允许访问,不是修改原来的访问权限修饰词。
                        fields[i].setAccessible(true);
                        try {
                            if (fields[i].getName().equalsIgnoreCase("id")) {
                                continue;
                            }
                            gpsinfos.add(fields[i].getName() + ":" + fields[i].get(gpsInfo));
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        }
                    }
 
                    gpsInfoAdapter.addAll(gpsinfos);
                }else{
                    MyLog.i(TAG,"未检测到GPS数据库信息");
                }
 
            }
        });
        return view;
    }
 
    private void initView(View view) {
        lv = view.findViewById(R.id.lv_gpsinfo);
        gpsInfoAdapter = new GpsInfoAdapter(_mActivity);
        lv.setAdapter(gpsInfoAdapter);
 
    }
 
}