| | |
| | | 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.lifecycle.Observer; |
| | | import androidx.lifecycle.ViewModelProviders; |
| | | |
| | | 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 |
| | | /** |
| | | * 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{ |
| | | public class GpsInfoFragment extends SupportFragment { |
| | | |
| | | private static final String TAG = "RTKConfigFragment"; |
| | | |
| | | private EditText et_ip,et_port,et_city_id,et_city_province,et_phone; |
| | | private RTKConfigViewModel rtkConfigViewModel; |
| | | private RTKConfig mRtkConfig; |
| | | private ListView lv; |
| | | private GpsInfoAdapter gpsInfoAdapter; |
| | | private List<String> gpsinfos = new ArrayList<>(); |
| | | |
| | | public static SupportFragment newInstance(){ |
| | | |
| | | public static SupportFragment newInstance() { |
| | | return new GpsInfoFragment(); |
| | | } |
| | | |
| | |
| | | @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 initView(); |
| | | } |
| | | }); |
| | | return view; |
| | | } |
| | | |
| | | private View initView() { |
| | | TextView textView = new TextView(_mActivity); |
| | | ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | textView.setText("收到命令[3],Json内容为{\"connected\":0,\"ip\":\"47.93.80.84\",\"port\":12125}"); |
| | | textView.setTextSize(Utils.dp2Px(20)); |
| | | textView.setLayoutParams(layoutParams); |
| | | textView.setGravity(Gravity.CENTER_VERTICAL); |
| | | return textView; |
| | | private void initView(View view) { |
| | | lv = view.findViewById(R.id.lv_gpsinfo); |
| | | gpsInfoAdapter = new GpsInfoAdapter(_mActivity); |
| | | lv.setAdapter(gpsInfoAdapter); |
| | | |
| | | } |
| | | |
| | | } |