PageRenderTime 33ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/yueai/src/main/java/com/yueai/activity/SplashActivity.java

https://bitbucket.org/juzhiwiscom/datelove
Java | 619 lines | 388 code | 46 blank | 185 comment | 71 complexity | 9607478d34e5f9ce246d5e5fa50aa1a1 MD5 | raw file
  1. package com.yueai.activity;
  2. import android.Manifest;
  3. import android.app.ProgressDialog;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.content.pm.PackageManager;
  7. import android.location.Location;
  8. import android.location.LocationListener;
  9. import android.location.LocationManager;
  10. import android.net.ConnectivityManager;
  11. import android.net.NetworkInfo;
  12. import android.net.Uri;
  13. import android.os.Build;
  14. import android.os.Bundle;
  15. import android.os.Handler;
  16. import android.provider.Settings;
  17. import android.support.annotation.NonNull;
  18. import android.support.v4.app.ActivityCompat;
  19. import android.support.v4.content.ContextCompat;
  20. import android.text.TextUtils;
  21. import android.view.View;
  22. import android.view.animation.AlphaAnimation;
  23. import android.view.animation.Animation;
  24. import android.view.animation.AnimationSet;
  25. import android.view.animation.RotateAnimation;
  26. import android.view.animation.ScaleAnimation;
  27. import android.widget.ImageView;
  28. import com.alibaba.fastjson.JSON;
  29. import com.appsflyer.AppsFlyerLib;
  30. import com.baidu.android.pushservice.PushConstants;
  31. import com.baidu.android.pushservice.PushManager;
  32. import com.library.dialog.OnSingleDialogClickListener;
  33. import com.library.utils.DensityUtil;
  34. import com.library.utils.DialogUtil;
  35. import com.library.utils.LogUtil;
  36. import com.library.utils.TimeUtil;
  37. import com.library.utils.ToastUtil;
  38. import com.library.utils.Util;
  39. import com.library.utils.VersionInfoUtil;
  40. import com.yueai.R;
  41. import com.yueai.base.BaseFragmentActivity;
  42. import com.yueai.bean.BaseModel;
  43. import com.yueai.bean.CheckRefresh;
  44. import com.yueai.bean.LocationInfo;
  45. import com.yueai.bean.LoginEntity;
  46. import com.yueai.bean.PlatformInfo;
  47. import com.yueai.constant.IConfigConstant;
  48. import com.yueai.constant.IUrlConstant;
  49. import com.yueai.utils.AppsflyerUtils;
  50. import com.yueai.utils.CommonRequestUtil;
  51. import com.yueai.utils.GoogleUtil;
  52. import com.yueai.xml.PlatformInfoXml;
  53. import com.yueai.xml.UserInfoXml;
  54. import com.zhy.http.okhttp.OkHttpUtils;
  55. import com.zhy.http.okhttp.callback.Callback;
  56. import com.zhy.http.okhttp.callback.FileCallBack;
  57. import java.io.File;
  58. import java.net.Inet4Address;
  59. import java.net.InetAddress;
  60. import java.net.NetworkInterface;
  61. import java.util.Enumeration;
  62. import java.util.HashMap;
  63. import java.util.Map;
  64. import butterknife.BindView;
  65. import butterknife.ButterKnife;
  66. import okhttp3.Call;
  67. import okhttp3.Response;
  68. /**
  69. * Created by Administrator on 2016/10/18.
  70. */
  71. public class SplashActivity extends BaseFragmentActivity {
  72. @BindView(R.id.iv_yueai)
  73. ImageView ivYueai;
  74. private String UPDATE_SERVERAPK = "YueAi";
  75. private LocationManager mLocationManager;
  76. private static final int PERMISSION_CODE_ACCESS_FINE_LOCATION = 0;
  77. private boolean isFirstInto=true;
  78. @Override
  79. protected int getLayoutResId() {
  80. return R.layout.activity_splash;
  81. }
  82. @Override
  83. protected void initViewsAndVariables() {
  84. // 百度推送service初始化及绑定
  85. PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, IConfigConstant.BAIDU_PUSH_API_KEY);
  86. // AppsFlyer初始化
  87. AppsFlyerLib.getInstance().setAndroidIdData(getAndroidId());
  88. AppsFlyerLib.getInstance().startTracking(this.getApplication(), IConfigConstant.APPSFLYER_DEV_KEY);
  89. // 获得platform信息
  90. getPlatformInfo();
  91. // // 获取位置信息并上传
  92. // requestLocation();
  93. init();
  94. // anim();
  95. }
  96. private void anim() {
  97. //准备动画
  98. AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
  99. alphaAnimation.setDuration(2000); //2秒钟内,透明的0-1
  100. ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1, 0, 1,
  101. Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  102. scaleAnimation.setDuration(2000); //2秒钟内,由没有到有
  103. RotateAnimation rotateAnimation = new RotateAnimation
  104. (0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  105. rotateAnimation.setDuration(2000); // 2秒钟内旋转结束
  106. //动画集合,让上诉三个动画一起执行shareInterpolator true 共享插值器 数学曲线 false 不共享插值器,不共享数学曲线
  107. AnimationSet animationSet = new AnimationSet(false);
  108. animationSet.addAnimation(alphaAnimation);
  109. animationSet.addAnimation(scaleAnimation);
  110. animationSet.addAnimation(rotateAnimation);
  111. ivYueai.startAnimation(animationSet);
  112. //监听动画结束后,跳转到后一个界面(GuideActivity(提示用户项目有什么功能界面,应用程序的主界面))
  113. animationSet.setAnimationListener(new Animation.AnimationListener() {
  114. @Override
  115. public void onAnimationStart(Animation animation) {
  116. //动画开始时候调用方法
  117. }
  118. @Override
  119. public void onAnimationRepeat(Animation animation) {
  120. //动画重复时候调用方法
  121. }
  122. @Override
  123. public void onAnimationEnd(Animation animation) {
  124. //动画结束时候调用方法
  125. //数据的存储(文件存储(sp 数据库 File(sd卡 files文件夹 cache文件))
  126. //内存存储(List(变量,集合))
  127. //网络存储(数据在服务器端))
  128. //
  129. // //SplashActivity.this 创建对话框的时候,需要上下环境,一定要用activity.this
  130. // //getApplicationContext()
  131. // Boolean isFirst = SharePreUtil.getBoolean(getApplicationContext(), ConstantValue.ISFIRST, true);
  132. // if(isFirst){
  133. // //进入包含了viewpager那个导航界面
  134. // Intent intent = new Intent(getApplicationContext(), GuideActivity.class);
  135. // startActivity(intent);
  136. // //将isFirst改为false,并且在本地持久化
  137. // SharePreUtil.saveBoolean(getApplicationContext(), ConstantValue.ISFIRST, false);
  138. // }else{
  139. // //进入应用程序主界面
  140. // Intent intent = new Intent(getApplicationContext(), MainActivity.class);
  141. // startActivity(intent);
  142. // }
  143. // finish();
  144. if (!UserInfoXml.getIsClient()) {
  145. activation();
  146. }
  147. if (UserInfoXml.getUsername() != null && UserInfoXml.getPassword() != null) {
  148. checkRefresh();
  149. } else {
  150. Util.gotoActivity(SplashActivity.this, RegisterActivity.class, true);
  151. }
  152. }
  153. });
  154. }
  155. @Override
  156. protected void addListeners() {
  157. }
  158. protected void init() {
  159. if (!UserInfoXml.getIsClient()) {
  160. activation();
  161. }
  162. new Handler().postDelayed(new Runnable() {
  163. @Override
  164. public void run() {
  165. if (UserInfoXml.getUsername() != null && UserInfoXml.getPassword() != null) {
  166. checkRefresh();
  167. } else {
  168. Util.gotoActivity(SplashActivity.this, RegisterActivity.class, true);
  169. }
  170. }
  171. }, 2000);
  172. }
  173. public void checkRefresh() {
  174. OkHttpUtils.post()
  175. .url(IUrlConstant.URL_CHECK_UPDATE)
  176. .addHeader("token", PlatformInfoXml.getToken())
  177. .addParams("platformInfo", PlatformInfoXml.getPlatformJsonString())
  178. .build()
  179. .execute(new RefreshCallBack());
  180. }
  181. private ProgressDialog pd;
  182. @Override
  183. protected void onCreate(Bundle savedInstanceState) {
  184. super.onCreate(savedInstanceState);
  185. // TODO: add setContentView(...) invocation
  186. ButterKnife.bind(this);
  187. }
  188. public class RefreshCallBack extends Callback<CheckRefresh> {
  189. @Override
  190. public CheckRefresh parseNetworkResponse(Response response, int id) throws Exception {
  191. String resultJson = response.body().string();
  192. if (!TextUtils.isEmpty(resultJson)) {
  193. return JSON.parseObject(resultJson, CheckRefresh.class);
  194. }
  195. return null;
  196. }
  197. @Override
  198. public void onError(Call call, Exception e, int id) {
  199. login();
  200. }
  201. @Override
  202. public void onResponse(CheckRefresh response, int id) {
  203. if (response != null) {
  204. if (response.isUpdate == null || response.isUpdate.equals("0")) {
  205. login();
  206. } else {
  207. DialogUtil.showSingleBtnDialog(getSupportFragmentManager(), "更新", response.updateInfo, getString(R.string.sure), false, new OnSingleDialogClickListener() {
  208. @Override
  209. public void onPositiveClick(View view) {
  210. pd = new ProgressDialog(SplashActivity.this);
  211. pd.setTitle("正在下載");
  212. pd.setCanceledOnTouchOutside(false);
  213. pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  214. downFile("http://iospan.ilove.ren:8092/apk/" + getString(R.string.app_name) + ".apk");
  215. }
  216. });
  217. }
  218. }
  219. }
  220. }
  221. /**
  222. * 下载apk
  223. */
  224. public void downFile(final String url) {
  225. pd.show();
  226. OkHttpUtils.get()
  227. .url(url)
  228. .build()
  229. .execute(new FileCallBack(getExternalFilesDir(null).getPath() + File.separator, UPDATE_SERVERAPK) {
  230. @Override
  231. public void inProgress(float progress, long total, int id) {
  232. super.inProgress(progress, total, id);
  233. pd.setProgress((int) (progress * 100));
  234. }
  235. @Override
  236. public void onError(Call call, Exception e, int id) {
  237. pd.cancel();
  238. }
  239. @Override
  240. public void onResponse(File response, int id) {
  241. pd.cancel();
  242. update();
  243. }
  244. });
  245. }
  246. /**
  247. * 安装应用
  248. */
  249. public void update() {
  250. Intent intent = new Intent(Intent.ACTION_VIEW);
  251. intent.setDataAndType(Uri.fromFile(new File(getExternalFilesDir(null).getPath() + File.separator, UPDATE_SERVERAPK)),
  252. "application/vnd.android.package-archive");
  253. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  254. startActivity(intent);
  255. }
  256. private void login() {
  257. OkHttpUtils.post()
  258. .url(IUrlConstant.URL_LOGIN)
  259. .addHeader("token", PlatformInfoXml.getToken())
  260. .addParams("platformInfo", PlatformInfoXml.getPlatformJsonString())
  261. .addParams("pushToken", PlatformInfoXml.getPushToken())
  262. .addParams("account", UserInfoXml.getUsername())
  263. .addParams("password", UserInfoXml.getPassword())
  264. .build()
  265. .execute(new LoginCallBack());
  266. }
  267. public class LoginCallBack extends Callback<LoginEntity> {
  268. @Override
  269. public LoginEntity parseNetworkResponse(Response response, int id) throws Exception {
  270. String resultJson = response.body().string();
  271. if (!TextUtils.isEmpty(resultJson)) {
  272. return JSON.parseObject(resultJson, LoginEntity.class);
  273. }
  274. return null;
  275. }
  276. @Override
  277. public void onError(Call call, Exception e, int id) {
  278. Util.gotoActivity(SplashActivity.this, LoginActivity.class, true);
  279. }
  280. @Override
  281. public void onResponse(final LoginEntity response, int id) {
  282. if (response != null) {
  283. if (!TextUtils.isEmpty(response.getMsg())) {
  284. ToastUtil.showShortToast(SplashActivity.this, response.getMsg());
  285. }
  286. String isSucceed = response.getIsSucceed();
  287. if (!TextUtils.isEmpty(isSucceed) && "1".equals(isSucceed)) {
  288. PlatformInfoXml.setToken(response.getToken());
  289. UserInfoXml.setUserInfo(response.getUserEnglish());
  290. // 设置页眉和互推开关
  291. UserInfoXml.setIsShowHeadMsg(response.getIsShowHeadNotice());
  292. UserInfoXml.setIsShowHeadMsgNew(response.getIsShowHeadNotice2());
  293. UserInfoXml.setIsShowRecommendUser(response.getIsShowCommendUser());
  294. // appsflyer登录
  295. AppsflyerUtils.login();
  296. CommonRequestUtil.initParamsDict(new CommonRequestUtil.OnCommonListener() {
  297. @Override
  298. public void onSuccess() {
  299. if(isFirstInto){
  300. isFirstInto=false;
  301. if (response.getIsShowUploadImg() != null && response.getIsShowUploadImg().equals("1")) {
  302. Util.gotoActivity(SplashActivity.this, UploadPhotoActivity.class, true);
  303. } else {
  304. Util.gotoActivity(SplashActivity.this, MainActivity.class, true);
  305. }
  306. }
  307. }
  308. @Override
  309. public void onFail() {
  310. if(isFirstInto) {
  311. isFirstInto = false;
  312. if (response.getIsShowUploadImg() != null && response.getIsShowUploadImg().equals("1")) {
  313. Util.gotoActivity(SplashActivity.this, UploadPhotoActivity.class, true);
  314. } else {
  315. Util.gotoActivity(SplashActivity.this, MainActivity.class, true);
  316. }
  317. }
  318. }
  319. });
  320. } else {
  321. if(isFirstInto) {
  322. isFirstInto = false;
  323. Util.gotoActivity(SplashActivity.this, LoginActivity.class, true);
  324. }
  325. }
  326. } else {
  327. if(isFirstInto) {
  328. isFirstInto = false;
  329. Util.gotoActivity(SplashActivity.this, LoginActivity.class, true);
  330. }
  331. }
  332. }
  333. }
  334. protected void activation() {
  335. OkHttpUtils.post()
  336. .url(IUrlConstant.URL_CLENT_ACTIVATION)
  337. .addParams("platformInfo", PlatformInfoXml.getPlatformJsonString())
  338. .build()
  339. .execute(new Callback<BaseModel>() {
  340. @Override
  341. public BaseModel parseNetworkResponse(Response response, int id) throws Exception {
  342. String resultJson = response.body().string();
  343. if (!TextUtils.isEmpty(resultJson)) {
  344. return JSON.parseObject(resultJson, BaseModel.class);
  345. }
  346. return null;
  347. }
  348. @Override
  349. public void onError(Call call, Exception e, int id) {
  350. }
  351. @Override
  352. public void onResponse(BaseModel response, int id) {
  353. if (response != null) {
  354. String isSucceed = response.getIsSucceed();
  355. if (!TextUtils.isEmpty(isSucceed) && "1".equals(isSucceed)) {
  356. UserInfoXml.setIsClient();
  357. // appsflyer激活
  358. AppsflyerUtils.activate();
  359. }
  360. }
  361. }
  362. });
  363. }
  364. private void getPlatformInfo() {
  365. PlatformInfo platformInfo = new PlatformInfo();
  366. platformInfo.setW(String.valueOf(DensityUtil.getScreenWidth(SplashActivity.this)));
  367. platformInfo.setH(String.valueOf(DensityUtil.getScreenHeight(SplashActivity.this)));
  368. platformInfo.setVersion(String.valueOf(VersionInfoUtil.getVersionCode(getApplicationContext())));
  369. platformInfo.setPhonetype(Build.MODEL);
  370. platformInfo.setPid(getAndroidId());
  371. platformInfo.setImsi(getAndroidId());
  372. platformInfo.setProduct(IConfigConstant.PRODUCT_ID);// 产品号
  373. platformInfo.setFid(IConfigConstant.F_ID);// 渠道号
  374. platformInfo.setCountry("Taiwan");
  375. platformInfo.setLanguage("Traditional");
  376. platformInfo.setNetType(getNetType());
  377. platformInfo.setMobileIP(getMobileIP());
  378. platformInfo.setRelease(TimeUtil.getCurrentTime());
  379. platformInfo.setPlatform("2");
  380. platformInfo.setSystemVersion(Build.VERSION.RELEASE);
  381. // 保存platform信息
  382. PlatformInfoXml.setPlatfromInfo(platformInfo);
  383. }
  384. private String getAndroidId() {
  385. return Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
  386. }
  387. private String getNetType() {
  388. String type = "";
  389. ConnectivityManager cm = (ConnectivityManager) SplashActivity.this.getSystemService(Context.CONNECTIVITY_SERVICE);
  390. NetworkInfo info = cm.getActiveNetworkInfo();
  391. if (info == null) {
  392. type = "0";
  393. } else if (info.getType() == ConnectivityManager.TYPE_WIFI) {
  394. type = "2";
  395. } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
  396. String extraInfo = info.getExtraInfo();
  397. if (extraInfo.equals("cmwap")) {
  398. type = "3";
  399. } else if (extraInfo.equals("cmnet")) {
  400. type = "4";
  401. } else if (extraInfo.equals("ctnet")) {
  402. type = "5";
  403. } else if (extraInfo.equals("ctwap")) {
  404. type = "6";
  405. } else if (extraInfo.equals("3gwap")) {
  406. type = "7";
  407. } else if (extraInfo.equals("3gnet")) {
  408. type = "8";
  409. } else if (extraInfo.equals("uniwap")) {
  410. type = "9";
  411. } else if (extraInfo.equals("uninet")) {
  412. type = "10";
  413. }
  414. }
  415. return type;
  416. }
  417. private String getMobileIP() {
  418. try {
  419. for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
  420. NetworkInterface intf = en.nextElement();
  421. for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
  422. InetAddress inetAddress = enumIpAddr.nextElement();
  423. if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
  424. return inetAddress.getHostAddress().toString();
  425. }
  426. }
  427. }
  428. } catch (Exception e) {
  429. e.printStackTrace();
  430. }
  431. return "";
  432. }
  433. // /**
  434. // * 请求定位信息
  435. // */
  436. // private void requestLocation() {
  437. // mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  438. // if (ContextCompat.checkSelfPermission(SplashActivity.this,
  439. // Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED) {
  440. // // 请求android.permission.ACCESS_FINE_LOCATION
  441. // ActivityCompat.requestPermissions(SplashActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_CODE_ACCESS_FINE_LOCATION);
  442. // } else {
  443. // if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {// Network定位
  444. // mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 2000, 5, mLocationListener);
  445. // } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {// GPS定位
  446. // uploadLocation(mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER));
  447. // }
  448. // }
  449. // }
  450. //
  451. // private LocationListener mLocationListener = new LocationListener() {
  452. //
  453. // @Override
  454. // public void onLocationChanged(Location location) {
  455. // uploadLocation(location);
  456. // }
  457. //
  458. // @Override
  459. // public void onStatusChanged(String provider, int status, Bundle extras) {
  460. // }
  461. //
  462. // @Override
  463. // public void onProviderEnabled(String provider) {
  464. // }
  465. //
  466. // @Override
  467. // public void onProviderDisabled(String provider) {
  468. // }
  469. // };
  470. //
  471. // @Override
  472. // public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  473. // if (requestCode == PERMISSION_CODE_ACCESS_FINE_LOCATION) {
  474. // if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {// 申请权限成功
  475. // if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {// Network定位
  476. // if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
  477. // PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
  478. // Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
  479. // // TODO: Consider calling
  480. // // ActivityCompat#requestPermissions
  481. // // here to request the missing permissions, and then overriding
  482. // // public void onRequestPermissionsResult(int requestCode, String[] permissions,
  483. // // int[] grantResults)
  484. // // to handle the case where the user grants the permission. See the documentation
  485. // // for ActivityCompat#requestPermissions for more details.
  486. // return;
  487. // }
  488. // mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 2000, 5, mLocationListener);
  489. // } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {// GPS定位
  490. // uploadLocation(mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER));
  491. // }else{
  492. // init();
  493. // }
  494. // }else{
  495. // init();
  496. // }
  497. // }else{
  498. // init();
  499. // }
  500. // }
  501. //
  502. // /**
  503. // * 上传位置信息
  504. // *
  505. // * @param location 定位成功后的信息
  506. // */
  507. // private void uploadLocation(Location location) {
  508. // if (location != null) {
  509. // String getLatitude = String.valueOf(location.getLatitude());
  510. // String getLongitude = String.valueOf(location.getLongitude());
  511. // String country = UserInfoXml.getCountry();
  512. // Map<String, String> googleAddress = GoogleUtil.getGoogleAddress(getLatitude, getLongitude, "zh-TW", "Taiwan");
  513. // String province = googleAddress.get("province");
  514. // if(!TextUtils.isEmpty(province)){
  515. // if (!province.equals(UserInfoXml.getProvinceName())) {
  516. // UserInfoXml.setProvinceName(province);
  517. // }
  518. // }
  519. // LocationInfo locationInfo = new LocationInfo();
  520. // locationInfo.setAddrStr("");
  521. // locationInfo.setProvince(province);
  522. // locationInfo.setCity("");
  523. // locationInfo.setCityCode("");
  524. // locationInfo.setDistrict("");
  525. // locationInfo.setStreet("");
  526. // locationInfo.setStreetNumber("");
  527. // locationInfo.setLatitude(getLatitude);
  528. // locationInfo.setLongitude(getLongitude);
  529. // Map<String, LocationInfo> map = new HashMap<String, LocationInfo>();
  530. // map.put("locationInfo", locationInfo);
  531. // OkHttpUtils.post()
  532. // .url(IUrlConstant.URL_UPLOAD_LOCATION)
  533. //// .addHeader("token", PlatformInfoXml.getToken())
  534. // .addParams("platformInfo", PlatformInfoXml.getPlatformJsonString())
  535. // .addParams("locationInfo", JSON.toJSONString(map))
  536. // .build()
  537. // .execute(new Callback<BaseModel>() {
  538. // @Override
  539. // public BaseModel parseNetworkResponse(Response response, int id) throws Exception {
  540. // String resultJson = response.body().string();
  541. // if (!TextUtils.isEmpty(resultJson)) {
  542. // return JSON.parseObject(resultJson, BaseModel.class);
  543. // }
  544. // return null;
  545. // }
  546. //
  547. // @Override
  548. // public void onError(Call call, Exception e, int id) {
  549. // init();
  550. //
  551. // }
  552. //
  553. // @Override
  554. // public void onResponse(BaseModel response, int id) {
  555. // if (response != null) {
  556. // String isSucceed = response.getIsSucceed();
  557. // if (!TextUtils.isEmpty(isSucceed) && "1".equals(isSucceed)) {// 上传成功
  558. // LogUtil.i(LogUtil.TAG_ZL, "上传位置信息成功");
  559. // init();
  560. // }
  561. // }
  562. // }
  563. // });
  564. // }else{
  565. // new Handler().postDelayed(new Runnable() {
  566. // @Override
  567. // public void run() {
  568. // init();
  569. // }
  570. // },5000);
  571. // }
  572. // }
  573. }