app/src/main/assets/rtk_config.json
@@ -9,7 +9,7 @@ "imei":"460123874561", "phone":"2019101500000001", "password":"123456789", "registered":1, "registered":0, "interval":1 } app/src/main/java/safeluck/drive/evaluation/Constant.java
@@ -45,11 +45,14 @@ public static final int JUDGE_INFO = 0x000c; public static final String RTK_CONFIG_JSON = "rtk_config.json"; public static final String BIND_DRIVING_TOPIC = "driving"; public static final String BIND_DRIVING_TOPIC = "driving_topic"; public static final long TEST_STU_ID = 1001; //I类评判表 public static final int SUBJECT_I = 1; public static final String MAP = "map.json"; public static final String VEHICLE = "vehiclemodel.json"; public static final String BIND_RTKCONFIG_TOPIC = "rtkconfig_topic"; public static final String BIND_CONNECT_RTK_TOPIC = "rtk_connect_login_topic"; } app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigDao.java
@@ -19,6 +19,5 @@ @Update void update(RTKConfig rtkConfig); @Query("SELECT * from rtkconfig_table") RTKConfig getRTKConfigNoLive(); } app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKWorkRepository.java
@@ -12,18 +12,10 @@ private static final String TAG = "RTKWorkRepository"; private RTKConfigDao rtkConfigDao; private LiveData<RTKConfig> rtkConfig; private RTKConfig rtkConfig1; public RTKWorkRepository(Application application) { rtkConfigDao = WorkRoomDataBase.getWorkRoomDataBase(application).getRTKConfigDao(); rtkConfig = rtkConfigDao.getRTKConfig(); WorkRoomDataBase.dataBaseWriteExecutor.execute(new Runnable() { @Override public void run() { MyLog.d(TAG,"获取RTK配置信息表"); rtkConfig1 = rtkConfigDao.getRTKConfigNoLive(); } }); } @@ -49,16 +41,5 @@ }); } public RTKConfig getRTKConfigNoLive() { if (rtkConfig1 == null){ WorkRoomDataBase.dataBaseWriteExecutor.execute(new Runnable() { @Override public void run() { MyLog.d(TAG,"再次获取RTK配置信息表"); rtkConfig1 = rtkConfigDao.getRTKConfigNoLive(); } }); } return rtkConfig1; } } app/src/main/java/safeluck/drive/evaluation/MainActivity.java
@@ -19,13 +19,25 @@ import me.yokeyword.fragmentation.SupportActivity; import safeluck.drive.evaluation.DB.Student; import safeluck.drive.evaluation.DB.WokViewModel; import safeluck.drive.evaluation.DB.rtktb.RTKConfig; import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel; import safeluck.drive.evaluation.cEventCenter.CEventCenter; import safeluck.drive.evaluation.cEventCenter.ICEventListener; import safeluck.drive.evaluation.fragment.HomeFragment; import com.anyun.exam.lib.AYSdk; import com.anyun.exam.lib.MyLog; import com.google.gson.Gson; import org.json.JSONException; import org.json.JSONObject; import java.util.List; import safeluck.drive.evaluation.util.PermissionManager; import safeluck.drive.evaluation.viewmodels.MainViewModel; import safeluck.drive.evaluation.viewmodels.RTKConnAndLogin; import safeluck.drive.evaluation.viewmodels.RTKConnAndLoginViewModel; public class MainActivity extends SupportActivity { @@ -33,7 +45,81 @@ private String TAG = MainActivity.class.getCanonicalName(); private PermissionManager mPermissionsManager ; private RTKConfig mRTKConfig;//RTK配置信息 private Gson gson = new Gson(); String[] PERMISSIONS = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA}; RTKConnAndLoginViewModel rtkConnAndLoginViewModel; RTKConnAndLogin rtkConnAndLogin; RTKConfigViewModel rtkConfigViewModel; private ICEventListener icEventListener = new ICEventListener() { @Override public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { if (msgCode == Constant.FETCH_RTK_PLATFORM_INFO) { if (mRTKConfig != null) { String rtkjson = gson.toJson(mRTKConfig); //去除id字段 JSONObject jsonObject = null; try { jsonObject = new JSONObject(rtkjson); } catch (JSONException e) { e.printStackTrace(); } jsonObject.remove("_id"); rtkjson = null; rtkjson = jsonObject.toString(); MyLog.i(TAG, "RTK配置信息:" + rtkjson); AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson); } else { MyLog.d(TAG, "RTKConfig未取到数据"); } } if (msgCode == Constant.RTK_PLATFORM_CONNECT_STATUS || msgCode == Constant.RTK_PLATFORM_REGISTER_RESULT) { if (msgCode == Constant.RTK_PLATFORM_REGISTER_RESULT) { try { JSONObject jsonObject3 = new JSONObject((String) obj); int loginCode = jsonObject3.getInt("login_code"); MyLog.d(TAG, "RTK平台登录结果:" + loginCode); rtkConnAndLogin.setLogin_code(loginCode); } catch (JSONException e) { e.printStackTrace(); } } else { try { JSONObject jsonObject3 = new JSONObject((String) obj); int connect_status = jsonObject3.getInt("connected"); MyLog.i(TAG, "RTK平台连接状态:" + connect_status); rtkConnAndLogin.setLogin_code(connect_status); } catch (JSONException e) { e.printStackTrace(); } } rtkConnAndLoginViewModel.getRtkConnAndLogin().postValue(rtkConnAndLogin); } if (msgCode == Constant.RTK_PLATFORM_REGISTER_STATUS) { try { JSONObject jsonObject = new JSONObject((String) obj); String rtkLoginPwd = jsonObject.getString("password"); int reg_code = jsonObject.getInt("register_code"); if (mRTKConfig != null) { mRTKConfig.setPassword(rtkLoginPwd); mRTKConfig.setRegistered(reg_code); rtkConfigViewModel.insertRTKConfig(mRTKConfig); }else{ MyLog.i(TAG,"mRTKConfig == null"); } } catch (JSONException e) { e.printStackTrace(); } } } }; @Override protected void onCreate(Bundle savedInstanceState) { @@ -53,7 +139,18 @@ } }); rtkConfigViewModel = ViewModelProviders.of(this).get(RTKConfigViewModel.class); rtkConfigViewModel.getRTKConfig().observe(this, new Observer<RTKConfig>() { @Override public void onChanged(RTKConfig rtkConfig) { MyLog.i(TAG, "RTKConfig Changed: " + (rtkConfig != null ? rtkConfig.toString() : "null")); mRTKConfig = rtkConfig; } }); rtkConnAndLoginViewModel = ViewModelProviders.of(this).get(RTKConnAndLoginViewModel.class); rtkConnAndLogin = new RTKConnAndLogin(); mPermissionsManager = new PermissionManager(this) { @@ -83,8 +180,6 @@ }; MyLog.i(TAG,"onCreate"); MainViewModel mainViewModel = ViewModelProviders.of(this).get(MainViewModel.class); mainViewModel.getJson().observe(this, new Observer<String>() { @@ -100,11 +195,18 @@ if (findFragment(HomeFragment.class) == null){ loadRootFragment(R.id.fl_container,HomeFragment.newInstance()); } CEventCenter.onBindEvent(true, icEventListener, Constant.BIND_RTKCONFIG_TOPIC);//发送rtk配置消息 CEventCenter.onBindEvent(true, icEventListener, Constant.BIND_CONNECT_RTK_TOPIC);//收到rtk连接 登录结果 } @Override protected void onDestroy() { super.onDestroy(); CEventCenter.onBindEvent(false, icEventListener, Constant.BIND_RTKCONFIG_TOPIC); CEventCenter.onBindEvent(false, icEventListener, Constant.BIND_CONNECT_RTK_TOPIC); Log.i(TAG, "onDestroy: "); } app/src/main/java/safeluck/drive/evaluation/adapter/SimpleFragmentAdapter.java
@@ -9,6 +9,7 @@ import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.fragment.BaseDatasFragment; import safeluck.drive.evaluation.fragment.GpsInfoFragment; import safeluck.drive.evaluation.fragment.RTKConfigFragment; import safeluck.drive.evaluation.fragment.JiaXiaoFragment; @@ -20,7 +21,7 @@ * All Rights Saved! Chongqing AnYun Tech co. LTD */ public class SimpleFragmentAdapter extends FragmentPagerAdapter { private String[] mTitles = new String[]{"基础数据","RTK配置","驾校信息"}; private String[] mTitles = new String[]{"基础数据","RTK配置","GPS信息"}; public SimpleFragmentAdapter(FragmentManager fm) { super(fm); } @@ -37,9 +38,12 @@ supportFragment = RTKConfigFragment.newInstance(); //ftp break; // case 2: // supportFragment = JiaXiaoFragment.newInstance(); // //驾校信息 // break; case 2: supportFragment = JiaXiaoFragment.newInstance(); //驾校信息 supportFragment = GpsInfoFragment.newInstance(); break; default:break; } app/src/main/java/safeluck/drive/evaluation/app.java
@@ -1,6 +1,7 @@ package safeluck.drive.evaluation; import android.app.Application; import android.text.TextUtils; import android.widget.Toast; @@ -16,6 +17,9 @@ import com.anyun.exam.lib.crash.CrashHandler; import com.facebook.stetho.Stetho; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.json.JSONException; @@ -27,6 +31,8 @@ import safeluck.drive.evaluation.DB.failitems.FailedProjRepository; import safeluck.drive.evaluation.DB.rtktb.RTKConfig; import safeluck.drive.evaluation.DB.rtktb.RTKWorkRepository; import safeluck.drive.evaluation.cEventCenter.CEvent; import safeluck.drive.evaluation.cEventCenter.CEventCenter; import safeluck.drive.evaluation.util.FileUtil; import safeluck.drive.evaluation.util.SystemUtil; @@ -67,17 +73,7 @@ Stetho.initializeWithDefaults(this); //RTK配置信息 // rtkConfig = new RTKConfig(); // rtkConfig.setCity(12); // rtkConfig.setImei("460123874561"); // rtkConfig.setInterval(1); // rtkConfig.setIp("47.93.80.84"); // rtkConfig.setModel("123"); // rtkConfig.setPhone("2019101500000001"); // rtkConfig.setPort(12125); // rtkConfig.setProvince(23); // rtkConfig.setSn("2019101500000001"); //数据库操作 MyLog.i(TAG, "onCreate111"); failedProjRepository = new FailedProjRepository(this); @@ -104,70 +100,34 @@ MyLog.d(TAG, String.format("收到命令[%d],Json内容为%s", cmd, json)); switch (cmd) { case Constant.NDK_START: Toast.makeText(this, "NDK start", Toast.LENGTH_SHORT).show(); break; case Constant.RTK_PLATFORM_REGISTER_STATUS: //RTK平台注册状态,需要保存数据库 CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json); failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(26), Constant.TEST_STU_ID)); rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); try { JSONObject jsonObject = new JSONObject(json); String rtkLoginPwd = jsonObject.getString("password"); int reg_code = jsonObject.getInt("register_code"); rtkConfig.setPassword(rtkLoginPwd); rtkConfig.setRegistered(reg_code); } catch (JSONException e) { e.printStackTrace(); } rtkWorkRepository.insertRTKConfig(rtkConfig); break; case Constant.RTK_PLATFORM_REGISTER_RESULT: failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(26), Constant.TEST_STU_ID)); try { JSONObject jsonObject = new JSONObject(json); int rtklogincode = jsonObject.getInt("login_code"); rtkConfig.setRegistered(rtklogincode); } catch (JSONException e) { e.printStackTrace(); } //RTK平台登录结果 CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json); break; case Constant.FETCH_RTK_PLATFORM_INFO: rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); if (gson == null) { gson = new Gson(); } if (rtkConfig==null){ rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); } if (rtkConfig != null){ String rtkjson = gson.toJson(rtkConfig); MyLog.i(TAG, "RTK配置信息:" + rtkjson); //去除id字段 JSONObject jsonObject = null; try { jsonObject = new JSONObject(rtkjson); } catch (JSONException e) { e.printStackTrace(); } jsonObject.remove("_id"); rtkjson = null; rtkjson = jsonObject.toString(); MyLog.i(TAG, "RTK配置信息:" + rtkjson); AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson); } CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,cmd,0,""); break; case Constant.JUDGE_INFO: if(!TextUtils.isEmpty(json)){ JsonArray jsonArray = JsonParser.parseString(json).getAsJsonArray(); for (int i = 0; i < jsonArray.size(); i++) { JsonObject jsonObject = jsonArray.get(i).getAsJsonObject(); int emp_id = jsonObject.get("wrong_id").getAsInt(); failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd, Constant.TEST_STU_ID)); failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, emp_id, Constant.TEST_STU_ID)); } } break; case Constant.EXAM_STATUS_REPLY: @@ -175,20 +135,8 @@ failedProjRepository.deleteAll(); break; case Constant.RTK_PLATFORM_CONNECT_STATUS: rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); try { JSONObject jsonObject3 = new JSONObject(json); String ip = jsonObject3.getString("ip"); int port = jsonObject3.getInt("port"); int reg_code = jsonObject3.getInt("connected"); rtkConfig.setRegistered(reg_code); rtkConfig.setIp(ip); rtkConfig.setPort(port); } catch (JSONException e) { e.printStackTrace(); } rtkWorkRepository.insertRTKConfig(rtkConfig); CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json); break; case Constant.FETCH_MAP_INFO: app/src/main/java/safeluck/drive/evaluation/fragment/BaseSettingFragment.java
@@ -59,6 +59,7 @@ tabLayout.addTab(tabLayout.newTab()); tabLayout.addTab(tabLayout.newTab()); tabLayout.addTab(tabLayout.newTab()); // tabLayout.addTab(tabLayout.newTab()); tb = view.findViewById(R.id.toolbar); tb.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); tb.setNavigationOnClickListener(new View.OnClickListener() { app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java
New file @@ -0,0 +1,61 @@ 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.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProviders; import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.DB.rtktb.RTKConfig; import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel; import safeluck.drive.evaluation.R; 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 EditText et_ip,et_port,et_city_id,et_city_province,et_phone; private RTKConfigViewModel rtkConfigViewModel; private RTKConfig mRtkConfig; public static SupportFragment newInstance(){ return new GpsInfoFragment(); } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return initView(); } 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; } } app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java
@@ -7,6 +7,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; @@ -18,6 +19,7 @@ import me.yokeyword.fragmentation.ISupportFragment; import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.BuildConfig; import safeluck.drive.evaluation.R; import safeluck.drive.evaluation.util.DimenUtil; @@ -29,6 +31,8 @@ * All Rights Saved! Chongqing AnYun Tech co. LTD */ public class HomeFragment extends SupportFragment implements View.OnClickListener { private TextView tv_app_version; public static ISupportFragment newInstance() { return new HomeFragment(); } @@ -47,6 +51,9 @@ 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)); } @@ -99,13 +106,18 @@ break; case R.id.system_setting: //打开输入密码界面 PasswordFragment passwordFragment = findFragment(PasswordFragment.class); if (passwordFragment == null) { passwordFragment = (PasswordFragment) PasswordFragment.newInstance(); start(passwordFragment); } else { start(passwordFragment); // 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; } app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -17,6 +17,7 @@ import androidx.lifecycle.ViewModelProviders; import com.anyun.exam.lib.AYSdk; import com.anyun.exam.lib.MyLog; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -35,6 +36,7 @@ import safeluck.drive.evaluation.R; import safeluck.drive.evaluation.adapter.ScoreAdapter; import safeluck.drive.evaluation.bean.ScoreBean; import safeluck.drive.evaluation.cEventCenter.CEventCenter; /** * 联网训练UI @@ -85,6 +87,7 @@ } private void initView(View view) { sendRTKConfig2RemoteService(); mListView = view.findViewById(R.id.lv); mListView.setFocusable(false); view.findViewById(R.id.view_map).setOnClickListener(this); @@ -96,7 +99,10 @@ mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item,null)); } private void sendRTKConfig2RemoteService() { MyLog.d(TAG,"主动推送RTKConfig"); CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.FETCH_RTK_PLATFORM_INFO,0,""); } @Override public void onClick(View v) { switch (v.getId()){ app/src/main/java/safeluck/drive/evaluation/fragment/RTKConfigFragment.java
@@ -1,5 +1,6 @@ package safeluck.drive.evaluation.fragment; import android.content.Context; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -11,13 +12,20 @@ import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget.TextView; import com.anyun.exam.lib.MyLog; import com.google.gson.Gson; import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.Constant; import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel; import safeluck.drive.evaluation.R; import safeluck.drive.evaluation.DB.rtktb.RTKConfig; import safeluck.drive.evaluation.cEventCenter.CEventCenter; import safeluck.drive.evaluation.cEventCenter.ICEventListener; import safeluck.drive.evaluation.viewmodels.RTKConnAndLogin; import safeluck.drive.evaluation.viewmodels.RTKConnAndLoginViewModel; /**FTP配置UI * MyApplication2 @@ -30,6 +38,8 @@ private static final String TAG = "RTKConfigFragment"; private EditText et_ip,et_port,et_city_id,et_city_province,et_phone; // RTK注册状态、RTK连接状态、 private TextView tv_reg,tv_connect,tv_model,tv_sn,tv_imei,tv_login; private RTKConfigViewModel rtkConfigViewModel; private RTKConfig mRtkConfig; @@ -55,8 +65,25 @@ et_city_province.setText(String.valueOf(rtkConfig.getProvince())); et_port.setText(String.valueOf(rtkConfig.getPort())); et_phone.setText(rtkConfig.getPhone()); tv_sn.setText(getResources().getString(R.string.rtk_config_sn,rtkConfig.getSn())); tv_model.setText(getResources().getString(R.string.rtk_config_model,rtkConfig.getModel())); tv_imei.setText(getResources().getString(R.string.rtk_config_imei,rtkConfig.getImei())); tv_reg.setText(getResources().getString(R.string.rtk_register_status,rtkConfig.getRegistered())); } }); RTKConnAndLoginViewModel rtkConnAndLoginViewModel = ViewModelProviders.of(this).get(RTKConnAndLoginViewModel.class); rtkConnAndLoginViewModel.getRtkConnAndLogin().observe(this, new Observer<RTKConnAndLogin>() { @Override public void onChanged(RTKConnAndLogin rtkConnAndLogin) { MyLog.i(TAG,"平台登录结果及连接状态"+rtkConnAndLogin.toString()); tv_connect.setText(getResources().getString(R.string.rtk_connect_status,rtkConnAndLogin.getConnect_status())); tv_connect.setText(getResources().getString(R.string.rtk_config_login,rtkConnAndLogin.getLogin_code())); } }); return view; } @@ -67,6 +94,13 @@ et_city_province = view.findViewById(R.id.et_provice_id); et_phone = view.findViewById(R.id.et_phone); et_port = view.findViewById(R.id.rtk_addr_port); tv_connect = view.findViewById(R.id.tv_rtk_connect);//RTK平台连接状态 tv_imei = view.findViewById(R.id.tv_rtk_imei); tv_login = view.findViewById(R.id.tv_rtk_login);//RTK平台登录结果 tv_model = view.findViewById(R.id.tv_rtk_model); tv_reg = view.findViewById(R.id.tv_rtk_reg);//RTK平台注册状态 tv_sn = view.findViewById(R.id.tv_rtk_sn); } @Override @@ -84,4 +118,17 @@ break; } } @Override public void onAttach(Context context) { super.onAttach(context); } @Override public void onDetach() { super.onDetach(); } } app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -16,6 +16,8 @@ import android.widget.ListView; import android.widget.Toast; import com.anyun.exam.lib.MyLog; import java.util.ArrayList; import java.util.EventListener; import java.util.List; @@ -99,7 +101,7 @@ return view; } private void initView(View view) { sendRTKConfig2RemoteService(); mListView = view.findViewById(R.id.lv); mListView.setFocusable(false);//listview不获取焦点,不然的话scrollview会顶到底部 view.findViewById(R.id.view_map).setOnClickListener(this); @@ -112,6 +114,12 @@ mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item,null)); } private void sendRTKConfig2RemoteService() { MyLog.d(TAG,"主动推送RTKConfig"); CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.FETCH_RTK_PLATFORM_INFO,0,""); } @Override app/src/main/java/safeluck/drive/evaluation/viewmodels/RTKConnAndLogin.java
New file @@ -0,0 +1,32 @@ package safeluck.drive.evaluation.viewmodels; import androidx.annotation.NonNull; public class RTKConnAndLogin { private int login_code = 1;//RTK平台登录结果 0-成功 其他失败 private int connect_status;//RTK平台连接状态 public int getLogin_code() { return login_code; } public void setLogin_code(int login_code) { this.login_code = login_code; } public int getConnect_status() { return connect_status; } public void setConnect_status(int connect_status) { this.connect_status = connect_status; } @Override public String toString() { return "RTKConnAndLogin{" + "login_code=" + login_code + ", connect_status=" + connect_status + '}'; } } app/src/main/java/safeluck/drive/evaluation/viewmodels/RTKConnAndLoginViewModel.java
New file @@ -0,0 +1,15 @@ package safeluck.drive.evaluation.viewmodels; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; public class RTKConnAndLoginViewModel extends ViewModel { private MutableLiveData<RTKConnAndLogin> rtkConnAndLogin; public MutableLiveData<RTKConnAndLogin> getRtkConnAndLogin(){ if (rtkConnAndLogin == null){ rtkConnAndLogin = new MutableLiveData<>(); } return rtkConnAndLogin; } } app/src/main/res/layout/layout_home_fragment.xml
@@ -91,6 +91,8 @@ style="@style/home_fragment_text" android:text="@string/version_name" android:padding="10dp" android:id="@+id/tv_app_version" android:textSize="20sp" android:textColor="@color/home_version_show" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true"/> app/src/main/res/layout/layout_rtk_setting.xml
@@ -98,6 +98,73 @@ android:layout_marginBottom="10dp" android:background="@color/colorAccent" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:textColor="@android:color/black" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/tv_rtk_reg" android:text="@string/rtk_register_status" android:layout_weight="1"/> <TextView android:textColor="@android:color/black" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/tv_rtk_connect" android:text="@string/rtk_connect_status" android:layout_weight="1"/> <TextView android:textColor="@android:color/black" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/tv_rtk_imei" android:text="@string/rtk_config_imei" android:layout_weight="1"/> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1px" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:background="@color/colorAccent" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:textColor="@android:color/black" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/tv_rtk_login" android:text="@string/rtk_config_login" android:layout_weight="1"/> <TextView android:textColor="@android:color/black" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/tv_rtk_model" android:text="@string/rtk_config_model" android:layout_weight="1"/> <TextView android:textColor="@android:color/black" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/tv_rtk_sn" android:text="@string/rtk_config_sn" android:layout_weight="1"/> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1px" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:background="@color/colorAccent" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" app/src/main/res/values/strings.xml
@@ -4,7 +4,7 @@ <string name="setting">系统设置</string> <string name="vehicle_train">单机训练</string> <string name="vehicle_net">联网考试</string> <string name="version_name">v3.1</string> <string name="version_name">v%1$s</string> <string name="user_id">身份证号:                </string> <string name="inspector">考核员编号:</string> <string name="sys_setting">系统配置</string> @@ -18,4 +18,10 @@ <string name="request_permission">This sample needs camera permission.</string> <string name="camera_error">This device doesn\'t support Camera2 API.</string> <string name="rtk_addr_des">RTK平台地址:</string> <string name="rtk_register_status">RTK注册状态:%1$d</string> <string name="rtk_config_imei">IMEI:%1$s</string> <string name="rtk_config_model">Model:%1$s</string> <string name="rtk_config_sn">SN:%1$s</string> <string name="rtk_connect_status">RTK连接状态:%1$d</string> <string name="rtk_config_login">RTK登录结果:%1$d</string> </resources>