| | |
| | | package com.dayu.qiheonlinelibrary.net; |
| | | |
| | | import android.os.Handler; |
| | | import android.os.Looper; |
| | | import android.text.TextUtils; |
| | | |
| | | import com.dayu.qiheonlinelibrary.QHOnLineApplication; |
| | | import com.dayu.qiheonlinelibrary.utils.SharedPreferencesHelper; |
| | | import com.dayu.qiheonlinelibrary.utils.ToastUtil; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | |
| | | import java.io.IOException; |
| | | import java.net.ConnectException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import okhttp3.FormBody; |
| | | import okhttp3.Interceptor; |
| | | import okhttp3.MediaType; |
| | | import okhttp3.Protocol; |
| | | import okhttp3.Request; |
| | | import okhttp3.RequestBody; |
| | | import okhttp3.Response; |
| | | import okhttp3.ResponseBody; |
| | | |
| | |
| | | |
| | | Request myRequest = createRequest(chain.request()); |
| | | if (myRequest != null) { |
| | | Response response = chain.proceed(myRequest); |
| | | Response response = null; |
| | | try { |
| | | response = chain.proceed(myRequest); |
| | | } catch (ConnectException e) { |
| | | e.printStackTrace(); |
| | | return getNullResponse(request); |
| | | } |
| | | return response; |
| | | } else { |
| | | ToastUtil.showToastLong(QHOnLineApplication.qhAloneApplication.application, "请检查网络连接!!"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | * @return |
| | | */ |
| | | public Response getNullResponse(Request request) { |
| | | // 显示Toast提示 |
| | | new Handler(Looper.getMainLooper()).post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | ToastUtil.showToastLong(QHOnLineApplication.getInstance().application.getApplicationContext(), "请检查网络!!!"); |
| | | } |
| | | }); |
| | | int code = 20010; |
| | | String message = "咦,请检查网络"; |
| | | String errJson = "{\"code\":" + code + ",\"message\":\"" + message + "\"}"; |