| | |
| | | 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; |
| | | |
| | | public static ExamPlatformData getInstance() { |
| | | return ourInstance; |
| | | } |
| | | |
| | | private ExamPlatformData() { |
| | | |
| | | private ExamPlatformData() { |
| | | } |
| | | |
| | | public String getPlatformIP(){ |
| | | return (String) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_IP,""); |
| | | ip = (String) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_IP,"47.93.157.103"); |
| | | return ip; |
| | | } |
| | | |
| | | public int getPlatformPort(){ |
| | | return (int) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_PORT,0); |
| | | port = (int) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_PORT,2020); |
| | | return port; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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; |
| | | } |
| | | |
| | | /** |
| | |
| | | SPUtils.put(app.getAppContext(),SPUtils.PLATFORM_PORT,port); |
| | | } |
| | | |
| | | public int getExamUniqueID(){ |
| | | |
| | | |
| | | |
| | | return exam_id; |
| | | public String getID() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public int getExam_id() { |
| | | return exam_id; |
| | | } |
| | | } |