From a45036d4003974f8e78eb819a932895291d677d6 Mon Sep 17 00:00:00 2001 From: 陈奇 <1650699704@qq.com> Date: Tue, 27 Nov 2018 17:14:41 +0800 Subject: [PATCH] [*] --- app/src/main/java/com/moral/yunfushao/MainApp.java | 70 ++++++++++++++++++++++++++++++++--- 1 files changed, 64 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/moral/yunfushao/MainApp.java b/app/src/main/java/com/moral/yunfushao/MainApp.java index a1c153d..dcfb44c 100644 --- a/app/src/main/java/com/moral/yunfushao/MainApp.java +++ b/app/src/main/java/com/moral/yunfushao/MainApp.java @@ -1,20 +1,24 @@ package com.moral.yunfushao; -import android.app.Application; import android.bluetooth.BluetoothGattService; +import com.baidu.location.BDLocation; +import com.baidu.location.BDLocationListener; +import com.baidu.location.LocationClient; +import com.baidu.location.LocationClientOption; import com.baidu.mapapi.SDKInitializer; import com.clj.fastble.BleManager; import com.lzy.okgo.OkGo; import com.lzy.okgo.cookie.store.PersistentCookieStore; import com.moral.andbrickslib.utils.log.XLog; +import com.moral.yunfushao.common.AppConfig; import com.moral.yunfushao.utils.SharedPreferencesUtil; /** * Created by haijiang on 2017/5/2. */ -public class MainApp extends Application { +public class MainApp extends SampleApplication { public static MainApp theApp; //������id public static String userId; @@ -24,6 +28,15 @@ */ public BleManager bleManager; public BluetoothGattService usrService; + + /** + * ������������ + */ + LocationClient mLocClient; + public MyLocationListenner myListener; + public static double mLat, mLon; + public static String address; + @Override public void onCreate() { super.onCreate(); @@ -33,12 +46,57 @@ OkGo.init(this); OkGo.getInstance().setCookieStore(new PersistentCookieStore()); - if(sharedPreferencesUtil == null){ - sharedPreferencesUtil = new SharedPreferencesUtil(this); + if (sharedPreferencesUtil == null) { + sharedPreferencesUtil = SharedPreferencesUtil.getUtil(this); } -// userId = sharedPreferencesUtil.getUserid(); - userId = "1"; + userId = sharedPreferencesUtil.getUserid(); + + + if (MainApp.theApp.sharedPreferencesUtil.getVoiceType() == 0) { + AppConfig.voideUrl1 = "http://yfsapi.7drlb.com/video/boy/music.mp3"; + AppConfig.voideUrl2 = "http://yfsapi.7drlb.com/video/boy/music1.mp3"; + AppConfig.voideUrl3 = "http://yfsapi.7drlb.com/video/boy/music2.mp3"; + } else if (MainApp.theApp.sharedPreferencesUtil.getVoiceType() == 1) { + AppConfig.voideUrl1 = "http://yfsapi.7drlb.com/video/girl/music.mp3"; + AppConfig.voideUrl2 = "http://yfsapi.7drlb.com/video/girl/music1.mp3"; + AppConfig.voideUrl3 = "http://yfsapi.7drlb.com/video/girl/music2.mp3"; + } else if (MainApp.theApp.sharedPreferencesUtil.getVoiceType() == 2) { + AppConfig.voideUrl1 = null; + AppConfig.voideUrl2 = null; + AppConfig.voideUrl3 = null; + } bleManager = new BleManager(this); + + myListener = new MyLocationListenner(); + // ��������������� + mLocClient = new LocationClient(this); + mLocClient.registerLocationListener(myListener); + LocationClientOption option = new LocationClientOption(); + option.setOpenGps(true); // ������gps + option.setCoorType("bd09ll"); // ������������������ + option.setIsNeedAddress(true); + option.setScanSpan(1000 * 60); + mLocClient.setLocOption(option); + mLocClient.start(); + } + + + /** + * ������SDK������������ + */ + public class MyLocationListenner implements BDLocationListener { + + @Override + public void onReceiveLocation(BDLocation location) { + // map view ��������������������������������������� + if (location == null) { + return; + } + mLat = location.getLatitude(); + mLon = location.getLongitude(); + address = location.getAddrStr(); + XLog.d(mLat + "|" + mLon + "|" + address); + } } } -- Gitblit v1.8.0