From 82e853c976f0d268df2b493b2db89671748f35a6 Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期四, 02 四月 2020 11:02:58 +0800
Subject: [PATCH] 实现从"https://trainsim-api.aaej.cn/"获取map和car模型的http接口

---
 app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java |   78 ++++++++++++++++++++++++++++-----------
 1 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java
index 6564fe4..99a1fbc 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java
@@ -5,6 +5,7 @@
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
+import android.os.Looper;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -12,6 +13,7 @@
 import android.view.ViewGroup;
 import android.widget.Button;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import androidx.appcompat.widget.AppCompatEditText;
 import androidx.lifecycle.Observer;
@@ -22,6 +24,7 @@
 import com.google.android.material.textfield.TextInputEditText;
 import com.safeluck.aykj.utils.BytesUtils;
 
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.util.concurrent.Executors;
@@ -29,10 +32,18 @@
 import java.util.concurrent.TimeUnit;
 
 import me.yokeyword.fragmentation.SupportFragment;
+import okhttp3.ResponseBody;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import retrofit2.Retrofit;
 import safeluck.drive.evaluation.DB.criterias.CriteriaForI;
 import safeluck.drive.evaluation.DB.criterias.viewmodel.CriteriaIViewModel;
 import safeluck.drive.evaluation.R;
 import safeluck.drive.evaluation.bean.ExamPlatformData;
+import safeluck.drive.evaluation.httpmodule.AYApiService;
+import safeluck.drive.evaluation.httpmodule.HttpRequetBean;
+import safeluck.drive.evaluation.httpmodule.RetrofitCreator;
 import safeluck.drive.evaluation.im.MessageProcessor;
 import safeluck.drive.evaluation.platformMessage.AttachInfo;
 import safeluck.drive.evaluation.platformMessage.JKMessage0001;
@@ -45,6 +56,7 @@
 import safeluck.drive.evaluation.platformMessage.JKMessage0204;
 import safeluck.drive.evaluation.im.IMSClientBootstrap;
 import safeluck.drive.evaluation.platformMessage.JKMessage0206;
+import safeluck.drive.evaluation.util.CThreadPoolExecutor;
 import safeluck.drive.evaluation.util.SPUtils;
 
 import static safeluck.drive.evaluation.util.Utils.utc2NetWorkTime;
@@ -132,31 +144,53 @@
                 /**======================娴嬭瘯鏁版嵁搴撶粨鏉�==================*/
 
 
-                Speaker speaker = new Speaker(getActivity(),null);
-                speaker.speak("涓浗鍔犳补锛岄噸搴嗗姞娌�");
+//                Speaker speaker = new Speaker(getActivity(),null);
+//                speaker.speak("涓浗鍔犳补锛岄噸搴嗗姞娌�");
+//
+//                String userId = "100002";
+//                String token = "token_" + userId;
+////                String hosts = "[{\"host\":\"47.93.80.84\", \"port\":12125}]";
+//                String hosts = "[{\"host\":\"47.93.157.103\", \"port\":2020}]";
+////                String hosts = "[{\"host\":\"192.168.31.77\", \"port\":12125}]";
+//
+//                IMSClientBootstrap.getInstance().init(userId, token, hosts, 1, new IMSConnectStatusCallback() {
+//                    @Override
+//                    public void onConnecting() {
+//
+//                    }
+//
+//                    @Override
+//                    public void onConnected() {
+//
+//                    }
+//
+//                    @Override
+//                    public void onConnectFailed() {
+//
+//                    }
+//                });
 
-                String userId = "100002";
-                String token = "token_" + userId;
-//                String hosts = "[{\"host\":\"47.93.80.84\", \"port\":12125}]";
-                String hosts = "[{\"host\":\"47.93.157.103\", \"port\":2020}]";
-//                String hosts = "[{\"host\":\"192.168.31.77\", \"port\":12125}]";
+                        RetrofitCreator.Companion.getRestService().getMapsAndVehicleModel(new HttpRequetBean("0314200100000004","place")).enqueue(new Callback<ResponseBody>() {
+                            @Override
+                            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
+                                String str = null;
+                                try {
+                                    str = response.body().string();
+                                } catch (IOException e) {
+                                    e.printStackTrace();
+                                }
+                                Log.i(TAG,"鏈嶅姟鍣ㄨ繑鍥炵殑body="+str);
+                                if (Looper.myLooper()==Looper.getMainLooper()){
+                                    Toast.makeText(_mActivity, "涓荤嚎绋�", Toast.LENGTH_SHORT).show();
+                                }
+                            }
 
-                IMSClientBootstrap.getInstance().init(userId, token, hosts, 1, new IMSConnectStatusCallback() {
-                    @Override
-                    public void onConnecting() {
+                            @Override
+                            public void onFailure(Call<ResponseBody> call, Throwable t) {
+                                Log.i(TAG,t.getLocalizedMessage());
+                            }
+                        });
 
-                    }
-
-                    @Override
-                    public void onConnected() {
-
-                    }
-
-                    @Override
-                    public void onConnectFailed() {
-
-                    }
-                });
                 break;
             case R.id.btn_send:
 //                if (connectThread != null){

--
Gitblit v1.8.0