package safeluck.drive.evaluation.bean;
|
|
import android.content.Context;
|
import android.util.Log;
|
|
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.ViewModelProviders;
|
|
import com.anyun.exam.lib.MyLog;
|
|
import java.util.Random;
|
|
import safeluck.drive.evaluation.app;
|
import safeluck.drive.evaluation.util.SPUtils;
|
import safeluck.drive.evaluation.viewmodels.ExamPlatformModel;
|
import safeluck.drive.evaluation.viewmodels.MainViewModel;
|
|
public class ExamPlatformData {
|
private static final ExamPlatformData ourInstance = new ExamPlatformData();
|
|
private int exam_id =12345;//考试唯一ID
|
|
private String id;//身份证
|
|
private String ip;
|
private int port;
|
private String mapPath;//绝对路径包含文件名的path
|
private String carPath;//绝对路径包含文件名的path
|
|
public static ExamPlatformData getInstance() {
|
return ourInstance;
|
}
|
|
|
private ExamPlatformData() {
|
}
|
|
public String getPlatformIP(){
|
ip = (String) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_IP,"47.93.157.103");
|
return ip;
|
}
|
|
public int getPlatformPort(){
|
port = (int) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_PORT,2020);
|
return port;
|
}
|
|
/**
|
* 插入平台IP地址
|
* @param ip
|
*/
|
public void insertPlatformIp(String ip){
|
|
SPUtils.put(app.getAppContext(),SPUtils.PLATFORM_IP,ip);
|
|
}
|
|
/**
|
* 比较ip地址和端口号,
|
* @param ip
|
* @param port
|
* @return ip和端口其中有变化,返回true,否则返回false
|
*/
|
public boolean compareIPandPort(String ip,int port){
|
MyLog.i( "compareIPandPort: "+ip+" "+port);
|
if(!getPlatformIP().equalsIgnoreCase(ip) || getPlatformPort()!=port){
|
MyLog.i("ip和端口有变化");
|
return true;
|
}
|
return false;
|
}
|
|
/**
|
* 插入平台端口号
|
* @param port
|
*/
|
public void insertPlatformPort(int port){
|
SPUtils.put(app.getAppContext(),SPUtils.PLATFORM_PORT,port);
|
}
|
|
|
|
public String getID() {
|
return id;
|
}
|
|
public void setId(String id) {
|
this.id = id;
|
}
|
|
public int getExam_id() {
|
return exam_id;
|
}
|
|
public void setNewMapPath(String path) {
|
this.mapPath = path;
|
SPUtils.put(app.getAppContext(),SPUtils.MAP_PATH,mapPath);
|
}
|
|
public String getMapPath(){
|
mapPath = (String) SPUtils.get(app.getAppContext(),SPUtils.MAP_PATH,"");
|
return mapPath;
|
}
|
|
/**
|
* 设置保存地图模型文件(坐标点—)的路径
|
* @param car_path
|
*/
|
public void setCarModelPath(String car_path) {
|
this.carPath = car_path;
|
SPUtils.put(app.getAppContext(),SPUtils.CAR_PATH,car_path);
|
}
|
|
public String getCarModelPath(){
|
carPath = (String) SPUtils.get(app.getAppContext(),SPUtils.CAR_PATH,"");
|
return carPath;
|
}
|
}
|