Commit 5e806fc8 authored by mengcuiguang2's avatar mengcuiguang2

解决冲突

parents 8d8b7ed2 e937e0fc
...@@ -134,7 +134,7 @@ android { ...@@ -134,7 +134,7 @@ android {
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include:['*.jar'], dir:'libs')
testImplementation rootProject.ext.support["junit"] testImplementation rootProject.ext.support["junit"]
//下拉刷新 //下拉刷新
...@@ -162,8 +162,9 @@ dependencies { ...@@ -162,8 +162,9 @@ dependencies {
// 应用管理中心分包 // 应用管理中心分包
implementation(name: 'humesdk-1.0.0', ext: 'aar') implementation(name: 'humesdk-1.0.0', ext: 'aar')
// umeng // umeng
implementation(name: 'umeng-asms-armeabi-v1.2.2', ext: 'aar') implementation 'com.umeng.umsdk:common:9.4.0'// 必选
implementation(name: 'umeng-apm-armeabi-v1.2.0', ext: 'aar') implementation 'com.umeng.umsdk:asms:1.2.3'// 必选
implementation 'com.umeng.umsdk:apm:1.4.0'
// 穿山甲 GroMore // 穿山甲 GroMore
// mediation_ad_sdk // mediation_ad_sdk
implementation(name: 'mediation_ad_sdk_2.8.1.0', ext: 'aar') implementation(name: 'mediation_ad_sdk_2.8.1.0', ext: 'aar')
...@@ -178,7 +179,6 @@ dependencies { ...@@ -178,7 +179,6 @@ dependencies {
//RxPay //RxPay
implementation 'com.cuieney:rxpay-api:2.2.3' implementation 'com.cuieney:rxpay-api:2.2.3'
kapt 'com.cuieney:rxpay-compiler:2.1.1' kapt 'com.cuieney:rxpay-compiler:2.1.1'
implementation 'com.romandanylyk:pageindicatorview:1.0.3'
implementation(name: 'BaiduLBS_AndroidSDK_Lib', ext: 'aar') implementation(name: 'BaiduLBS_AndroidSDK_Lib', ext: 'aar')
......
...@@ -410,6 +410,35 @@ ...@@ -410,6 +410,35 @@
# ======================= 穿山甲 GroMore END ================ # ======================= 穿山甲 GroMore END ================
# ===================== RxPay START ================
-keep class com.alipay.android.app.IAlixPay{*;}
-keep class com.alipay.android.app.IAlixPay$Stub{*;}
-keep class com.alipay.android.app.IRemoteServiceCallback{*;}
-keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
-keep class com.alipay.sdk.app.PayTask{ public *;}
-keep class com.alipay.sdk.app.AuthTask{ public *;}
-keep class com.alipay.sdk.app.H5PayCallback {
<fields>;
<methods>;
}
-keep class com.alipay.android.phone.mrpc.core.** { *; }
-keep class com.alipay.apmobilesecuritysdk.** { *; }
-keep class com.alipay.mobile.framework.service.annotation.** { *; }
-keep class com.alipay.mobilesecuritysdk.face.** { *; }
-keep class com.alipay.tscenter.biz.rpc.** { *; }
-keep class org.json.alipay.** { *; }
-keep class com.alipay.tscenter.** { *; }
-keep class com.ta.utdid2.** { *;}
-keep class com.ut.device.** { *;}
-dontwarn com.alipay.**
# ======================= RxPay END ================
# ===================== 百度地图 START ================ # ===================== 百度地图 START ================
-keep class com.baidu.** {*;} -keep class com.baidu.** {*;}
-keep class vi.com.** {*;} -keep class vi.com.** {*;}
......
...@@ -22,15 +22,14 @@ ...@@ -22,15 +22,14 @@
<!-- 获取手机状态信息 --> <!-- 获取手机状态信息 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application <application
android:name="com.mints.street.AppApplication" android:name="com.mints.street.AppApplication"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher_main"
android:label="@string/app_name" android:label="@string/app_name"
android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
...@@ -69,20 +68,25 @@ ...@@ -69,20 +68,25 @@
android:process=":remote"/> android:process=":remote"/>
<activity android:name="com.mints.street.splash.SplashActivity" <activity android:name="com.mints.street.splash.SplashActivity"
android:excludeFromRecents="true"
android:theme="@style/NormalSplash"> android:theme="@style/NormalSplash">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="um.60e80209a6f90557b7b19aa7" />
</intent-filter>
</activity> </activity>
<activity android:name="com.mints.street.login.LoginActivity"> <activity android:name="com.mints.street.login.LoginActivity">
</activity> </activity>
<activity android:name="com.mints.street.main.MainActivity" <activity android:name="com.mints.street.main.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:theme="@style/AppTheme.NoneTranslucent"> android:theme="@style/AppTheme.NoneTranslucent">
...@@ -91,6 +95,8 @@ ...@@ -91,6 +95,8 @@
<activity android:name=".main.my.AboutusActivity"/> <activity android:name=".main.my.AboutusActivity"/>
<activity android:name=".main.my.PermissionsActivity"/> <activity android:name=".main.my.PermissionsActivity"/>
<activity android:name=".main.my.OpenvipActivity"/> <activity android:name=".main.my.OpenvipActivity"/>
<activity android:name=".main.home.HistoricalimageActivity"/>
<!-- ShareSDK start --> <!-- ShareSDK start -->
<activity <activity
android:name="com.mob.tools.MobUIShell" android:name="com.mob.tools.MobUIShell"
...@@ -174,6 +180,7 @@ ...@@ -174,6 +180,7 @@
android:exported="false" android:exported="false"
android:screenOrientation="behind" android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" /> android:windowSoftInputMode="adjustResize|stateHidden" />
<activity android:name=".main.vr.PanoramicActivity"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.mints.street package com.mints.street
import android.content.Context
import android.os.StrictMode import android.os.StrictMode
import android.os.StrictMode.VmPolicy import android.os.StrictMode.VmPolicy
import android.util.Log import android.util.Log
import android.widget.Toast
import com.baidu.lbsapi.BMapManager
import com.baidu.mapapi.CoordType import com.baidu.mapapi.CoordType
import com.baidu.mapapi.SDKInitializer import com.baidu.mapapi.SDKInitializer
import com.cuieney.rxpay_annotation.WX import com.cuieney.rxpay_annotation.WX
import com.fry.base.base.BaseApp import com.fry.base.base.BaseApp
import com.mints.street.main.vr.PanoramicActivity
import com.mints.street.manager.CsjGroMoreManager import com.mints.street.manager.CsjGroMoreManager
import com.mints.street.manager.UmengManager import com.mints.street.manager.UmengManager
import me.goldze.mvvmhabit.utils.KLog
import java.util.concurrent.TimeoutException import java.util.concurrent.TimeoutException
/** /**
...@@ -28,14 +33,14 @@ class AppApplication : BaseApp() { ...@@ -28,14 +33,14 @@ class AppApplication : BaseApp() {
builder.detectFileUriExposure() builder.detectFileUriExposure()
// 解决java.util.concurrent.TimeoutException https://www.jianshu.com/p/844ef9c84f15 // 解决java.util.concurrent.TimeoutException https://www.jianshu.com/p/844ef9c84f15
val defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler() // val defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { t, e -> // Thread.setDefaultUncaughtExceptionHandler { t, e ->
if (t.name == "FinalizerWatchdogDaemon" && e is TimeoutException) { // if (t.name == "FinalizerWatchdogDaemon" && e is TimeoutException) {
Log.e("ignore", "ignore") // Log.e("ignore", "ignore")
} else { // } else {
defaultUncaughtExceptionHandler?.uncaughtException(t, e) // defaultUncaughtExceptionHandler?.uncaughtException(t, e)
} // }
} // }
} }
/* /*
...@@ -54,10 +59,24 @@ class AppApplication : BaseApp() { ...@@ -54,10 +59,24 @@ class AppApplication : BaseApp() {
//自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型. //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型.
//包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。 //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。
SDKInitializer.setCoordType(CoordType.BD09LL) SDKInitializer.setCoordType(CoordType.BD09LL)
//百度全景
initEngineManager(this)
}
/**
* 初始化百度全景
*/
private fun initEngineManager(context: Context) {
if (mBMapManager == null) {
mBMapManager = BMapManager(context)
}
if (mBMapManager?.init(PanoramicActivity.MyGeneralListener())==false) {
KLog.e("BMapManager","BMapManager 初始化错误!")
}
} }
companion object { companion object {
var mContext: AppApplication? = null var mContext: AppApplication? = null
var mBMapManager: BMapManager? = null
fun getContext(): AppApplication? { fun getContext(): AppApplication? {
return mContext return mContext
......
...@@ -8,7 +8,9 @@ import com.fry.base.adapter.BindingViewHolder ...@@ -8,7 +8,9 @@ import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin import com.fry.base.binding.setMargin
import com.mints.street.R import com.mints.street.R
import com.mints.street.databinding.ItemGridMapAdapterBinding import com.mints.street.databinding.ItemGridMapAdapterBinding
import com.mints.street.main.vr.PanoramicActivity
import me.goldze.mvvmhabit.utils.AppUtils import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.RxUtils
/** /**
* Created by 冯瑞雨 on 2021/7/9. * Created by 冯瑞雨 on 2021/7/9.
...@@ -18,12 +20,17 @@ class GridMapAdapter(val context: Context,val list :List<String>):AbstractVLayo ...@@ -18,12 +20,17 @@ class GridMapAdapter(val context: Context,val list :List<String>):AbstractVLayo
holder: BindingViewHolder<ItemGridMapAdapterBinding>, holder: BindingViewHolder<ItemGridMapAdapterBinding>,
position: Int position: Int
) { ) {
var a = holder.binding.bg.layoutParams var a = holder.binding.bg.layoutParams
if(position%2 == 0){ if(position%2 == 0){
holder.binding.bg.setMargin(AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),0,null,null,null) holder.binding.bg.setMargin(AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),0,null,null,null)
}else{ }else{
holder.binding.bg.setMargin(0,AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),0,null,null,null) holder.binding.bg.setMargin(0,AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),0,null,null,null)
} }
RxUtils.onMultiClick(holder.binding.bg){
PanoramicActivity.starPanoramicActivity(context,""
,PanoramicActivity.WGS84,lat =39.906283536127169,lon = 116.39129554889048 )
}
} }
override fun getItemCount() = list.size override fun getItemCount() = list.size
......
...@@ -2,7 +2,7 @@ package com.mints.street.api ...@@ -2,7 +2,7 @@ package com.mints.street.api
import com.mints.street.bean.AwardBean import com.mints.street.bean.AwardBean
import com.mints.street.bean.UserBean import com.mints.street.bean.UserBean
import com.mints.street.netwrok.HttpManager import com.mints.street.netwrok.common.HttpManager
import io.reactivex.Observable import io.reactivex.Observable
import me.goldze.mvvmhabit.http.BaseResponse import me.goldze.mvvmhabit.http.BaseResponse
import retrofit2.Response import retrofit2.Response
......
package com.mints.street.login package com.mints.street.login
import android.app.Application import android.app.Application
import com.fry.base.basenetwork.HttpSubscribeImpl
import com.mints.street.bean.AwardBean import com.mints.street.bean.AwardBean
import com.mints.street.model.ApiModel import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import me.goldze.mvvmhabit.base.BaseViewModel import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse import me.goldze.mvvmhabit.http.BaseResponse
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
...@@ -26,7 +26,9 @@ class LoginViewModel(application:Application):BaseViewModel(application) { ...@@ -26,7 +26,9 @@ class LoginViewModel(application:Application):BaseViewModel(application) {
override fun onBusinessSuccess(response: BaseResponse<AwardBean>) { override fun onBusinessSuccess(response: BaseResponse<AwardBean>) {
KLog.e("sfdsdf",response.result.toString()) KLog.e("sfdsdf",response.result.toString())
} }
override fun onBusinessFail(response: BaseResponse<AwardBean>?) {
}
}) })
} }
} }
\ No newline at end of file
...@@ -20,7 +20,7 @@ import com.mints.street.main.my.MyFragment ...@@ -20,7 +20,7 @@ import com.mints.street.main.my.MyFragment
import com.mints.street.main.vr.VRFragment import com.mints.street.main.vr.VRFragment
import com.mints.street.manager.UmengManager import com.mints.street.manager.UmengManager
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.layout_popupwindow.* import com.umeng.analytics.MobclickAgent
import me.goldze.mvvmhabit.base.AppManager import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.ToastUtils import me.goldze.mvvmhabit.utils.ToastUtils
...@@ -70,6 +70,20 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() { ...@@ -70,6 +70,20 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
} }
override fun onResume() {
super.onResume()
// 友盟
MobclickAgent.onResume(this)
}
override fun onPause() {
super.onPause()
// 友盟
MobclickAgent.onPause(this)
}
var oldTime: Long = 0 var oldTime: Long = 0
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
when (keyCode) { when (keyCode) {
......
package com.mints.street.main.home
import android.os.Bundle
import android.view.View
import com.coorchice.library.utils.LogUtils
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityHistoricalImageBinding
import kotlinx.android.synthetic.main.activity_historical_image.*
import me.goldze.mvvmhabit.utils.ToastUtils
/**
* 描述:历史影像
* 作者:孟崔广
* 时间:2021/7/12 17:51
*/
class HistoricalimageActivity :BaseActivity<ActivityHistoricalImageBinding, HistoricalimageModel>(), View.OnClickListener {
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_historical_image
override fun initData() {
super.initData()
initView()
}
private fun initView() {
}
override fun onClick(v: View?) {
}
}
package com.mints.street.main.home
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
class HistoricalimageModel(application: Application): BaseViewModel(application) {
}
\ No newline at end of file
package com.mints.street.main.home package com.mints.street.main.home
import android.content.Context.SENSOR_SERVICE
import android.graphics.Color import android.graphics.Color
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import com.baidu.location.BDLocation
import com.baidu.location.BDLocationListener
import com.baidu.location.LocationClient
import com.baidu.location.LocationClientOption
import com.baidu.mapapi.map.* import com.baidu.mapapi.map.*
import com.baidu.mapapi.model.LatLng import com.baidu.mapapi.model.LatLng
import com.baidu.mapapi.search.core.RecommendStopInfo import com.baidu.mapapi.search.core.RecommendStopInfo
import com.baidu.mapapi.search.recommendstop.OnGetRecommendStopResultListener
import com.baidu.mapapi.search.recommendstop.RecommendStopResult
import com.baidu.mapapi.search.recommendstop.RecommendStopSearch import com.baidu.mapapi.search.recommendstop.RecommendStopSearch
import com.baidu.mapapi.search.recommendstop.RecommendStopSearchOption import com.baidu.mapapi.search.recommendstop.RecommendStopSearchOption
import com.fry.base.base.BaseFragment import com.fry.base.base.BaseFragment
import com.mints.street.BR import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.databinding.FragmentHomeBinding import com.mints.street.databinding.FragmentHomeBinding
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.RxUtils import me.goldze.mvvmhabit.utils.RxUtils
...@@ -24,7 +31,7 @@ import me.goldze.mvvmhabit.utils.RxUtils ...@@ -24,7 +31,7 @@ import me.goldze.mvvmhabit.utils.RxUtils
* Created by 冯瑞雨 on 2021/7/2. * Created by 冯瑞雨 on 2021/7/2.
* 首页页面 * 首页页面
*/ */
class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorEventListener {
private var mBaiduMap: BaiduMap? = null private var mBaiduMap: BaiduMap? = null
...@@ -32,28 +39,54 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){ ...@@ -32,28 +39,54 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){
private var mRecommendStopSearch: RecommendStopSearch? = null private var mRecommendStopSearch: RecommendStopSearch? = null
// 定位相关
private var mLocClient: LocationClient? = null
override fun initContentView(inflater: LayoutInflater?, // 定位图层显示方式
container: ViewGroup?, private var mCurrentMode: MyLocationConfiguration.LocationMode? = null
savedInstanceState: Bundle?)= R.layout.fragment_home private var mSensorManager: SensorManager? = null
private var lastX = 0.0
//// 此处设置开发者获取到的方向信息,顺时针0-360
private var mCurrentDirection = 0
//纬度
private var mCurrentLat = 0.0
//经度
private var mCurrentLon = 0.00
//设置定位数据的精度信息,单位:米
private var mCurrentAccracy = 0f
override fun initVariableId()=BR.viewModel // 是否首次定位
private var isFirstLoc = true
private var myLocationData: MyLocationData? = null
override fun initData() {
super.initData()
initMap()
override fun initContentView(
inflater: LayoutInflater?,
container: ViewGroup?,
savedInstanceState: Bundle?
) = R.layout.fragment_home
override fun initVariableId() = BR.viewModel
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
initMap()
}
override fun initData() {
super.initData()
viewModel.add() viewModel.add()
} }
private fun initMap(){
private fun initMap() {
mBaiduMap = binding.bmapView.map mBaiduMap = binding.bmapView.map
mBaiduMap?.mapType = BaiduMap.MAP_TYPE_SATELLITE mBaiduMap?.mapType = BaiduMap.MAP_TYPE_SATELLITE
binding.bmapView.showZoomControls(false)//设置是否显示缩放控件
//设置是否显示缩放控件
binding.bmapView.showZoomControls(false)
// 构建地图状态 // 构建地图状态
val builder = MapStatus.Builder() val builder = MapStatus.Builder()
// 默认 天安门 // 默认 天安门
...@@ -62,27 +95,31 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){ ...@@ -62,27 +95,31 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){
val zoom = 11.0f val zoom = 11.0f
builder.target(center).zoom(zoom) builder.target(center).zoom(zoom)
val mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(builder.build()) val mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(builder.build())
// 设置地图状态 // 设置地图状态
mBaiduMap?.setMapStatus(mapStatusUpdate) mBaiduMap?.setMapStatus(mapStatusUpdate)
mBaiduMap?.setOnMapStatusChangeListener(object :BaiduMap.OnMapStatusChangeListener{ mBaiduMap?.setOnMapStatusChangeListener(object : BaiduMap.OnMapStatusChangeListener {
override fun onMapStatusChangeStart(status: MapStatus?) { override fun onMapStatusChangeStart(status: MapStatus?) {
KLog.a("百度map","移动开始") KLog.a("百度map", "移动开始")
} }
override fun onMapStatusChangeStart(status: MapStatus?, reason: Int) { override fun onMapStatusChangeStart(status: MapStatus?, reason: Int) {
KLog.a("百度map","移动开始,两个参数") KLog.a("百度map", "移动开始,两个参数")
} }
override fun onMapStatusChange(status: MapStatus?) { override fun onMapStatusChange(status: MapStatus?) {
KLog.a("百度map","移动改变") KLog.a("百度map", "移动改变")
} }
override fun onMapStatusChangeFinish(status: MapStatus?) { override fun onMapStatusChangeFinish(status: MapStatus?) {
KLog.a("百度map","移动结束") KLog.a("百度map", "移动结束")
val center = status?.target mRecommendStopSearch?.requestRecommendStop(
mRecommendStopSearch?.requestRecommendStop(RecommendStopSearchOption().location(center)) RecommendStopSearchOption().location(
center
)
)
} }
}) })
...@@ -98,13 +135,55 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){ ...@@ -98,13 +135,55 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){
mBaiduMap?.setMapStatus(MapStatusUpdateFactory.zoomOut()) mBaiduMap?.setMapStatus(MapStatusUpdateFactory.zoomOut())
} }
mRecommendStopSearch = RecommendStopSearch.newInstance() mRecommendStopSearch = RecommendStopSearch.newInstance()
mRecommendStopSearch?.setOnGetRecommendStopResultListener(object :OnGetRecommendStopResultListener{ mRecommendStopSearch?.setOnGetRecommendStopResultListener { result ->
override fun onGetRecommendStopResult(result: RecommendStopResult?) { if (result != null) {
if (result != null) { addMarkerToMap(result.recommendStopInfoList)
addMarkerToMap(result.recommendStopInfoList)
}
} }
}) }
//重新回到定位点
RxUtils.onMultiClick(binding.imageLocationIcon){
// 默认 天安门
val center = LatLng(mCurrentLat, mCurrentLon)
// 默认 11级
val zoom = 17.0f
builder.target(center).zoom(zoom)
val mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(builder.build())
// 设置地图状态
mBaiduMap?.setMapStatus(mapStatusUpdate)
}
//定位初始化
initLocation()
}
/**
* 定位初始化
*/
private fun initLocation() {
// 获取传感器管理服务
mSensorManager = AppManager.getAppManager().currentActivity
.getSystemService(SENSOR_SERVICE) as SensorManager
mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL
// 为系统的方向传感器注册监听器
mSensorManager?.registerListener(
this,
mSensorManager?.getDefaultSensor(Sensor.TYPE_ORIENTATION),
SensorManager.SENSOR_DELAY_UI
)
// 开启定位图层
mBaiduMap?.isMyLocationEnabled = true
// 定位初始化
mLocClient = LocationClient(context)
mLocClient?.registerLocationListener(MyLocationListener())
val option = LocationClientOption()
// 打开gps
option.isOpenGps = true
// 设置坐标类型
option.setCoorType("bd09ll")
option.setScanSpan(1000)
mLocClient?.locOption = option
mLocClient?.start()
} }
...@@ -120,33 +199,90 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){ ...@@ -120,33 +199,90 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>(){
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
// 取消注册传感器监听
mSensorManager?.unregisterListener(this)
// 退出时销毁定位
mLocClient?.stop()
// 关闭定位图层
mBaiduMap?.isMyLocationEnabled = false
mRecommendStopSearch?.destroy() mRecommendStopSearch?.destroy()
binding.bmapView.onDestroy() binding.bmapView.onDestroy()
} }
/** /**
* 推荐上车点添加到地图上 * 推荐上车点添加到地图上
* @param stops 推荐上车点列表 * @param stops 推荐上车点列表
*/ */
private fun addMarkerToMap(stops: List<RecommendStopInfo?>?) { private fun addMarkerToMap(stops: List<RecommendStopInfo?>?) {
stops?.apply { stops?.apply {
mBaiduMap?.clear() mBaiduMap?.clear()
for (stop in this) { for (stop in this) {
stop?.apply { stop?.apply {
val textView = TextView(context) val textView = TextView(context)
textView.text = stop.name textView.text = stop.name
textView.setBackgroundColor(Color.WHITE) textView.setBackgroundColor(Color.WHITE)
val infoWindow = InfoWindow( val infoWindow = InfoWindow(
textView, textView,
stop.location, -47 stop.location, -47
) )
val markerOptions = MarkerOptions() val markerOptions = MarkerOptions()
markerOptions.icon(mBitmapDescriptor).position(stop.location).scaleX(0.5f).scaleY(0.5f) markerOptions.icon(mBitmapDescriptor).position(stop.location).scaleX(0.5f)
.infoWindow(infoWindow) .scaleY(0.5f)
mBaiduMap!!.addOverlay(markerOptions) .infoWindow(infoWindow)
} mBaiduMap!!.addOverlay(markerOptions)
}
}
} }
}
}
/**
* 定位SDK监听函数
*/
inner class MyLocationListener : BDLocationListener {
override fun onReceiveLocation(location: BDLocation) {
// MapView 销毁后不在处理新接收的位置
mBaiduMap?.apply {
mCurrentLat = location.latitude
mCurrentLon = location.longitude
mCurrentAccracy = location.radius
myLocationData = MyLocationData.Builder()
.accuracy(location.radius) // 设置定位数据的精度信息,单位:米
.direction(mCurrentDirection.toFloat()) // 此处设置开发者获取到的方向信息,顺时针0-360
.latitude(location.latitude)
.longitude(location.longitude)
.build()
this.setMyLocationData(myLocationData)
if (isFirstLoc) {
isFirstLoc = false
val ll = LatLng(location.latitude, location.longitude)
val builder = MapStatus.Builder()
builder.target(ll).zoom(18.0f)
this.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()))
}
}
}
}
override fun onSensorChanged(sensorEvent: SensorEvent?) {
val x: Double =
sensorEvent?.values?.get(SensorManager.DATA_X)?.toDouble() ?: 0.0
if (kotlin.math.abs(x - lastX) > 1.0) {
mCurrentDirection = x.toInt()
myLocationData = MyLocationData.Builder()
.accuracy(mCurrentAccracy) // 设置定位数据的精度信息,单位:米
.direction(mCurrentDirection.toFloat()) // 此处设置开发者获取到的方向信息,顺时针0-360
.latitude(mCurrentLat)
.longitude(mCurrentLon)
.build()
mBaiduMap?.setMyLocationData(myLocationData)
}
lastX = x
}
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
} }
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ import com.mints.street.BR ...@@ -16,6 +16,7 @@ import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.databinding.FragmentMyBinding import com.mints.street.databinding.FragmentMyBinding
import com.mints.street.login.LoginActivity import com.mints.street.login.LoginActivity
import com.mints.street.main.home.HistoricalimageActivity
import kotlinx.android.synthetic.main.fragment_my.* import kotlinx.android.synthetic.main.fragment_my.*
...@@ -71,7 +72,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL ...@@ -71,7 +72,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
override fun onClick(v: View?) { override fun onClick(v: View?) {
when (v?.id) { when (v?.id) {
R.id.ly_aboutus -> { R.id.ly_aboutus -> {
startActivity(AboutusActivity::class.java) // startActivity(AboutusActivity::class.java)
startActivity(HistoricalimageActivity::class.java)
} }
R.id.ly_moresettings -> { R.id.ly_moresettings -> {
startActivity(MoresettingsActivity::class.java) startActivity(MoresettingsActivity::class.java)
......
package com.mints.street.main.vr
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.Window
import com.baidu.lbsapi.BMapManager
import com.baidu.lbsapi.MKGeneralListener
import com.baidu.lbsapi.panoramaview.PanoramaView
import com.baidu.lbsapi.panoramaview.PanoramaViewListener
import com.fry.base.base.BaseActivity
import com.mints.street.AppApplication
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityPanoramicBinding
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
/**
* Created by 冯瑞雨 on 2021/7/12.
* 全景页面
*/
class PanoramicActivity : BaseActivity<ActivityPanoramicBinding, PanoramicViewModel>() {
companion object {
const val PID = 0 // PID方式
const val GEO = 1 // 经纬度方式
const val MERCATOR = 2 // 墨卡托方式
const val UID_STREET = 3 // UID方式展示外景
const val UID_INTERIOR = 4 // UID方式展示内景
const val UID_STREET_CUSTOMALBUM = 5 // UID方式展示外景(使用自定义相册)
const val MARKER = 6 // 标注
const val OTHER = 7 // 其他测试
const val COORDINATE_CONVERTER = 8 // 坐标转换测试
const val WGS84 = 9 // 大地坐标系方式
const val GCJ02 = 10 // 国测局加密方式
fun starPanoramicActivity(
context: Context,
name: String,
type: Int,
pid: String? = null,
lon: Double? = null,
lat: Double? = null
) {
val intent = Intent(context,PanoramicActivity::class.java)
intent.putExtra("name",name)
intent.putExtra("type",type)
intent.putExtra("pid",pid)
intent.putExtra("lon",lon)
intent.putExtra("lat",lat)
context.startActivity(intent)
}
}
internal class MyGeneralListener : MKGeneralListener {
override fun onGetPermissionState(iError: Int) {
// 非零值表示key验证未通过
if (iError != 0) {
// 授权Key错误:
KLog.e(
"BMapManager",
"请在AndoridManifest.xml中输入正确的授权Key,并检查您的网络连接是否正常!error: $iError"
)
} else {
KLog.a("BMapManager", "key认证成功")
}
}
}
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_panoramic
override fun initVariableId() = BR.viewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//requestWindowFeature(Window.FEATURE_NO_TITLE)
initBMapManager()
}
override fun initData() {
super.initData()
val intent = intent
if (intent != null) {
testPanoByType(
name = intent.getStringExtra("name") ?: "全景",
type = intent.getIntExtra("type", -1),
pid = intent.getStringExtra("pid"),
lon = intent.getDoubleExtra("lon", 0.0),
lat = intent.getDoubleExtra("lat", 0.0)
)
}
}
private fun initBMapManager() {
if (AppApplication.mBMapManager == null) {
AppApplication.mBMapManager = BMapManager(AppApplication.mContext)
AppApplication.mBMapManager?.init(MyGeneralListener())
}
}
/**
* 加载全景
* @param name 标题名称 必填
* @param type type类型 必选
* @param pid 百度pid 非必填
* @param lon 纬度 非必填
* @param lat 经度 非必填
*/
private fun testPanoByType(
name: String,
type: Int,
pid: String? = null,
lon: Double? = null,
lat: Double? = null
) {
KLog.e("PanoramicActivity", "测试--------------- $name $type $pid $lon $lat")
if (type == -1) {
KLog.e("PanoramicActivity", "错误类型")
return
}
binding.panorama.setShowTopoLink(true)
// 测试回调函数,需要注意的是回调函数要在setPanorama()之前调用,否则回调函数可能执行异常
binding.panorama.setPanoramaViewListener(object : PanoramaViewListener {
override fun onDescriptionLoadEnd(p0: String?) {
KLog.i("PanoramicActivity", "onLoadPanoramaStart...")
}
override fun onLoadPanoramaBegin() {
KLog.i("PanoramicActivity", "onLoadPanoramaBegin...")
}
override fun onLoadPanoramaEnd(p0: String?) {
KLog.i("PanoramicActivity", "onLoadPanoramaEnd...")
}
override fun onLoadPanoramaError(p0: String?) {
}
override fun onMessage(p0: String?, p1: Int) {
}
override fun onCustomMarkerClick(p0: String?) {
}
override fun onMoveStart() {
}
override fun onMoveEnd() {
}
})
binding.ctbTitle.setTitle(name)
when (type) {
//通过百度全景ID(PID)获取全景
PID -> {
if (pid == null) {
return
}
binding.panorama.setPanoramaImageLevel(
PanoramaView.ImageDefinition.ImageDefinitionHigh
)
binding.panorama.setPanorama(pid)
}
//通过大地坐标系(WGS84)获取全景
WGS84 -> {
if (lon == null || lat == null || lon <= 0 || lat <= 0) {
return
}
binding.panorama.setPanoramaImageLevel(
PanoramaView.ImageDefinition.ImageDefinitionMiddle
)
binding.panorama.setPanorama(lon, lat, PanoramaView.COORDTYPE_WGS84)
}
//通过国测局加密坐标(GCJ02)获取全景
GCJ02 -> {
if (lon == null || lat == null || lon <= 0 || lat <= 0) {
return
}
binding.panorama.setPanoramaImageLevel(
PanoramaView.ImageDefinition.ImageDefinitionMiddle
)
binding.panorama.setPanorama(lon, lat, PanoramaView.COORDTYPE_GCJ02)
}
//通过百度经纬度坐标(BD09LL)获取全景
GEO -> {
if (lon == null || lat == null || lon <= 0 || lat <= 0) {
return
}
binding.panorama.setPanoramaImageLevel(
PanoramaView.ImageDefinition.ImageDefinitionMiddle
)
binding.panorama.setPanorama(lon, lat, PanoramaView.COORDTYPE_BD09LL)
}
//通过百度墨卡托坐标(BD09MC)获取全景
MERCATOR -> {
if (lon == null || lat == null || lon <= 0 || lat <= 0) {
return
}
binding.panorama.setPanoramaImageLevel(
PanoramaView.ImageDefinition.ImageDefinitionMiddle
)
binding.panorama.setPanorama(
lon, lat,
PanoramaView.COORDTYPE_BD09MC
)
}
}
}
}
\ No newline at end of file
package com.mints.street.main.vr
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
/**
* Created by 冯瑞雨 on 2021/7/12.
*/
class PanoramicViewModel(application: Application):BaseViewModel(application) {
}
\ No newline at end of file
...@@ -3,7 +3,7 @@ package com.mints.street.model ...@@ -3,7 +3,7 @@ package com.mints.street.model
import com.mints.street.api.MainApi import com.mints.street.api.MainApi
import com.mints.street.bean.AwardBean import com.mints.street.bean.AwardBean
import com.mints.street.bean.UserBean import com.mints.street.bean.UserBean
import com.mints.street.netwrok.HttpManager import com.mints.street.netwrok.common.HttpManager
import com.trello.rxlifecycle2.LifecycleProvider import com.trello.rxlifecycle2.LifecycleProvider
import io.reactivex.Observable import io.reactivex.Observable
import me.goldze.mvvmhabit.http.BaseResponse import me.goldze.mvvmhabit.http.BaseResponse
......
package com.fry.base.basenetwork; package com.mints.street.netwrok.base;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
package com.fry.base.basenetwork package com.mints.street.netwrok.base
import me.goldze.mvvmhabit._enum.ViewStatus import me.goldze.mvvmhabit._enum.ViewStatus
import me.goldze.mvvmhabit.base.BaseViewModel import me.goldze.mvvmhabit.base.BaseViewModel
......
package com.fry.base.basenetwork; package com.mints.street.netwrok.base;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import me.goldze.mvvmhabit.http.BaseResponse; import me.goldze.mvvmhabit.http.BaseResponse;
......
package com.fry.base.basenetwork package com.mints.street.netwrok.base
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
......
package com.fry.base.basenetwork; package com.mints.street.netwrok.base;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -6,6 +6,7 @@ import android.text.TextUtils; ...@@ -6,6 +6,7 @@ import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.fry.base.BuildConfig; import com.fry.base.BuildConfig;
import com.mints.street.netwrok.common.GsonConverterFactory;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -15,7 +16,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers; ...@@ -15,7 +16,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import me.goldze.mvvmhabit.http.cookie.CookieJarImpl; import me.goldze.mvvmhabit.http.cookie.CookieJarImpl;
import me.goldze.mvvmhabit.http.cookie.store.PersistentCookieStore; import me.goldze.mvvmhabit.http.cookie.store.PersistentCookieStore;
import me.goldze.mvvmhabit.http.interceptor.BaseInterceptor;
import me.goldze.mvvmhabit.http.interceptor.logging.Level; import me.goldze.mvvmhabit.http.interceptor.logging.Level;
import me.goldze.mvvmhabit.http.interceptor.logging.LoggingInterceptor; import me.goldze.mvvmhabit.http.interceptor.logging.LoggingInterceptor;
import me.goldze.mvvmhabit.utils.Utils; import me.goldze.mvvmhabit.utils.Utils;
...@@ -25,7 +25,6 @@ import okhttp3.OkHttpClient; ...@@ -25,7 +25,6 @@ import okhttp3.OkHttpClient;
import okhttp3.internal.platform.Platform; import okhttp3.internal.platform.Platform;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/** /**
* Created by jeme on 2019/1/31 * Created by jeme on 2019/1/31
...@@ -45,7 +44,6 @@ public class RetrofitClient { ...@@ -45,7 +44,6 @@ public class RetrofitClient {
throw new RuntimeException("baseUrl 不能为空"); throw new RuntimeException("baseUrl 不能为空");
} }
SslHttpsUtils.SSLParams sslParams = SslHttpsUtils.getSslSocketFactory();
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder() OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
.cookieJar(new CookieJarImpl(new PersistentCookieStore(mContext))) .cookieJar(new CookieJarImpl(new PersistentCookieStore(mContext)))
// .cache(cache) // .cache(cache)
......
package com.mints.street.netwrok.common;
import com.google.gson.Gson;
import com.mints.street.manager.UserManager;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import me.goldze.mvvmhabit.http.BaseResponse;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okio.Buffer;
import retrofit2.Converter;
import retrofit2.Retrofit;
/**
* Description:gson全局解析
*/
public class GsonConverterFactory extends Converter.Factory {
private final Gson gson;
public static GsonConverterFactory create() {
return create(new Gson());
}
public static GsonConverterFactory create(Gson gson) {
return new GsonConverterFactory(gson);
}
private GsonConverterFactory(Gson gson) {
if (gson == null) throw new NullPointerException("gson == null");
this.gson = gson;
}
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
return new GsonResponseBodyConverter<>(gson, type);
}
@Override
public Converter<?, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
return new GsonRequestBodyConverter<>(gson, type);
}
// 这里创建从ResponseBody其它类型的Converter
// 主要用于对响应体的处理
final class GsonResponseBodyConverter<T> implements Converter<ResponseBody, T> {
private final Gson gson;
private final Type type;
GsonResponseBodyConverter(Gson gson, Type type) {
this.gson = gson;
this.type = type;
}
@Override
public T convert(ResponseBody value) throws IOException {
Reader reader = value.charStream();
try {
T t = gson.fromJson(reader, type);
loginInvalid(t);
return t;
} finally {
try {
if (reader != null)
reader.close();
} catch (IOException ignored) {
ignored.printStackTrace();
}
}
}
/**
* 用户登陆失效
*
* @param t
*/
private void loginInvalid(T t) {
if (t instanceof BaseResponse) {
BaseResponse br = (BaseResponse) t;
int code = br.getstatus();
if (code == 401) {
try {
UserManager.Companion.getINSTANCE().userLogout();
// Activity forwardActivity = ForegroundOrBackground.getApp_activity();
// if (forwardActivity != null) {
// if (!forwardActivity.isFinishing()) {
// forwardActivity.startActivity(new Intent(forwardActivity, WxLoginActivity.class));
// }
// }
} catch (Exception e) {
}
}
}
}
}
// 在这里创建 从自定类型到ResponseBody 的Converter
// 主要用于对Part、PartMap、Body注解的处理
final class GsonRequestBodyConverter<T> implements Converter<T, RequestBody> {
private final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
private final Charset UTF_8 = StandardCharsets.UTF_8;
private final Gson gson;
private final Type type;
GsonRequestBodyConverter(Gson gson, Type type) {
this.gson = gson;
this.type = type;
}
@Override
public RequestBody convert(T value) throws IOException {
Buffer buffer = new Buffer();
Writer writer = new OutputStreamWriter(buffer.outputStream(), UTF_8);
gson.toJson(value, type, writer);
writer.flush();
return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
}
}
}
package com.mints.street.netwrok; package com.mints.street.netwrok.common;
import io.reactivex.Observable; import io.reactivex.Observable;
......
package com.mints.street.netwrok; package com.mints.street.netwrok.common;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import com.fry.base.basenetwork.HttpConfiguation;
import com.fry.base.basenetwork.IHttpResponseListener;
import com.fry.base.basenetwork.RetrofitClient;
import com.fry.base.global.Constants; import com.fry.base.global.Constants;
import com.fry.base.netwrok.OkHttpInterceptor; import com.mints.street.netwrok.base.HttpConfiguation;
import com.mints.street.netwrok.base.IHttpResponseListener;
import com.mints.street.netwrok.base.RetrofitClient;
import com.mints.street.utils.encry.AESUtils; import com.mints.street.utils.encry.AESUtils;
import com.trello.rxlifecycle2.LifecycleProvider; import com.trello.rxlifecycle2.LifecycleProvider;
......
package com.fry.base.netwrok package com.mints.street.netwrok.common
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
...@@ -165,6 +165,10 @@ class OkHttpInterceptor(aesKey: String) : Interceptor { ...@@ -165,6 +165,10 @@ class OkHttpInterceptor(aesKey: String) : Interceptor {
// 解密 // 解密
try { try {
val json = JSONObject(rspString) val json = JSONObject(rspString)
// if(!json.isNull("status")&& TextUtils.equals(json["status"].toString(),"401")){
// return
// }
if (!json.isNull("data")) { if (!json.isNull("data")) {
val data = json["data"] val data = json["data"]
rspString = AESUtils.detrypt(data.toString(), aesKey) rspString = AESUtils.detrypt(data.toString(), aesKey)
......
...@@ -89,13 +89,14 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() { ...@@ -89,13 +89,14 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
if (!deviceInfo.signInfo) { if (!deviceInfo.signInfo) {
finish() finish()
} else { } else {
try { // try {
mSplashContainer = findViewById(R.id.splash_container) // mSplashContainer = findViewById(R.id.splash_container)
//加载开屏广告 // //加载开屏广告
loadSplashAd() // loadSplashAd()
} catch (e: Exception) { // } catch (e: Exception) {
goToMainActivity() // goToMainActivity()
} // }
goToMainActivity()
} }
} }
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="ViewModel"
type="com.mints.street.main.home.HistoricalimageModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.mints.street.main.vr.PanoramicViewModel" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<com.fry.base.ui.widget.CommonTitleBar
android:id="@+id/ctb_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:ctb_theme="dark"
app:ctb_title="全景"
app:layout_constraintTop_toTopOf="parent"/>
<com.baidu.lbsapi.panoramaview.PanoramaView
android:id="@+id/panorama"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true" />
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
...@@ -8,6 +8,9 @@ buildscript { ...@@ -8,6 +8,9 @@ buildscript {
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
google() google()
jcenter() jcenter()
// umeng
maven { url 'https://repo1.maven.org/maven2/' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.1' classpath 'com.android.tools.build:gradle:4.1.1'
...@@ -27,6 +30,9 @@ allprojects { ...@@ -27,6 +30,9 @@ allprojects {
google() google()
jcenter() jcenter()
// umeng
maven { url 'https://repo1.maven.org/maven2/' }
} }
} }
......
package com.fry.base.basenetwork;
import java.lang.ref.WeakReference;
import io.reactivex.disposables.Disposable;
import me.goldze.mvvmhabit._enum.ViewStatus;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.http.BaseResponse;
import me.goldze.mvvmhabit.http.ExceptionHandle;
import me.goldze.mvvmhabit.http.ResponseThrowable;
import me.goldze.mvvmhabit.utils.ToastUtils;
import retrofit2.Response;
/**
* Created by jeme on 2019/1/31
*/
public abstract class HttpResponseListenerImpl<T extends BaseResponse> implements IHttpResponseListener<T>{
private WeakReference<BaseViewModel> viewModel;
private boolean needToast = true;
protected boolean isLoading = false;
public HttpResponseListenerImpl(BaseViewModel viewModel) {
this.viewModel = new WeakReference<>(viewModel);
}
public HttpResponseListenerImpl(BaseViewModel viewModel, boolean needToast) {
this.viewModel = new WeakReference<>(viewModel);
this.needToast = needToast;
}
public HttpResponseListenerImpl() {
}
@Override
public void onStart(Disposable disposable) {
if(!isLoading){
if(viewModel !=null && viewModel.get() != null){
viewModel.get().showDialog();
}
isLoading = true;
}else{
disposable.dispose();
}
}
@Override
public boolean onParseResponse(Response<T> response) {
return false;
}
public boolean isEmpty(T response){
return false;
}
@Override
public void onBusinessFail(T response) {
/* if(isEmpty(response)){
viewModel.get().viewSwitch(ViewStatus.NODATA);
}*/
if(response == null){
viewModel.get().viewSwitch(ViewStatus.NODATA);
return;
}
if(needToast) {
ToastUtils.showShort(response.getMessage());
}
}
@Override
public void onFailed(ResponseThrowable throwable) {
isLoading = false;
if(throwable == null){
return;
}
if(needToast) {
ToastUtils.showShort(throwable.message);
}
if(throwable.code == ExceptionHandle.ERROR.HTTP_ERROR
|| throwable.code == ExceptionHandle.ERROR.NETWORD_ERROR
|| throwable.code == ExceptionHandle.ERROR.TIMEOUT_ERROR){
if(viewModel != null && viewModel.get() != null){
viewModel.get().viewSwitch(ViewStatus.NONETWORK);
}
}
}
@Override
public void onCompleted() {
isLoading = false;
if(viewModel !=null && viewModel.get() != null){
viewModel.get().dismissDialog();
}
}
}
package com.fry.base.basenetwork;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
/**
* Created by ωǒ、〃尐川.η on 2018/8/20.
*/
public class HttpsUtil {
//获取这个SSLSocketFactory
public static SSLSocketFactory getSSLSocketFactory() {
try {
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, getTrustManager(), new SecureRandom());
return sslContext.getSocketFactory();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
//获取TrustManager
private static TrustManager[] getTrustManager() {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
}
};
return trustAllCerts;
}
//获取HostnameVerifier
public static HostnameVerifier getHostnameVerifier() {
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
};
return hostnameVerifier;
}
}
package com.fry.base.basenetwork;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
/**
* Created by jeme on 2019/1/31
*/
public class SslHttpsUtils {
public static class SSLParams {
public SSLSocketFactory sSLSocketFactory;
public X509TrustManager trustManager;
}
public static SSLParams getSslSocketFactory() {
return getSslSocketFactoryBase(null, null, null);
}
/**
* https单向认证
* 可以额外配置信任服务端的证书策略,否则默认是按CA证书去验证的,若不是CA可信任的证书,则无法通过验证
*/
public static SSLParams getSslSocketFactory(X509TrustManager trustManager) {
return getSslSocketFactoryBase(trustManager, null, null);
}
/**
* https单向认证
* 用含有服务端公钥的证书校验服务端证书
*/
public static SSLParams getSslSocketFactory(InputStream... certificates) {
return getSslSocketFactoryBase(null, null, null, certificates);
}
/**
* https双向认证
* bksFile 和 password -> 客户端使用bks证书校验服务端证书
* certificates -> 用含有服务端公钥的证书校验服务端证书
*/
public static SSLParams getSslSocketFactory(InputStream bksFile, String password, InputStream... certificates) {
return getSslSocketFactoryBase(null, bksFile, password, certificates);
}
/**
* https双向认证
* bksFile 和 password -> 客户端使用bks证书校验服务端证书
* X509TrustManager -> 如果需要自己校验,那么可以自己实现相关校验,如果不需要自己校验,那么传null即可
*/
public static SSLParams getSslSocketFactory(InputStream bksFile, String password, X509TrustManager trustManager) {
return getSslSocketFactoryBase(trustManager, bksFile, password);
}
private static SSLParams getSslSocketFactoryBase(X509TrustManager trustManager, InputStream bksFile, String password, InputStream... certificates) {
SSLParams sslParams = new SSLParams();
try {
KeyManager[] keyManagers = prepareKeyManager(bksFile, password);
TrustManager[] trustManagers = prepareTrustManager(certificates);
X509TrustManager manager;
if (trustManager != null) {
//优先使用用户自定义的TrustManager
manager = trustManager;
} else if (trustManagers != null) {
//然后使用默认的TrustManager
manager = chooseTrustManager(trustManagers);
} else {
//否则使用不安全的TrustManager
manager = UnSafeTrustManager;
}
// 创建TLS类型的SSLContext对象, that uses our TrustManager
SSLContext sslContext = SSLContext.getInstance("TLS");
// 用上面得到的trustManagers初始化SSLContext,这样sslContext就会信任keyStore中的证书
// 第一个参数是授权的密钥管理器,用来授权验证,比如授权自签名的证书验证。第二个是被授权的证书管理器,用来验证服务器端的证书
sslContext.init(keyManagers, new TrustManager[]{manager}, null);
// 通过sslContext获取SSLSocketFactory对象
sslParams.sSLSocketFactory = sslContext.getSocketFactory();
sslParams.trustManager = manager;
return sslParams;
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
} catch (KeyManagementException e) {
throw new AssertionError(e);
}
}
private static KeyManager[] prepareKeyManager(InputStream bksFile, String password) {
try {
if (bksFile == null || password == null) return null;
KeyStore clientKeyStore = KeyStore.getInstance("BKS");
clientKeyStore.load(bksFile, password.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(clientKeyStore, password.toCharArray());
return kmf.getKeyManagers();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private static TrustManager[] prepareTrustManager(InputStream... certificates) {
if (certificates == null || certificates.length <= 0) return null;
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
// 创建一个默认类型的KeyStore,存储我们信任的证书
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null);
int index = 0;
for (InputStream certStream : certificates) {
String certificateAlias = Integer.toString(index++);
// 证书工厂根据证书文件的流生成证书 cert
Certificate cert = certificateFactory.generateCertificate(certStream);
// 将 cert 作为可信证书放入到keyStore中
keyStore.setCertificateEntry(certificateAlias, cert);
try {
if (certStream != null) certStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//我们创建一个默认类型的TrustManagerFactory
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
//用我们之前的keyStore实例初始化TrustManagerFactory,这样tmf就会信任keyStore中的证书
tmf.init(keyStore);
//通过tmf获取TrustManager数组,TrustManager也会信任keyStore中的证书
return tmf.getTrustManagers();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private static X509TrustManager chooseTrustManager(TrustManager[] trustManagers) {
for (TrustManager trustManager : trustManagers) {
if (trustManager instanceof X509TrustManager) {
return (X509TrustManager) trustManager;
}
}
return null;
}
/**
* 为了解决客户端不信任服务器数字证书的问题,网络上大部分的解决方案都是让客户端不对证书做任何检查,
* 这是一种有很大安全漏洞的办法
*/
public static X509TrustManager UnSafeTrustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
};
/**
* 此类是用于主机名验证的基接口。 在握手期间,如果 URL 的主机名和服务器的标识主机名不匹配,
* 则验证机制可以回调此接口的实现程序来确定是否应该允许此连接。策略可以是基于证书的或依赖于其他验证方案。
* 当验证 URL 主机名使用的默认规则失败时使用这些回调。如果主机名是可接受的,则返回 true
*/
public static HostnameVerifier UnSafeHostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment