taxiApp26.2.8.2release版本
This commit is contained in:
parent
48e9f9762d
commit
faebc07e8a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,2 +1,2 @@
|
||||||
#Fri Oct 21 16:04:51 GMT+08:00 2022
|
#Tue Jul 18 17:57:57 GMT+08:00 2023
|
||||||
gradle.version=5.6.4
|
gradle.version=5.6.4
|
||||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -87,10 +87,10 @@
|
||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library name="Gradle: kaptGeneratedClasses">
|
<library name="Gradle: kaptGeneratedClasses">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debugUnitTest" />
|
|
||||||
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debugAndroidTest" />
|
|
||||||
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/release" />
|
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/release" />
|
||||||
|
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debugUnitTest" />
|
||||||
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/releaseUnitTest" />
|
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/releaseUnitTest" />
|
||||||
|
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debugAndroidTest" />
|
||||||
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debug" />
|
<root url="file://$MODULE_DIR$/../../../kurolibrary/build/tmp/kapt3/classes/debug" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
|
|
|
@ -90,10 +90,10 @@
|
||||||
<library name="Gradle: kaptGeneratedClasses">
|
<library name="Gradle: kaptGeneratedClasses">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debug" />
|
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debug" />
|
||||||
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/release" />
|
|
||||||
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/releaseUnitTest" />
|
|
||||||
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debugUnitTest" />
|
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debugUnitTest" />
|
||||||
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debugAndroidTest" />
|
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/debugAndroidTest" />
|
||||||
|
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/release" />
|
||||||
|
<root url="file://$MODULE_DIR$/../../../kurotool/build/tmp/kapt3/classes/releaseUnitTest" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -21,8 +21,8 @@ android {
|
||||||
applicationId "net.sysolution.taxiapp"
|
applicationId "net.sysolution.taxiapp"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 188
|
versionCode 208
|
||||||
versionName "3.3.3-beta26.3.3.8.3-release"
|
versionName "3.3.3-beta26.3.8.2-release"
|
||||||
|
|
||||||
//alphaxx - 预览版本,不会对外发布,由测试人员测试,会有很多bug
|
//alphaxx - 预览版本,不会对外发布,由测试人员测试,会有很多bug
|
||||||
//Betaxx - 公开测试版本,会发给其他工作人员,会有较多版本
|
//Betaxx - 公开测试版本,会发给其他工作人员,会有较多版本
|
||||||
|
@ -48,7 +48,10 @@ android {
|
||||||
26.3.2 解决卸载重装后设备不在原来的分组问题
|
26.3.2 解决卸载重装后设备不在原来的分组问题
|
||||||
26.3.3 解决直接升级后设备不播放广告或者等很久才播放问题
|
26.3.3 解决直接升级后设备不播放广告或者等很久才播放问题
|
||||||
26.3.7 由于经常掉线,心跳改回30s发一次,重连时间改回10s,日志开关默认关闭
|
26.3.7 由于经常掉线,心跳改回30s发一次,重连时间改回10s,日志开关默认关闭
|
||||||
26.3.8 更换了播放器默认logo图,修改同步的时候出现logo问题,增加“查询是否设置过logo”功能
|
26.3.8.8debug 更换了播放器默认logo图,修改同步的时候出现logo问题,增加“查询是否设置过logo”功能
|
||||||
|
26.3.8.9debug 修复定点广告播放顺序,ledOk重复绑定同一个凭证会被过滤,重连时会主动断开旧连接,3s没gps信息清除定点广告改成30s,
|
||||||
|
重启时主动获取一次gps信息,没有gps则判断是否有定点广告,有就清除
|
||||||
|
26.3.8 新增清除logo
|
||||||
**/
|
**/
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
|
@ -7,9 +7,11 @@
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- gps定位权限 -->
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<!-- gps定位权限 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 允许读取电话状态SIM的权限 -->
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
|
<!-- 允许读取电话状态SIM的权限 -->
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
|
|
@ -3,6 +3,9 @@ package cn.trans88.taxiappkotlin;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import cn.trans88.taxiappkotlin.logic.model.BackgroundType;
|
||||||
import cn.trans88.taxiappkotlin.util.YoungUtil;
|
import cn.trans88.taxiappkotlin.util.YoungUtil;
|
||||||
|
|
||||||
public class Configurations {
|
public class Configurations {
|
||||||
|
@ -322,13 +325,22 @@ public class Configurations {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String backgroundType(){
|
public String backgroundType(){
|
||||||
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("backgroundType", "");
|
TaxiApp taxiApp = (TaxiApp) TaxiApp.Companion.instance();
|
||||||
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("backgroundType", taxiApp.getDefaultBackgroundType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void backgroundTypeSave(String s){
|
public void backgroundTypeSave(String s){
|
||||||
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("backgroundType", s).apply();
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("backgroundType", s).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCustomLogo(){
|
||||||
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("isCustomLogo", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void isCustomLogoSave(Boolean b){
|
||||||
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("isCustomLogo", b).apply();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,28 +3,23 @@ package cn.trans88.taxiappkotlin
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.media.MediaCodecList
|
import android.media.MediaCodecList
|
||||||
import android.os.Build
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import cn.trans88.kurotool.util.LogLevel
|
import cn.trans88.kurotool.util.LogLevel
|
||||||
import cn.trans88.kurotool.util.LogUtil
|
import cn.trans88.kurotool.util.LogUtil
|
||||||
import cn.trans88.taxiappkotlin.ext.logd
|
|
||||||
import cn.trans88.taxiappkotlin.ext.loge
|
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.DaoMaster
|
import cn.trans88.taxiappkotlin.logic.dao.DaoMaster
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.DaoSession
|
import cn.trans88.taxiappkotlin.logic.dao.DaoSession
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.HelperDaoDB
|
import cn.trans88.taxiappkotlin.logic.dao.HelperDaoDB
|
||||||
import cn.trans88.taxiappkotlin.logic.exception.CrashHandler
|
import cn.trans88.taxiappkotlin.logic.exception.CrashHandler
|
||||||
import cn.trans88.taxiappkotlin.logic.model.Advertise
|
import cn.trans88.taxiappkotlin.logic.model.Advertise
|
||||||
import cn.trans88.taxiappkotlin.logic.model.Schedule
|
import cn.trans88.taxiappkotlin.logic.model.BackgroundType
|
||||||
import cn.trans88.taxiappkotlin.logic.network.JoeyDownloadManager
|
import cn.trans88.taxiappkotlin.logic.network.JoeyDownloadManager
|
||||||
import cn.trans88.taxiappkotlin.net.BizInterceptor
|
import cn.trans88.taxiappkotlin.net.BizInterceptor
|
||||||
import cn.trans88.taxiappkotlin.net.RetrofitCallFactory
|
|
||||||
import cn.trans88.taxiappkotlin.ui.custom.JVideoView
|
import cn.trans88.taxiappkotlin.ui.custom.JVideoView
|
||||||
import cn.trans88.taxiappkotlin.ui.play.PlayActivity
|
import cn.trans88.taxiappkotlin.ui.play.PlayActivity
|
||||||
import cn.trans88.taxiappkotlin.ui.play.PlayServer
|
|
||||||
import cn.trans88.taxiappkotlin.util.YoungUtil
|
import cn.trans88.taxiappkotlin.util.YoungUtil
|
||||||
import com.facebook.stetho.Stetho
|
import com.facebook.stetho.Stetho
|
||||||
|
import com.google.gson.Gson
|
||||||
import com.trs88.kurolibrary.log.*
|
import com.trs88.kurolibrary.log.*
|
||||||
import com.trs88.kurolibrary.restful.KuroRestful
|
|
||||||
import com.trs88.kurolibrary.restful.retrofit.KuroApiFactory
|
import com.trs88.kurolibrary.restful.retrofit.KuroApiFactory
|
||||||
import io.reactivex.plugins.RxJavaPlugins
|
import io.reactivex.plugins.RxJavaPlugins
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -37,6 +32,10 @@ class TaxiApp:Application() {
|
||||||
private lateinit var daoSession: DaoSession
|
private lateinit var daoSession: DaoSession
|
||||||
private lateinit var daoMaster: DaoMaster
|
private lateinit var daoMaster: DaoMaster
|
||||||
|
|
||||||
|
var gson = Gson()
|
||||||
|
var defaultBackgroundType = ""
|
||||||
|
|
||||||
|
|
||||||
var nextVideoView:JVideoView? = null
|
var nextVideoView:JVideoView? = null
|
||||||
|
|
||||||
val timer = Timer()
|
val timer = Timer()
|
||||||
|
@ -63,7 +62,7 @@ class TaxiApp:Application() {
|
||||||
val HAOSHENG = "HAOSHENG";
|
val HAOSHENG = "HAOSHENG";
|
||||||
val MAIDIER = "MAIDIER";
|
val MAIDIER = "MAIDIER";
|
||||||
val isTest = false
|
val isTest = false
|
||||||
val testCardid:String ="y60-a20-40919"
|
val testCardid:String = "y60-a20-40919"
|
||||||
var isActive = false
|
var isActive = false
|
||||||
var startSyncMode = false
|
var startSyncMode = false
|
||||||
// var isFirstRegister = true
|
// var isFirstRegister = true
|
||||||
|
@ -104,6 +103,9 @@ class TaxiApp:Application() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var backgroundType = BackgroundType()
|
||||||
|
defaultBackgroundType = gson.toJson(backgroundType)
|
||||||
|
|
||||||
//初始化下载
|
//初始化下载
|
||||||
JoeyDownloadManager.init(this, 30 * 1000, 30 * 1000)
|
JoeyDownloadManager.init(this, 30 * 1000, 30 * 1000)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import cn.trans88.taxiappkotlin.Configurations
|
||||||
import cn.trans88.taxiappkotlin.TaxiApp
|
import cn.trans88.taxiappkotlin.TaxiApp
|
||||||
import cn.trans88.taxiappkotlin.ext.fromJson
|
import cn.trans88.taxiappkotlin.ext.fromJson
|
||||||
import cn.trans88.taxiappkotlin.ext.isMainThread
|
import cn.trans88.taxiappkotlin.ext.isMainThread
|
||||||
|
import cn.trans88.taxiappkotlin.ext.logd
|
||||||
import cn.trans88.taxiappkotlin.ext.loge
|
import cn.trans88.taxiappkotlin.ext.loge
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao
|
import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.DaoUtil
|
import cn.trans88.taxiappkotlin.logic.dao.DaoUtil
|
||||||
|
@ -34,6 +35,9 @@ import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.trs88.kurolibrary.execute.KuroExecutor
|
import com.trs88.kurolibrary.execute.KuroExecutor
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import okhttp3.internal.closeQuietly
|
||||||
|
import org.greenrobot.greendao.query.LazyList
|
||||||
|
import org.greenrobot.greendao.query.QueryBuilder
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.LinkedBlockingQueue
|
import java.util.concurrent.LinkedBlockingQueue
|
||||||
|
@ -43,7 +47,6 @@ import kotlin.collections.ArrayList
|
||||||
* 仓库层:判断调用的数据是从本地获取还是网络获取的
|
* 仓库层:判断调用的数据是从本地获取还是网络获取的
|
||||||
*/
|
*/
|
||||||
val myListMap = mutableMapOf<Int, ArrayList<Advertise>>()
|
val myListMap = mutableMapOf<Int, ArrayList<Advertise>>()
|
||||||
var myListMapTemp = mutableMapOf<Int, ArrayList<Advertise>>()
|
|
||||||
object Repository {
|
object Repository {
|
||||||
// private val circularListMap = mapOf(AdvertiseType.NORMAL.ordinal to CircularList<Advertise>(),AdvertiseType.AREA.ordinal to CircularList<Advertise>())
|
// private val circularListMap = mapOf(AdvertiseType.NORMAL.ordinal to CircularList<Advertise>(),AdvertiseType.AREA.ordinal to CircularList<Advertise>())
|
||||||
private val circularListMap = mutableMapOf<Int, CircularList<Advertise>>()
|
private val circularListMap = mutableMapOf<Int, CircularList<Advertise>>()
|
||||||
|
@ -66,46 +69,27 @@ object Repository {
|
||||||
|
|
||||||
var currentSyncTime: Long = 0
|
var currentSyncTime: Long = 0
|
||||||
|
|
||||||
/**
|
|
||||||
* 将广告发送给观察者
|
|
||||||
*/
|
|
||||||
// @Deprecated("已经废弃")
|
|
||||||
// fun getAdvertise() = liveData(Dispatchers.IO) {
|
|
||||||
//// fun getAdvertise() = liveData{
|
|
||||||
// YoungUtil.YoungLog("getAdvertise")
|
|
||||||
// val advertise = getTestPlayAdvertise(myListMap[getTestPlayLevels()])
|
|
||||||
// val result = try {
|
|
||||||
// Result.success(advertise)
|
|
||||||
// } catch (e: Exception) {
|
|
||||||
// Result.failure<Advertise>(e)
|
|
||||||
// }
|
|
||||||
// emit(result)
|
|
||||||
// }
|
|
||||||
|
|
||||||
fun setSyncTime(syncTime: Long) {
|
fun setSyncTime(syncTime: Long) {
|
||||||
currentSyncTime = syncTime
|
currentSyncTime = syncTime
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAdvertiseTEST(): Advertise? {
|
fun getAdvertiseTEST(): Advertise? {
|
||||||
val list = myListMap[getTestPlayLevels()]
|
synchronized(TaxiApp::class.java){
|
||||||
val listTemp = myListMapTemp[getTestPlayLevels()]
|
val list = myListMap[getTestPlayLevels()]
|
||||||
"广告数量:${list?.size}".loge()
|
"广告数量:${list?.size}".loge()
|
||||||
|
//#edit by ljh 2023/2/16
|
||||||
//#edit by ljh 2023/2/16
|
var advertise:Advertise? = null
|
||||||
var advertise:Advertise? = null
|
val isTimedAdvertise = Configurations.config(taxiApp.activity).isTimedAdvertise
|
||||||
val isTimedAdvertise = Configurations.config(taxiApp.activity).isTimedAdvertise
|
advertise = if (isTimedAdvertise){
|
||||||
advertise = if (isTimedAdvertise){
|
getTestPlayAdvertise(taxiApp.timedAds)
|
||||||
getTestPlayAdvertise(taxiApp.timedAds)
|
} else {
|
||||||
} else {
|
getTestPlayAdvertise(list)
|
||||||
getTestPlayAdvertise(list) ?: getTestPlayAdvertiseByTempList(listTemp)
|
}
|
||||||
}
|
|
||||||
// val advertise = getTestPlayAdvertise(myListMap[getTestPlayLevels()])
|
// val advertise = getTestPlayAdvertise(myListMap[getTestPlayLevels()])
|
||||||
return advertise
|
return advertise
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fun getPlayCircularList(): CircularList<Advertise>? {
|
|
||||||
// return circularListMap[getPlayLevels()]
|
|
||||||
// }
|
|
||||||
|
|
||||||
fun getTestPlayCircularList(): MutableList<Advertise>? {
|
fun getTestPlayCircularList(): MutableList<Advertise>? {
|
||||||
//#edit by ljh @2023/2/23
|
//#edit by ljh @2023/2/23
|
||||||
|
@ -279,191 +263,193 @@ object Repository {
|
||||||
return AdvertiseType.IDLE.ordinal
|
return AdvertiseType.IDLE.ordinal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getTestPlayLevels() refreshMyList() getAdvertiseTEST() 用同一把锁加同步,防止有广告时出现logo
|
||||||
|
*
|
||||||
|
* @return Int
|
||||||
|
*/
|
||||||
fun getTestPlayLevels(): Int {
|
fun getTestPlayLevels(): Int {
|
||||||
val levels = AdvertiseType.values()
|
synchronized(TaxiApp::class.java){
|
||||||
val isTimedAdvertise = Configurations.config(taxiApp.activity).isTimedAdvertise
|
val levels = AdvertiseType.values()
|
||||||
"getTestPlayLevels -> isTimedAdvertise:$isTimedAdvertise".loge()
|
val isTimedAdvertise = Configurations.config(taxiApp.activity).isTimedAdvertise
|
||||||
for (index in AdvertiseType.values().size downTo 0) {
|
"getTestPlayLevels -> isTimedAdvertise:$isTimedAdvertise".loge()
|
||||||
//#edit by ljh 2023/2/27
|
for (index in AdvertiseType.values().size downTo 0) {
|
||||||
//先判断当前的播放列表是否是分时段播放列表,还是正常的播放列表
|
//#edit by ljh 2023/2/27
|
||||||
val list = if (!isTimedAdvertise){
|
//先判断当前的播放列表是否是分时段播放列表,还是正常的播放列表
|
||||||
myListMap[index]
|
val list = if (!isTimedAdvertise){
|
||||||
} else {
|
myListMap[index]
|
||||||
"分时段播放列表".loge()
|
} else {
|
||||||
taxiApp.timedAds
|
"分时段播放列表".loge()
|
||||||
return AdvertiseType.GROUP.ordinal
|
taxiApp.timedAds
|
||||||
}
|
return AdvertiseType.GROUP.ordinal
|
||||||
if (list!!.size > 0) {
|
}
|
||||||
val level = when(index){
|
if (list!!.size > 0) {
|
||||||
AdvertiseType.AREA.ordinal -> "定点广告"
|
val level = when(index){
|
||||||
AdvertiseType.IDLE.ordinal -> "闲置广告"
|
AdvertiseType.AREA.ordinal -> "定点广告"
|
||||||
AdvertiseType.GROUP.ordinal -> "分组广告"
|
AdvertiseType.IDLE.ordinal -> "闲置广告"
|
||||||
AdvertiseType.COUNT.ordinal -> "计数广告"
|
AdvertiseType.GROUP.ordinal -> "分组广告"
|
||||||
else -> "其他广告"
|
AdvertiseType.COUNT.ordinal -> "计数广告"
|
||||||
}
|
else -> "其他广告"
|
||||||
YoungUtil.YoungLog("当前播放广告的等级:$level,播放列表不为空")
|
}
|
||||||
return index
|
YoungUtil.YoungLog("当前播放广告的等级:$level,播放列表不为空")
|
||||||
}
|
return index
|
||||||
}
|
}
|
||||||
return AdvertiseType.IDLE.ordinal
|
}
|
||||||
|
YoungUtil.YoungLog("当前播放广告的等级:闲置广告")
|
||||||
|
return AdvertiseType.IDLE.ordinal
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新循环列表
|
* 刷新循环列表
|
||||||
*/
|
*/
|
||||||
@Synchronized
|
|
||||||
fun refreshMyList() {
|
fun refreshMyList() {
|
||||||
val currentTimeMillis = System.currentTimeMillis()
|
synchronized(TaxiApp::class.java){
|
||||||
YoungUtil.YoungLog("refreshMyList 是否在主线程: ${Thread.currentThread().isMainThread()}")
|
var daoAdvertises:LazyList<Advertise>? = null
|
||||||
// myListMap.clear()
|
try {
|
||||||
|
val currentTimeMillis = System.currentTimeMillis()
|
||||||
|
YoungUtil.YoungLog("refreshMyList 是否在主线程: ${Thread.currentThread().isMainThread()}")
|
||||||
|
|
||||||
//#edit by ljh @2023/6/29
|
//#edit by ljh @2023/6/29
|
||||||
for (index in AdvertiseType.values().size downTo 0) {
|
for (index in AdvertiseType.values().size downTo 0) {
|
||||||
//清空前先备份一下列表
|
myListMap[index]?.clear()
|
||||||
myListMapTemp[index] = if (myListMap[index].isNullOrEmpty()){
|
myListMap[index] = ArrayList()
|
||||||
ArrayList()
|
|
||||||
} else {
|
|
||||||
myListMap[index]!!
|
|
||||||
}
|
|
||||||
myListMap[index]?.clear()
|
|
||||||
myListMap[index] = ArrayList()
|
|
||||||
}
|
|
||||||
|
|
||||||
//#edit by ljh 2023/2/23
|
|
||||||
//如果当前播放的是定时播放列表重新排序
|
|
||||||
val isTimedAdNow = Configurations.config(taxiApp.activity).isTimedAdvertise
|
|
||||||
"现在是否正在播定时广告:$isTimedAdNow".loge()
|
|
||||||
var tempList: ArrayList<Advertise>? = null
|
|
||||||
if (isTimedAdNow){
|
|
||||||
val timedListJsonStr = Configurations.config(taxiApp.activity).timedAdList()
|
|
||||||
if (taxiApp.timedAds.isEmpty()){
|
|
||||||
tempList = ProcessingCommands.gson.fromJson(timedListJsonStr,object :TypeToken<kotlin.collections.List<Advertise>>(){}.type) as ArrayList<Advertise>
|
|
||||||
taxiApp.timedAds.addAll(tempList)
|
|
||||||
}
|
|
||||||
// taxiApp.timedAds.clear()
|
|
||||||
}
|
|
||||||
"refreshMyList播放列表重新赋值刷新了".loge()
|
|
||||||
|
|
||||||
//清楚排序规则
|
|
||||||
DaoUtil.getOrderDao().deleteAll()
|
|
||||||
|
|
||||||
val daoAdvertises = DaoUtil.getAdvertise().queryBuilder().orderDesc(AdvertiseDao.Properties.CreateAt).list()
|
|
||||||
"存储的广告数量:${daoAdvertises.size}".loge()
|
|
||||||
val advertises = mutableListOf<Advertise>()
|
|
||||||
//定点广告list
|
|
||||||
val area = DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.BelongTo.eq(AdvertiseType.AREA.ordinal)).list()
|
|
||||||
YoungUtil.YoungLog("定点广告数量:${area.size}")
|
|
||||||
if (Configurations.config(TaxiApp.instance()).advertiseOrder() != "" && area.size == 0) {
|
|
||||||
val orderList = Gson().fromJson<AdvertiseOrder>(Configurations.config(TaxiApp.instance()).advertiseOrder()).advertise_order
|
|
||||||
YoungUtil.YoungLog("当前的播放顺序策略:${orderList.toString()}")
|
|
||||||
|
|
||||||
orderList.forEach { orderListAdid ->
|
|
||||||
daoAdvertises.forEach { daoAdvertis ->
|
|
||||||
if (orderListAdid == daoAdvertis.ad_id) {
|
|
||||||
YoungUtil.YoungLog("adid相同加入 播放数组 adid:$orderListAdid")
|
|
||||||
advertises.add(daoAdvertis)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// //将剩下没排序的广告加入播放列表
|
//#edit by ljh 2023/2/23
|
||||||
// for (daoAdvertise in daoAdvertises.reversed()) {
|
//如果当前播放的是定时播放列表重新排序
|
||||||
// var insert =true
|
val isTimedAdNow = Configurations.config(taxiApp.activity).isTimedAdvertise
|
||||||
// for (advertise in advertises) {
|
"现在是否正在播定时广告:$isTimedAdNow".loge()
|
||||||
// if (advertise.ad_id == daoAdvertise.ad_id){
|
var tempList: ArrayList<Advertise>? = null
|
||||||
// insert =false
|
if (isTimedAdNow){
|
||||||
|
val timedListJsonStr = Configurations.config(taxiApp.activity).timedAdList()
|
||||||
|
if (taxiApp.timedAds.isEmpty()){
|
||||||
|
tempList = ProcessingCommands.gson.fromJson(timedListJsonStr,object :TypeToken<kotlin.collections.List<Advertise>>(){}.type) as ArrayList<Advertise>
|
||||||
|
taxiApp.timedAds.addAll(tempList)
|
||||||
|
}
|
||||||
|
// taxiApp.timedAds.clear()
|
||||||
|
}
|
||||||
|
"refreshMyList播放列表重新赋值刷新了".loge()
|
||||||
|
|
||||||
|
//清楚排序规则
|
||||||
|
DaoUtil.getOrderDao().deleteAll()
|
||||||
|
|
||||||
|
// val daoAdvertises = DaoUtil.getAdvertise().queryBuilder().orderDesc(AdvertiseDao.Properties.CreateAt).list()
|
||||||
|
//#edit by ljh @2023/8/7 使用缓存加懒加载防止内存溢出,需要手动关闭close
|
||||||
|
daoAdvertises = DaoUtil.getAdvertise().queryBuilder().orderDesc(AdvertiseDao.Properties.CreateAt).listLazy()
|
||||||
|
"存储的广告数量:${daoAdvertises.size}".loge()
|
||||||
|
val advertises = mutableListOf<Advertise>()
|
||||||
|
//定点广告list
|
||||||
|
// val builder:QueryBuilder<Advertise> = DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.BelongTo.eq(AdvertiseType.AREA.ordinal))
|
||||||
|
// val query = builder.buildCursor().query()
|
||||||
|
// query.isClosed
|
||||||
|
val area = DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.BelongTo.eq(AdvertiseType.AREA.ordinal)).list()
|
||||||
|
YoungUtil.YoungLog("定点广告数量:${area.size}")
|
||||||
|
if (Configurations.config(TaxiApp.instance()).advertiseOrder() != "" && area.size == 0) {
|
||||||
|
val orderList = Gson().fromJson<AdvertiseOrder>(Configurations.config(TaxiApp.instance()).advertiseOrder()).advertise_order
|
||||||
|
YoungUtil.YoungLog("当前的播放顺序策略:${orderList.toString()}")
|
||||||
|
|
||||||
|
orderList.forEach { orderListAdid ->
|
||||||
|
daoAdvertises.forEach { daoAdvertis ->
|
||||||
|
if (orderListAdid == daoAdvertis.ad_id) {
|
||||||
|
YoungUtil.YoungLog("adid相同加入 播放数组 adid:$orderListAdid")
|
||||||
|
advertises.add(daoAdvertis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//如果服务端的排序解析失败还是按原来的顺序
|
||||||
|
if (orderList.isNullOrEmpty()) {
|
||||||
|
advertises.addAll(daoAdvertises)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
advertises.addAll(daoAdvertises)
|
||||||
|
advertises.reverse()
|
||||||
|
// daoAdvertises.reverse()
|
||||||
|
// daoAdvertises.forEach {
|
||||||
|
// advertises.add(it)
|
||||||
// }
|
// }
|
||||||
// }
|
}
|
||||||
//
|
"advertises的广告数量:${advertises.size}".loge()
|
||||||
// if (insert){
|
for (index in 0 until advertises.size) {
|
||||||
// YoungUtil.YoungLog("有没有排序的广告 ad_id:${daoAdvertise.ad_id} 加入排序")
|
val order = Order()
|
||||||
// advertises.add(daoAdvertise)
|
order.ad_id = advertises[index].ad_id
|
||||||
// }
|
if (index == advertises.size - 1) {
|
||||||
// }
|
order.isLast = true
|
||||||
|
}
|
||||||
|
DaoUtil.getOrderDao().insert(order)
|
||||||
|
}
|
||||||
|
|
||||||
//如果服务端的排序解析失败还是按原来的顺序
|
for (index in 0 until advertises.size) {
|
||||||
if (orderList.isNullOrEmpty()) {
|
YoungUtil.YoungLog("列表序号:${advertises[index].ad_id} 创建时间 ${advertises[index].createAt}")
|
||||||
advertises.addAll(daoAdvertises)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//Collections.reverse(daoAdvertises)
|
|
||||||
daoAdvertises.reverse()
|
|
||||||
daoAdvertises.forEach {
|
|
||||||
advertises.add(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"advertises的广告数量:${advertises.size}".loge()
|
|
||||||
for (index in 0 until advertises.size) {
|
|
||||||
val order = Order()
|
|
||||||
order.ad_id = advertises[index].ad_id
|
|
||||||
if (index == advertises.size - 1) {
|
|
||||||
order.isLast = true
|
|
||||||
}
|
|
||||||
DaoUtil.getOrderDao().insert(order)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (index in 0 until advertises.size) {
|
|
||||||
YoungUtil.YoungLog("列表序号:${advertises[index].ad_id} 创建时间 ${advertises[index].createAt}")
|
|
||||||
// sb.append("\n广告id:${advertise.ad_id}")
|
// sb.append("\n广告id:${advertise.ad_id}")
|
||||||
|
|
||||||
val advertise = advertises[index]
|
val advertise = advertises[index]
|
||||||
|
|
||||||
if (index == advertises.size - 1) {
|
if (index == advertises.size - 1) {
|
||||||
YoungUtil.YoungLog("最后一个素材 设置为true")
|
YoungUtil.YoungLog("最后一个素材 设置为true")
|
||||||
advertise.isLast = true
|
advertise.isLast = true
|
||||||
}
|
}
|
||||||
|
|
||||||
val newAdvertise = oldAdvertiseToNewAdvertise(advertise)
|
val newAdvertise = oldAdvertiseToNewAdvertise(advertise)
|
||||||
|
|
||||||
//#edit by ljh 2023/2/17
|
//#edit by ljh 2023/2/17
|
||||||
//重启时如果是分时段广告,则重新开启它的分时段播放任务
|
//重启时如果是分时段广告,则重新开启它的分时段播放任务
|
||||||
newAdvertise.isTimedAd?.let {
|
newAdvertise.isTimedAd?.let {
|
||||||
var tasks = taxiApp.timerTaskMap[newAdvertise.ad_id]
|
var tasks = taxiApp.timerTaskMap[newAdvertise.ad_id]
|
||||||
if (tasks.isNullOrEmpty()){
|
if (tasks.isNullOrEmpty()){
|
||||||
val schedules = DaoUtil.getSchedule().queryBuilder()
|
val schedules = DaoUtil.getSchedule().queryBuilder()
|
||||||
.where(ScheduleDao.Properties.AdvertiseId.eq(newAdvertise.ad_id)).list()
|
.where(ScheduleDao.Properties.AdvertiseId.eq(newAdvertise.ad_id)).list()
|
||||||
// "schedules数量:${schedules.size}".loge()
|
// "schedules数量:${schedules.size}".loge()
|
||||||
if (!schedules.isNullOrEmpty()){
|
if (!schedules.isNullOrEmpty()){
|
||||||
newAdvertise.isTimedAd = true
|
newAdvertise.isTimedAd = true
|
||||||
val daoAdvertise = DaoUtil.getAdvertise()
|
val daoAdvertise = DaoUtil.getAdvertise()
|
||||||
.queryBuilder().where(AdvertiseDao.Properties.Ad_id.eq(newAdvertise.ad_id.toString())).unique()
|
.queryBuilder().where(AdvertiseDao.Properties.Ad_id.eq(newAdvertise.ad_id.toString())).unique()
|
||||||
daoAdvertise.isTimedAd = true
|
daoAdvertise.isTimedAd = true
|
||||||
DaoUtil.getAdvertise().update(daoAdvertise)
|
DaoUtil.getAdvertise().update(daoAdvertise)
|
||||||
schedules.forEach {
|
schedules.forEach {
|
||||||
val list = kotlin.collections.ArrayList<Int>()
|
val list = kotlin.collections.ArrayList<Int>()
|
||||||
"重启了,重新开启分时段播放任务:${newAdvertise.ad_id},week_day:${it.weekDayString}".loge()
|
"重启了,重新开启分时段播放任务:${newAdvertise.ad_id},week_day:${it.weekDayString}".loge()
|
||||||
for (s in it.weekDayString.split(",")) {
|
for (s in it.weekDayString.split(",")) {
|
||||||
list.add(s.toInt())
|
list.add(s.toInt())
|
||||||
|
}
|
||||||
|
it.week_day = list
|
||||||
|
}
|
||||||
|
newAdvertise.time_section = schedules
|
||||||
|
taxiApp.activity?.getViewModel()?.addTimer(newAdvertise)
|
||||||
}
|
}
|
||||||
it.week_day = list
|
|
||||||
}
|
}
|
||||||
newAdvertise.time_section = schedules
|
|
||||||
taxiApp.activity?.getViewModel()?.addTimer(newAdvertise)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newAdvertise.isAllowPlay()) {
|
if (newAdvertise.isAllowPlay()) {
|
||||||
//#edit by ljh @2023/2/23 myListMap集合只存放不是定时插播的广告
|
//#edit by ljh @2023/2/23 myListMap集合只存放不是定时插播的广告
|
||||||
if (!newAdvertise.isTimedAd){
|
if (!newAdvertise.isTimedAd){
|
||||||
"广告准备ok 加入Mylist 广告ad_id:${newAdvertise.ad_id},是否是最后一个广告:${newAdvertise.isLast},belongto: ${newAdvertise.belongTo}".loge("Repository")
|
"广告准备ok 加入Mylist 广告ad_id:${newAdvertise.ad_id},是否是最后一个广告:${newAdvertise.isLast},belongto: ${newAdvertise.belongTo}".loge("Repository")
|
||||||
myListMap[newAdvertise.belongTo]?.add(newAdvertise)
|
myListMap[newAdvertise.belongTo]?.add(newAdvertise)
|
||||||
} else if(isTimedAdNow && newAdvertise.isTimedAd && newAdvertise.is_exclusive) {
|
} else if(isTimedAdNow && newAdvertise.isTimedAd && newAdvertise.is_exclusive) {
|
||||||
taxiApp.timedAds.forEach {
|
taxiApp.timedAds.forEach {
|
||||||
if (it.ad_id == newAdvertise.ad_id){
|
if (it.ad_id == newAdvertise.ad_id){
|
||||||
taxiApp.timedAds.remove(it)
|
taxiApp.timedAds.remove(it)
|
||||||
taxiApp.timedAds.add(newAdvertise)
|
taxiApp.timedAds.add(newAdvertise)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
// "广告准备ok 加入Mylist 广告ad_id:${newAdvertise.ad_id},是否是最后一个广告:${newAdvertise.isLast},belongto: ${newAdvertise.belongTo}".loge("Repository")
|
// "广告准备ok 加入Mylist 广告ad_id:${newAdvertise.ad_id},是否是最后一个广告:${newAdvertise.isLast},belongto: ${newAdvertise.belongTo}".loge("Repository")
|
||||||
// myListMap[newAdvertise.belongTo]?.add(newAdvertise)
|
// myListMap[newAdvertise.belongTo]?.add(newAdvertise)
|
||||||
} else {
|
} else {
|
||||||
YoungUtil.YoungLog("广告不满足不加入播放列表:${newAdvertise.ad_id}")
|
YoungUtil.YoungLog("广告不满足不加入播放列表:${newAdvertise.ad_id}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
daoAdvertises?.let {
|
||||||
|
if (it.isClosed){
|
||||||
|
"close daoAdvertises".logd()
|
||||||
|
it.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val last = System.currentTimeMillis()
|
}
|
||||||
//YoungUtil.YoungLog("刷新列表用时${last - currentTimeMillis}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun oldAdvertiseToNewAdvertise(oldAdvertise: Advertise): Advertise {
|
private fun oldAdvertiseToNewAdvertise(oldAdvertise: Advertise): Advertise {
|
||||||
|
@ -554,7 +540,7 @@ object Repository {
|
||||||
//广告位置设置为0并刷新播放的列表
|
//广告位置设置为0并刷新播放的列表
|
||||||
currentListOrder = 0
|
currentListOrder = 0
|
||||||
refreshMyList()
|
refreshMyList()
|
||||||
"sync:${Configurations.config(TaxiApp.instance()).sync()}".loge()
|
// "sync:${Configurations.config(TaxiApp.instance()).sync()}".loge()
|
||||||
if (Configurations.config(TaxiApp.instance()).sync() && getTestPlayLevels() == AdvertiseType.GROUP.ordinal) {
|
if (Configurations.config(TaxiApp.instance()).sync() && getTestPlayLevels() == AdvertiseType.GROUP.ordinal) {
|
||||||
//设置同步播放并且是分组广告
|
//设置同步播放并且是分组广告
|
||||||
// if (Settings.sync) {
|
// if (Settings.sync) {
|
||||||
|
|
|
@ -165,6 +165,23 @@ object DaoUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除过期广告
|
||||||
|
*/
|
||||||
|
@Synchronized
|
||||||
|
fun deleteByPositionAdvertise(advertise: PositionAdvertise) {
|
||||||
|
getPositionAdvertise().queryBuilder().where(PositionAdvertiseDao.Properties.Task_id.eq(advertise.task_id)).buildDelete().executeDeleteWithoutDetachingEntities()
|
||||||
|
getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(advertise.task_id)).buildDelete().executeDeleteWithoutDetachingEntities()
|
||||||
|
getRegion().queryBuilder().where(RegionsDao.Properties.RegionAdId.eq(advertise.task_id)).buildDelete().executeDeleteWithoutDetachingEntities()
|
||||||
|
getAdvertise().queryBuilder().where(AdvertiseDao.Properties.Ad_id.eq(advertise.task_id)).buildDelete().executeDeleteWithoutDetachingEntities()
|
||||||
|
if (null != advertise.pathName) {
|
||||||
|
val file = File(advertise.pathName)
|
||||||
|
if (file.exists()) {
|
||||||
|
file.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新广告数据
|
* 更新广告数据
|
||||||
* @param advertise Advertise
|
* @param advertise Advertise
|
||||||
|
|
|
@ -17,12 +17,12 @@ class GpsReceiver : BroadcastReceiver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
if (intent.action =="com.xixun.joey.gpsinfo"){
|
if (intent.action == "com.xixun.joey.gpsinfo"){
|
||||||
//经度
|
|
||||||
val lat = intent.getDoubleExtra("latitude", 0.0);
|
|
||||||
//纬度
|
//纬度
|
||||||
|
val lat = intent.getDoubleExtra("latitude", 0.0);
|
||||||
|
//经度
|
||||||
val lng = intent.getDoubleExtra("longitude", 0.0);
|
val lng = intent.getDoubleExtra("longitude", 0.0);
|
||||||
"收到gps坐标广播信息:经度:$lat,纬度:$lng".loge()
|
"收到gps坐标广播信息:纬度:$lat,经度:$lng".loge()
|
||||||
val satelliteNumber = intent.getIntExtra("satelliteNumber", 0);
|
val satelliteNumber = intent.getIntExtra("satelliteNumber", 0);
|
||||||
val speed = intent.getFloatExtra("speed", 0f)
|
val speed = intent.getFloatExtra("speed", 0f)
|
||||||
//YoungUtil.YoungLog("广播接收坐标信息:lat:$lat,lng:$lng,satell:$satelliteNumber,speed:$speed")
|
//YoungUtil.YoungLog("广播接收坐标信息:lat:$lat,lng:$lng,satell:$satelliteNumber,speed:$speed")
|
||||||
|
|
|
@ -21,9 +21,6 @@ public class Location implements Serializable {
|
||||||
private Long elapse;
|
private Long elapse;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Generated(hash = 2055779998)
|
@Generated(hash = 2055779998)
|
||||||
public Location(Long id, Long timestamp, Double longitude, Double latitude,
|
public Location(Long id, Long timestamp, Double longitude, Double latitude,
|
||||||
Float speed, Float bearing, Float distance, Long elapse) {
|
Float speed, Float bearing, Float distance, Long elapse) {
|
||||||
|
@ -40,10 +37,6 @@ public class Location implements Serializable {
|
||||||
public Location() {
|
public Location() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.io.Serializable;
|
||||||
/**
|
/**
|
||||||
* Created by joey on 17-12-19.
|
* Created by joey on 17-12-19.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class PlayLogger implements Serializable {
|
public class PlayLogger implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -16,8 +16,6 @@ public class Regions {
|
||||||
private int radius;
|
private int radius;
|
||||||
private boolean isInRegion=false;
|
private boolean isInRegion=false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Generated(hash = 343985898)
|
@Generated(hash = 343985898)
|
||||||
public Regions(Long autoId, String id, String RegionAdId, double lat,
|
public Regions(Long autoId, String id, String RegionAdId, double lat,
|
||||||
double lng, int price, int radius, boolean isInRegion) {
|
double lng, int price, int radius, boolean isInRegion) {
|
||||||
|
@ -34,8 +32,6 @@ public class Regions {
|
||||||
public Regions() {
|
public Regions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Long getAutoId() {
|
public Long getAutoId() {
|
||||||
return this.autoId;
|
return this.autoId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -377,83 +377,74 @@ object ConnManger {
|
||||||
* 发送坐标
|
* 发送坐标
|
||||||
*/
|
*/
|
||||||
fun sendLocation() {
|
fun sendLocation() {
|
||||||
KuroExecutor.execute(Runnable {
|
YoungUtil.YoungLog("sendLocation in MainThread is ${Looper.getMainLooper().thread === Thread.currentThread()}")
|
||||||
YoungUtil.YoungLog("sendLocation in MainThread is ${Looper.getMainLooper().thread === Thread.currentThread()}")
|
//todo 如果这里突然有大量的信息序列化是不是同样会内存溢出
|
||||||
//todo 如果这里突然有大量的信息序列化是不是同样会内存溢出
|
// val locations = DaoUtil.getLocations()
|
||||||
val locations = DaoUtil.getLocations()
|
//edit by ljh @2023/8/8 每次只查20条定点数据,防止数据量大导致内存爆满
|
||||||
// for (location in locations) {
|
val locations = DaoUtil.getLocationDao().queryBuilder().limit(20).list()
|
||||||
// if (TimeUtil.isExpiredTime(location.timestamp,3)){
|
|
||||||
// YoungUtil.YoungLog("sendLocation 存在超过7天的日志,清除:${location.id}")
|
|
||||||
// DaoUtil.getLocationDao().delete(location)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (locations.isNotEmpty()) {
|
if (locations.isNotEmpty()) {
|
||||||
val requestJson: String = if (locations.size < 20) {
|
val requestJson: String = if (locations.size < 20) {
|
||||||
ProcessingCommands.gson.toJson(locations)
|
ProcessingCommands.gson.toJson(locations)
|
||||||
} else {
|
} else {
|
||||||
ProcessingCommands.gson.toJson(locations.subList(0, 19))
|
ProcessingCommands.gson.toJson(locations.subList(0, 19))
|
||||||
|
}
|
||||||
|
|
||||||
|
val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
|
||||||
|
val body = RequestBody.create(parse, requestJson)
|
||||||
|
|
||||||
|
val okHttpClient = OkHttpClient()
|
||||||
|
//YoungUtil.YoungLog("准备上传坐标,上传地址:${SaveSimpleData.getLogServiceUrl()}")
|
||||||
|
YoungUtil.YoungLog("准备上传坐标")
|
||||||
|
YoungUtil.YoungLog("sendLocation:${requestJson}")
|
||||||
|
val request: Request = Request.Builder()
|
||||||
|
.url(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postGpsLocationLog") //要访问的链接
|
||||||
|
.addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
|
.post(body)
|
||||||
|
.build()
|
||||||
|
val call = okHttpClient.newCall(request)
|
||||||
|
call.enqueue(object : Callback {
|
||||||
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
|
YoungUtil.YoungLog("上传坐标失败:${e.message}")
|
||||||
|
DaoUtil.getLocationDao().deleteAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
|
override fun onResponse(call: Call, response: Response) {
|
||||||
val body = RequestBody.create(parse, requestJson)
|
YoungUtil.YoungLog("上传坐标成功:${response.message},response is Sussceful ${response.isSuccessful}${response.code}")
|
||||||
|
if (response.code == 200) {
|
||||||
val okHttpClient = OkHttpClient()
|
if (locations.size < 20) {
|
||||||
//YoungUtil.YoungLog("准备上传坐标,上传地址:${SaveSimpleData.getLogServiceUrl()}")
|
DaoUtil.getLocationDao().deleteAll()
|
||||||
YoungUtil.YoungLog("准备上传坐标")
|
} else {
|
||||||
YoungUtil.YoungLog("sendLocation:${requestJson}")
|
for (index in 0..19) {
|
||||||
val request: Request = Request.Builder()
|
DaoUtil.getLocationDao().delete(locations[index])
|
||||||
.url(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postGpsLocationLog") //要访问的链接
|
|
||||||
.addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
|
|
||||||
.post(body)
|
|
||||||
.build()
|
|
||||||
val call = okHttpClient.newCall(request)
|
|
||||||
call.enqueue(object : Callback {
|
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
|
||||||
YoungUtil.YoungLog("上传坐标失败:${e.message}")
|
|
||||||
DaoUtil.getLocationDao().deleteAll()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResponse(call: Call, response: Response) {
|
|
||||||
YoungUtil.YoungLog("上传坐标成功:${response.message},response is Sussceful ${response.isSuccessful}${response.code}")
|
|
||||||
if (response.code == 200) {
|
|
||||||
if (locations.size < 20) {
|
|
||||||
DaoUtil.getLocationDao().deleteAll()
|
|
||||||
} else {
|
|
||||||
for (index in 0..19) {
|
|
||||||
DaoUtil.getLocationDao().delete(locations[index])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
//edit by yzd @20211201
|
|
||||||
//if (Settings.gpsSwitch) {
|
})
|
||||||
if (Configurations.config(TaxiApp.instance()).gpsSwitch()) {
|
}
|
||||||
|
//edit by yzd @20211201
|
||||||
|
//if (Settings.gpsSwitch) {
|
||||||
|
if (Configurations.config(TaxiApp.instance()).gpsSwitch()) {
|
||||||
// "gpsSwitch on".loge()
|
// "gpsSwitch on".loge()
|
||||||
val timer = KuroTimer()
|
val timer = KuroTimer()
|
||||||
timer.schedule(object : KuroTimerTask() {
|
timer.schedule(object : KuroTimerTask() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
sendLocation()
|
sendLocation()
|
||||||
}
|
}
|
||||||
}, 10000)
|
}, 10000)
|
||||||
} else {
|
} else {
|
||||||
"gpsSwitch off".loge()
|
"gpsSwitch off".loge()
|
||||||
val timer = KuroTimer()
|
val timer = KuroTimer()
|
||||||
timer.schedule(object : KuroTimerTask() {
|
timer.schedule(object : KuroTimerTask() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
sendLocation()
|
sendLocation()
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 60 * 60 * 1000)
|
}, 60 * 60 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DelayTimer.timer({ sendLocation() }, 10000)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -578,45 +569,37 @@ object ConnManger {
|
||||||
//edit by yzd @20211201
|
//edit by yzd @20211201
|
||||||
//if (Settings.loggerSwitch) {
|
//if (Settings.loggerSwitch) {
|
||||||
if (Configurations.config(TaxiApp.instance()).loggerSwitch()) {
|
if (Configurations.config(TaxiApp.instance()).loggerSwitch()) {
|
||||||
ThreadUtil.executeBySingleThread2(Runnable {
|
YoungUtil.YoungLog("sendLogger in Thread is ${Looper.getMainLooper().thread === Thread.currentThread()}")
|
||||||
YoungUtil.YoungLog("sendLogger in Thread is ${Looper.getMainLooper().thread === Thread.currentThread()}")
|
val playLoggers = DaoUtil.getPlayLoggers()
|
||||||
val playLoggers = DaoUtil.getPlayLoggers()
|
if (playLoggers.isNotEmpty()) {
|
||||||
// for (playLogger in playLoggers) {
|
val requestJson: String = if (playLoggers.size < 20) {
|
||||||
// if (TimeUtil.isExpiredTime(playLogger.created_at,3)){
|
ProcessingCommands.gson.toJson(playLoggers)
|
||||||
// YoungUtil.YoungLog("sendLogger 存在超过7天的日志,清除:${playLogger.ad_id}")
|
} else {
|
||||||
// DaoUtil.getPlayLogger().delete(playLogger)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
if (playLoggers.isNotEmpty()) {
|
|
||||||
val requestJson: String = if (playLoggers.size < 20) {
|
|
||||||
ProcessingCommands.gson.toJson(playLoggers)
|
|
||||||
} else {
|
|
||||||
// ProcessingCommands.gson.toJson(playLoggers.subList(0, 19))
|
// ProcessingCommands.gson.toJson(playLoggers.subList(0, 19))
|
||||||
//#edit by ljh @2023/6/5 改成大批量看是否能减小流量消耗
|
//#edit by ljh @2023/6/5 改成大批量看是否能减小流量消耗
|
||||||
ProcessingCommands.gson.toJson(playLoggers)
|
ProcessingCommands.gson.toJson(playLoggers)
|
||||||
|
}
|
||||||
|
|
||||||
|
val okHttpClient = OkHttpClient()
|
||||||
|
YoungUtil.YoungLog("准备上传日志")
|
||||||
|
val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
|
||||||
|
val body = RequestBody.create(parse, requestJson)
|
||||||
|
YoungUtil.YoungLog("sendLogger:${requestJson}")
|
||||||
|
val request: Request = Request.Builder()
|
||||||
|
.url(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postPlayerLog") //要访问的链接
|
||||||
|
.addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
|
.addHeader("Accept-Encoding", "gzip")
|
||||||
|
.post(body)
|
||||||
|
.build()
|
||||||
|
val call = okHttpClient.newCall(request)
|
||||||
|
call.enqueue(object : Callback {
|
||||||
|
|
||||||
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
|
YoungUtil.YoungLog("上传日志失败:${e.message}")
|
||||||
}
|
}
|
||||||
|
|
||||||
val okHttpClient = OkHttpClient()
|
override fun onResponse(call: Call, response: Response) {
|
||||||
YoungUtil.YoungLog("准备上传日志")
|
YoungUtil.YoungLog("上传日志成功:${response.message},response isSuccessful ${response.isSuccessful}${response.code}")
|
||||||
val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull()
|
|
||||||
val body = RequestBody.create(parse, requestJson)
|
|
||||||
YoungUtil.YoungLog("sendLogger:${requestJson}")
|
|
||||||
val request: Request = Request.Builder()
|
|
||||||
.url(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postPlayerLog") //要访问的链接
|
|
||||||
.addHeader("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}")
|
|
||||||
.addHeader("Accept-Encoding", "gzip")
|
|
||||||
.post(body)
|
|
||||||
.build()
|
|
||||||
val call = okHttpClient.newCall(request)
|
|
||||||
call.enqueue(object : Callback {
|
|
||||||
|
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
|
||||||
YoungUtil.YoungLog("上传日志失败:${e.message}")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResponse(call: Call, response: Response) {
|
|
||||||
YoungUtil.YoungLog("上传日志成功:${response.message},response isSuccessful ${response.isSuccessful}${response.code}")
|
|
||||||
// if (response.code == 200) {
|
// if (response.code == 200) {
|
||||||
// if (playLoggers.size < 20) {
|
// if (playLoggers.size < 20) {
|
||||||
// DaoUtil.getPlayLogger().deleteAll()
|
// DaoUtil.getPlayLogger().deleteAll()
|
||||||
|
@ -627,26 +610,25 @@ object ConnManger {
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
//#edit by ljh @2023/2/21
|
//#edit by ljh @2023/2/21
|
||||||
// playLoggers.forEach{
|
// playLoggers.forEach{
|
||||||
// DaoUtil.getPlayLogger().delete(it)
|
// DaoUtil.getPlayLogger().delete(it)
|
||||||
// }
|
// }
|
||||||
//#edit by ljh @2023/6/5 删除批量上传的日志
|
//#edit by ljh @2023/6/5 删除批量上传的日志
|
||||||
DaoUtil.getPlayLogger().deleteAll()
|
DaoUtil.getPlayLogger().deleteAll()
|
||||||
}
|
|
||||||
"删除已上传的日志".logd()
|
|
||||||
}
|
}
|
||||||
})
|
"删除已上传的日志".logd()
|
||||||
}
|
|
||||||
|
|
||||||
val timer = KuroTimer()
|
|
||||||
timer.schedule(object : KuroTimerTask() {
|
|
||||||
override fun run() {
|
|
||||||
sendLogger()
|
|
||||||
}
|
}
|
||||||
}, 30000)
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
|
val timer = KuroTimer()
|
||||||
|
timer.schedule(object : KuroTimerTask() {
|
||||||
|
override fun run() {
|
||||||
|
sendLogger()
|
||||||
|
}
|
||||||
|
}, 30000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,6 +710,10 @@ object ConnManger {
|
||||||
//2022-0620by yzd修复一个bug:下面这行如果不注释,导致切换凭证的时候如果taxibaseUrl没变,setConnServiceUrl就不会被调用,使得conn不会切换服务地址
|
//2022-0620by yzd修复一个bug:下面这行如果不注释,导致切换凭证的时候如果taxibaseUrl没变,setConnServiceUrl就不会被调用,使得conn不会切换服务地址
|
||||||
//if (accountId != Configurations.config(TaxiApp.instance()).accountId() || bindModel.server != Configurations.config(TaxiApp.instance()).taxiBaseUrl()) {
|
//if (accountId != Configurations.config(TaxiApp.instance()).accountId() || bindModel.server != Configurations.config(TaxiApp.instance()).taxiBaseUrl()) {
|
||||||
//Settings.accountId = accountId
|
//Settings.accountId = accountId
|
||||||
|
val currentRegisterToken = Configurations.config(TaxiApp.instance()).registerToken()
|
||||||
|
//#edit by ljh @2023/7/20
|
||||||
|
//token不一样再去重新注册,连接
|
||||||
|
if (!currentRegisterToken.equals(bindModel.accountIdToken)){
|
||||||
Configurations.config(TaxiApp.instance()).accountIdSave(accountId)
|
Configurations.config(TaxiApp.instance()).accountIdSave(accountId)
|
||||||
//不等说明账户更换,重新连接
|
//不等说明账户更换,重新连接
|
||||||
resetAccountCleanDao()
|
resetAccountCleanDao()
|
||||||
|
@ -744,27 +730,11 @@ object ConnManger {
|
||||||
reconnect(1003,"切换账户关闭连接")
|
reconnect(1003,"切换账户关闭连接")
|
||||||
|
|
||||||
YoungUtil.YoungLog("用户不同,账号重新绑定")
|
YoungUtil.YoungLog("用户不同,账号重新绑定")
|
||||||
//}
|
//}
|
||||||
/*
|
YoungUtil.YoungLog("账号绑定完成")
|
||||||
if (accountId != Settings.accountId || bindModel.server != Settings.taxiBaseUrl) {
|
//Settings.registerToken = bindModel.accountIdToken
|
||||||
Settings.accountId = accountId
|
Configurations.config(TaxiApp.instance()).registerTokenSave(bindModel.accountIdToken)
|
||||||
//不等说明账户更换,重新连接
|
|
||||||
resetAccountCleanDao()
|
|
||||||
Settings.registerToken = bindModel.accountIdToken
|
|
||||||
|
|
||||||
if (bindModel.server != null && bindModel.server != "") {
|
|
||||||
Settings.taxiBaseUrl = bindModel.server
|
|
||||||
setConnServiceUrl(bindModel.server)
|
|
||||||
}
|
|
||||||
|
|
||||||
reconnect(1003,"切换账户关闭连接")
|
|
||||||
|
|
||||||
YoungUtil.YoungLog("用户不同,账号重新绑定")
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
YoungUtil.YoungLog("账号绑定完成")
|
|
||||||
//Settings.registerToken = bindModel.accountIdToken
|
|
||||||
Configurations.config(TaxiApp.instance()).registerTokenSave(bindModel.accountIdToken)
|
|
||||||
listener.onSuccess("true")
|
listener.onSuccess("true")
|
||||||
} catch (e: RemoteException) {
|
} catch (e: RemoteException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|
|
@ -216,11 +216,8 @@ public class JoeyDownloadManager {
|
||||||
advertise.setDuration(String.valueOf(videoDuration));
|
advertise.setDuration(String.valueOf(videoDuration));
|
||||||
}
|
}
|
||||||
DaoUtil.INSTANCE.getAdvertise().update(advertise);
|
DaoUtil.INSTANCE.getAdvertise().update(advertise);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AdvertiseProcess advertiseProcess =new AdvertiseProcess();
|
AdvertiseProcess advertiseProcess =new AdvertiseProcess();
|
||||||
advertiseProcess.setAd_id(task.getTag().toString());
|
advertiseProcess.setAd_id(task.getTag().toString());
|
||||||
advertiseProcess.setProgress(String.valueOf(100));
|
advertiseProcess.setProgress(String.valueOf(100));
|
||||||
|
@ -230,7 +227,7 @@ public class JoeyDownloadManager {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RefreshPlayer.refresh();
|
RefreshPlayer.refresh();
|
||||||
} catch (InterruptedException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +303,7 @@ public class JoeyDownloadManager {
|
||||||
int progress = (int)(((float)soFarBytes/ (float) totalBytes)*100);
|
int progress = (int)(((float)soFarBytes/ (float) totalBytes)*100);
|
||||||
if(soFarBytes >= totalBytes){
|
if(soFarBytes >= totalBytes){
|
||||||
try{
|
try{
|
||||||
Thread.sleep(1000);
|
Thread.sleep(500);
|
||||||
}catch (Exception e){}
|
}catch (Exception e){}
|
||||||
AdvertiseProcess advertiseProcess =new AdvertiseProcess();
|
AdvertiseProcess advertiseProcess =new AdvertiseProcess();
|
||||||
advertiseProcess.setAd_id(task.getTag().toString());
|
advertiseProcess.setAd_id(task.getTag().toString());
|
||||||
|
@ -314,6 +311,10 @@ public class JoeyDownloadManager {
|
||||||
String progressJson = new Gson().toJson(advertiseProcess);
|
String progressJson = new Gson().toJson(advertiseProcess);
|
||||||
YoungUtil.YoungLog("广告:"+task.getTag().toString()+",下载完成进度100");
|
YoungUtil.YoungLog("广告:"+task.getTag().toString()+",下载完成进度100");
|
||||||
WsManager.INSTANCE.send(progressJson);
|
WsManager.INSTANCE.send(progressJson);
|
||||||
|
try{
|
||||||
|
Thread.sleep(500);
|
||||||
|
}catch (Exception e){}
|
||||||
|
WsManager.INSTANCE.send(progressJson);
|
||||||
}
|
}
|
||||||
// if (progress%5==0){
|
// if (progress%5==0){
|
||||||
// AdvertiseProcess advertiseProcess =new AdvertiseProcess();
|
// AdvertiseProcess advertiseProcess =new AdvertiseProcess();
|
||||||
|
|
|
@ -18,6 +18,7 @@ import cn.trans88.taxiappkotlin.logic.network.ConnManger.reconnect
|
||||||
import cn.trans88.taxiappkotlin.logic.network.WsManager.send
|
import cn.trans88.taxiappkotlin.logic.network.WsManager.send
|
||||||
import cn.trans88.taxiappkotlin.play.RefreshPlayer
|
import cn.trans88.taxiappkotlin.play.RefreshPlayer
|
||||||
import cn.trans88.taxiappkotlin.ui.advertise.AdvertiseType
|
import cn.trans88.taxiappkotlin.ui.advertise.AdvertiseType
|
||||||
|
import cn.trans88.taxiappkotlin.ui.play.isOverdue
|
||||||
import cn.trans88.taxiappkotlin.util.YoungUtil
|
import cn.trans88.taxiappkotlin.util.YoungUtil
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.JsonParser
|
import com.google.gson.JsonParser
|
||||||
|
@ -31,6 +32,8 @@ object ProcessingCommands {
|
||||||
val gson = Gson()
|
val gson = Gson()
|
||||||
var beatTimer:Timer? = null
|
var beatTimer:Timer? = null
|
||||||
|
|
||||||
|
var areaIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 三乐平台的命令
|
* 三乐平台的命令
|
||||||
*/
|
*/
|
||||||
|
@ -66,13 +69,13 @@ object ProcessingCommands {
|
||||||
// //发送真正播放的广告列表
|
// //发送真正播放的广告列表
|
||||||
// "get_play_ad_list"->sendPlayAdvertiseInfo(task,baseTask.type)
|
// "get_play_ad_list"->sendPlayAdvertiseInfo(task,baseTask.type)
|
||||||
//发送收到所有广告的adid
|
//发送收到所有广告的adid
|
||||||
"get_ad_list"->sendAllAdvertiseInfo(task,baseTask.type)
|
"get_ad_list" -> sendAllAdvertiseInfo(task,baseTask.type)
|
||||||
//发送广告排序给服务器
|
//发送广告排序给服务器
|
||||||
"get_advertise_order"-> sendOrderInfo(task,baseTask.type)
|
"get_advertise_order" -> sendOrderInfo(task,baseTask.type)
|
||||||
"update_player_log_switch"->playLoggerSwitch(task,baseTask.type)
|
"update_player_log_switch" -> playLoggerSwitch(task,baseTask.type)
|
||||||
"update_gps_log_switch"->gpsSwitch(task,baseTask.type)
|
"update_gps_log_switch" -> gpsSwitch(task,baseTask.type)
|
||||||
"get_log_file_list"->getLogFilesAllName(task,baseTask.type)
|
"get_log_file_list" -> getLogFilesAllName(task,baseTask.type)
|
||||||
"beat_reply"->beatCheck(task,baseTask.type)
|
"beat_reply" -> beatCheck(task,baseTask.type)
|
||||||
else -> YoungUtil.YoungLog("三乐 未知命令")
|
else -> YoungUtil.YoungLog("三乐 未知命令")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -222,38 +225,45 @@ object ProcessingCommands {
|
||||||
private fun sendAllAdvertiseInfo(task: String, type: String) {
|
private fun sendAllAdvertiseInfo(task: String, type: String) {
|
||||||
val baseResponse = gson.fromJson<BaseResponse>(task)
|
val baseResponse = gson.fromJson<BaseResponse>(task)
|
||||||
|
|
||||||
|
val positionAdvertises = DaoUtil.getPositionAdvertise().loadAll()
|
||||||
val advertises = DaoUtil.getSanleAdvertise().loadAll()
|
val advertises = DaoUtil.getSanleAdvertise().loadAll()
|
||||||
//edit by ljh @2022/12/13 播放列表按创建日期排序
|
//edit by ljh @2022/12/13 播放列表按创建日期排序
|
||||||
advertises.sortBy {
|
advertises.sortBy {
|
||||||
it.createAt
|
it.createAt
|
||||||
}
|
}
|
||||||
val allAdIds = mutableListOf<String>()
|
val allAdIds = mutableListOf<String>()
|
||||||
|
if (positionAdvertises.size > 0){
|
||||||
|
for (positionAdvertise in positionAdvertises) {
|
||||||
|
positionAdvertise.isOverdue()
|
||||||
|
}
|
||||||
|
val positionAds = DaoUtil.getPositionAdvertise().loadAll()
|
||||||
|
positionAds.forEach {
|
||||||
|
allAdIds.add(it.task_id)
|
||||||
|
}
|
||||||
|
"positionAds:$positionAds".logd()
|
||||||
|
}
|
||||||
advertises.forEach {
|
advertises.forEach {
|
||||||
allAdIds.add(it.task_id)
|
allAdIds.add(it.task_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
val positionAdvertises = DaoUtil.getPositionAdvertise().loadAll()
|
|
||||||
positionAdvertises.forEach {
|
|
||||||
allAdIds.add(it.task_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
val playList = Repository.getTestPlayCircularList()
|
val playList = Repository.getTestPlayCircularList()
|
||||||
// val advertises = DaoUtil.getAdvertises()
|
// val advertises = DaoUtil.getAdvertises()
|
||||||
var currentPlayList = mutableListOf<String>()
|
var currentPlayList = playList?.map {
|
||||||
playList?.forEach {
|
it.ad_id
|
||||||
currentPlayList.add(it.ad_id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val playAdvertiseModel = PlayAdvertiseModel()
|
val playAdvertiseModel = PlayAdvertiseModel()
|
||||||
playAdvertiseModel.task_id = baseResponse.task_id
|
playAdvertiseModel.task_id = baseResponse.task_id
|
||||||
playAdvertiseModel.id = baseResponse.id
|
playAdvertiseModel.id = baseResponse.id
|
||||||
playAdvertiseModel.type = type
|
playAdvertiseModel.type = type
|
||||||
playAdvertiseModel.ad_list =allAdIds
|
playAdvertiseModel.ad_list = allAdIds
|
||||||
playAdvertiseModel.current_play_list =currentPlayList
|
playAdvertiseModel.current_play_list = currentPlayList
|
||||||
|
|
||||||
YoungUtil.YoungLog("当前卡内所有广告")
|
|
||||||
|
|
||||||
|
// YoungUtil.YoungLog("当前卡内正在播的广告:$playList")
|
||||||
|
// "currentPlayList:$currentPlayList".logd()
|
||||||
val response = gson.toJson(playAdvertiseModel)
|
val response = gson.toJson(playAdvertiseModel)
|
||||||
|
// "responseJson: $response".logd()
|
||||||
send(response)
|
send(response)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -300,7 +310,9 @@ object ProcessingCommands {
|
||||||
//#edit by ljh @2023/3/28
|
//#edit by ljh @2023/3/28
|
||||||
//如果传的media_id为空,则取消屏幕的自定义显示
|
//如果传的media_id为空,则取消屏幕的自定义显示
|
||||||
if (busInfo.media_id.isNullOrEmpty()){
|
if (busInfo.media_id.isNullOrEmpty()){
|
||||||
|
Configurations.config(TaxiApp.instance()).isCustomLogoSave(false)
|
||||||
taxiApp.activity?.cancelCustomView()
|
taxiApp.activity?.cancelCustomView()
|
||||||
|
saveBackgroundType(false)
|
||||||
} else {
|
} else {
|
||||||
when (busInfo.background_type) {
|
when (busInfo.background_type) {
|
||||||
"route" -> {
|
"route" -> {
|
||||||
|
@ -336,6 +348,7 @@ object ProcessingCommands {
|
||||||
downloadBusInfo(busInfo.media_id, "booked", MAIDIER)
|
downloadBusInfo(busInfo.media_id, "booked", MAIDIER)
|
||||||
}
|
}
|
||||||
"logo" -> {
|
"logo" -> {
|
||||||
|
Configurations.config(TaxiApp.instance()).isCustomLogoSave(true)
|
||||||
saveBackgroundType(true)
|
saveBackgroundType(true)
|
||||||
downloadBusInfo(busInfo.media_id, "logo", XIXUN)
|
downloadBusInfo(busInfo.media_id, "logo", XIXUN)
|
||||||
}
|
}
|
||||||
|
@ -372,7 +385,8 @@ object ProcessingCommands {
|
||||||
* @param type String
|
* @param type String
|
||||||
*/
|
*/
|
||||||
fun saveBackgroundType(isLogo: Boolean){
|
fun saveBackgroundType(isLogo: Boolean){
|
||||||
val gson = Gson()
|
val taxiApp = TaxiApp.instance() as TaxiApp
|
||||||
|
val gson = taxiApp.gson
|
||||||
val backgroundTypeJson = Configurations.config(TaxiApp.instance()).backgroundType()
|
val backgroundTypeJson = Configurations.config(TaxiApp.instance()).backgroundType()
|
||||||
val backgroundType = if (backgroundTypeJson.isNotEmpty()){
|
val backgroundType = if (backgroundTypeJson.isNotEmpty()){
|
||||||
gson.fromJson<BackgroundType>(backgroundTypeJson)
|
gson.fromJson<BackgroundType>(backgroundTypeJson)
|
||||||
|
@ -494,7 +508,7 @@ object ProcessingCommands {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除定点广告会同事删除和定点相关的区域、广告、时间、定点数据
|
* 删除定点广告会同时删除和定点相关的区域、广告、时间、定点数据
|
||||||
*/
|
*/
|
||||||
private fun deletePositionAdvertise(task: String,type: String) {
|
private fun deletePositionAdvertise(task: String,type: String) {
|
||||||
val advertises = DaoUtil.getPositionAdvertises()
|
val advertises = DaoUtil.getPositionAdvertises()
|
||||||
|
@ -534,6 +548,7 @@ object ProcessingCommands {
|
||||||
val positionAdvertise = gson.fromJson<PositionAdvertise>(task, PositionAdvertise::class.java)
|
val positionAdvertise = gson.fromJson<PositionAdvertise>(task, PositionAdvertise::class.java)
|
||||||
val advertises = DaoUtil.getPositionAdvertises()
|
val advertises = DaoUtil.getPositionAdvertises()
|
||||||
|
|
||||||
|
|
||||||
for(r in positionAdvertise.regions){
|
for(r in positionAdvertise.regions){
|
||||||
LogUtil.i("name:" + r.id + ", lng:" + r.lng + ", lat:" + r.lat);
|
LogUtil.i("name:" + r.id + ", lng:" + r.lng + ", lat:" + r.lat);
|
||||||
}
|
}
|
||||||
|
@ -559,7 +574,7 @@ object ProcessingCommands {
|
||||||
|
|
||||||
if (insert) {
|
if (insert) {
|
||||||
DaoUtil.getPositionAdvertise().insert(positionAdvertise)
|
DaoUtil.getPositionAdvertise().insert(positionAdvertise)
|
||||||
YoungUtil.YoungLog("添加一条定点广告")
|
YoungUtil.YoungLog("添加一条定点广告,${areaIndex++},adId:${positionAdvertise.task_id}")
|
||||||
positionAdvertise.time_span.forEach {
|
positionAdvertise.time_span.forEach {
|
||||||
it.advertiseId = positionAdvertise.task_id
|
it.advertiseId = positionAdvertise.task_id
|
||||||
DaoUtil.getTimeSpan().insert(it)
|
DaoUtil.getTimeSpan().insert(it)
|
||||||
|
|
|
@ -54,12 +54,9 @@ object WsManager {
|
||||||
YoungUtil.YoungLog("长连接进行连接的token:${Configurations.config(TaxiApp.instance()).appToken()}")
|
YoungUtil.YoungLog("长连接进行连接的token:${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
mRequest = Request.Builder()
|
mRequest = Request.Builder()
|
||||||
.url("${Configurations.config(TaxiApp.instance()).taxiServiceUrl()}?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}")
|
.url("${Configurations.config(TaxiApp.instance()).taxiServiceUrl()}?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
// .url("http://192.168.1.132:2347/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}")
|
// .url("http://192.168.1.127:2347/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
// .url("http://1vf5fnic.beesnat.com/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}")
|
// .url("http://1vf5fnic.beesnat.com/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
// .url("http://192.168.1.132:2347/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}")
|
// .url("http://192.168.43.191:2347/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}")
|
||||||
// .url("http://192.168.1.127:2347/?auth_token=${testToken}")
|
|
||||||
// .url("http://192.168.1.132:2347/?auth_token=${testToken}")
|
|
||||||
// .url("http://taxihub.cn:2347/?auth_token=${testToken}")
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
okHttpClient!!.newWebSocket(mRequest!!, object : WebSocketListener() {
|
okHttpClient!!.newWebSocket(mRequest!!, object : WebSocketListener() {
|
||||||
|
@ -169,6 +166,20 @@ object WsManager {
|
||||||
|
|
||||||
stopAllTimer()
|
stopAllTimer()
|
||||||
|
|
||||||
|
//#edit by ljh @2023/7/12
|
||||||
|
//检测之前连接是否存在,存在则主动断开掉
|
||||||
|
try {
|
||||||
|
if (mWebSocket != null) {
|
||||||
|
YoungUtil.YoungLog("closing bad connection: 连接异常,关闭此连接重连")
|
||||||
|
// mWebSocket!!.cancel()
|
||||||
|
val close = mWebSocket!!.close(1006, "连接异常,关闭此连接重连")
|
||||||
|
YoungUtil.YoungLog("webSocket是否正常关闭:$close")
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
YoungUtil.YoungLog("断开连接异常:${e.message}")
|
||||||
|
}
|
||||||
|
|
||||||
tryReconnectTimer = KuroTimer()
|
tryReconnectTimer = KuroTimer()
|
||||||
|
|
||||||
// val timer = KuroTimer()
|
// val timer = KuroTimer()
|
||||||
|
@ -243,8 +254,8 @@ object WsManager {
|
||||||
advertiseIdList.add(it.ad_id)
|
advertiseIdList.add(it.ad_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentPlayAdvertise =CurrentPlayAdvertises()
|
val currentPlayAdvertise = CurrentPlayAdvertises()
|
||||||
currentPlayAdvertise.currentPlayAdvertise =advertiseIdList
|
currentPlayAdvertise.currentPlayAdvertise = advertiseIdList
|
||||||
|
|
||||||
val currentAdvertises = Gson().toJson(currentPlayAdvertise)
|
val currentAdvertises = Gson().toJson(currentPlayAdvertise)
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,11 @@ import android.os.Build.VERSION
|
||||||
import android.os.Build.VERSION_CODES
|
import android.os.Build.VERSION_CODES
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import android.widget.ImageView
|
||||||
import android.widget.ImageView.ScaleType.FIT_XY
|
import android.widget.ImageView.ScaleType.FIT_XY
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.children
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import cn.trans88.taxiappkotlin.BootBroadcast
|
import cn.trans88.taxiappkotlin.BootBroadcast
|
||||||
|
@ -61,12 +63,14 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
||||||
|
|
||||||
private val netBroadcastReceiver = NetworkReceiver()//网络状态Receiver
|
private val netBroadcastReceiver = NetworkReceiver()//网络状态Receiver
|
||||||
private val busReceiver = BusReceiver()//豪胜公交Receiver
|
private val busReceiver = BusReceiver()//豪胜公交Receiver
|
||||||
private val gpsReceiver =GpsReceiver()//Gps信息Receiver
|
private val gpsReceiver = GpsReceiver()//Gps信息Receiver
|
||||||
|
|
||||||
private lateinit var playViewModel: PlayViewModel
|
private lateinit var playViewModel: PlayViewModel
|
||||||
|
|
||||||
val handler = MyHandler(this)
|
val handler = MyHandler(this)
|
||||||
|
|
||||||
|
val mainHandler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
//和conn连接的服务
|
//和conn连接的服务
|
||||||
private var connService: ConnService? = null
|
private var connService: ConnService? = null
|
||||||
|
|
||||||
|
@ -158,6 +162,19 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
||||||
startService(serverIntent)
|
startService(serverIntent)
|
||||||
//开机不管同步不同步直接先放
|
//开机不管同步不同步直接先放
|
||||||
//powerOnAdvertise(playViewModel)
|
//powerOnAdvertise(playViewModel)
|
||||||
|
|
||||||
|
//#edit by ljh @2023/7/19
|
||||||
|
//重启后30s查询是否有gps,没有gps信号清除定点广告
|
||||||
|
mainHandler.postDelayed({
|
||||||
|
playViewModel.initLocation()
|
||||||
|
|
||||||
|
playViewModel.apply {
|
||||||
|
if (mLocationManager == null || currentLocation == null || !isLocationEnabled){
|
||||||
|
clearAreaAdvertise()
|
||||||
|
}
|
||||||
|
mLocationManager?.removeUpdates(getLocationListener())
|
||||||
|
}
|
||||||
|
},30 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
//#edit by ljh 2023/2/16
|
//#edit by ljh 2023/2/16
|
||||||
|
@ -319,8 +336,66 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
||||||
* 取消自定义显示,路线、左转右转等..
|
* 取消自定义显示,路线、左转右转等..
|
||||||
*/
|
*/
|
||||||
fun cancelCustomView(){
|
fun cancelCustomView(){
|
||||||
|
YoungUtil.YoungLog("取消自定义显示,路线、左转右转等..")
|
||||||
|
|
||||||
ll_bus.visibility = View.GONE
|
ll_bus.visibility = View.GONE
|
||||||
img_other_screen.visibility = View.GONE
|
img_other_screen.visibility = View.GONE
|
||||||
|
|
||||||
|
fl_play.apply {
|
||||||
|
val logoView = this.findViewWithTag<View>("logo")
|
||||||
|
if (logoView != null) {
|
||||||
|
mainHandler.post {
|
||||||
|
showDefaultLogo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val program = File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program))
|
||||||
|
val logo = File(program, "logo")
|
||||||
|
val logoTemp = File(program, "logo.temp")
|
||||||
|
|
||||||
|
val busLicence = File(program, "busLicence")
|
||||||
|
val turnStop = File(program, "turnStop")
|
||||||
|
val turnLeft = File(program, "turnLeft")
|
||||||
|
val turnRight = File(program, "turnRight")
|
||||||
|
val vacant = File(program, "vacant")
|
||||||
|
val hired = File(program, "hired")
|
||||||
|
val noService = File(program, "no_service")
|
||||||
|
val booked = File(program, "booked")
|
||||||
|
|
||||||
|
if (logo.exists()) {
|
||||||
|
"删除logo文件".logd()
|
||||||
|
logo.delete()
|
||||||
|
}
|
||||||
|
if (logoTemp.exists()) {
|
||||||
|
"删除logotemp文件".logd()
|
||||||
|
logoTemp.delete()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (busLicence.exists()) {
|
||||||
|
busLicence.delete()
|
||||||
|
}
|
||||||
|
if (turnStop.exists()) {
|
||||||
|
turnStop.delete()
|
||||||
|
}
|
||||||
|
if (turnLeft.exists()) {
|
||||||
|
turnLeft.delete()
|
||||||
|
}
|
||||||
|
if (turnRight.exists()) {
|
||||||
|
turnRight.delete()
|
||||||
|
}
|
||||||
|
if (vacant.exists()) {
|
||||||
|
vacant.delete()
|
||||||
|
}
|
||||||
|
if (hired.exists()) {
|
||||||
|
hired.delete()
|
||||||
|
}
|
||||||
|
if (noService.exists()) {
|
||||||
|
noService.delete()
|
||||||
|
}
|
||||||
|
if (booked.exists()) {
|
||||||
|
booked.delete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,6 +502,9 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
||||||
handler.removeCallbacksAndMessages(null)
|
handler.removeCallbacksAndMessages(null)
|
||||||
// playViewModel.advertiseLiveData.removeObservers(this)
|
// playViewModel.advertiseLiveData.removeObservers(this)
|
||||||
playViewModel.playLiveData.removeObservers(this)
|
playViewModel.playLiveData.removeObservers(this)
|
||||||
|
|
||||||
|
playViewModel.mLocationManager?.removeUpdates(playViewModel.getLocationListener())
|
||||||
|
playViewModel.mLocationManager = null
|
||||||
// job.cancel()
|
// job.cancel()
|
||||||
//activity销毁时释放播放器
|
//activity销毁时释放播放器
|
||||||
// (TaxiApp.instance() as TaxiApp).player!!.release()
|
// (TaxiApp.instance() as TaxiApp).player!!.release()
|
||||||
|
@ -628,6 +706,13 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
||||||
//各种公司的定制view
|
//各种公司的定制view
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
YoungUtil.YoungLog("屏幕宽高变化 thread in ${isMainThread()}")
|
YoungUtil.YoungLog("屏幕宽高变化 thread in ${isMainThread()}")
|
||||||
|
fl_play.apply {
|
||||||
|
val logoView = this.findViewWithTag<View>("logo")
|
||||||
|
if (logoView != null) {
|
||||||
|
removeView(logoView)
|
||||||
|
playLogo()
|
||||||
|
}
|
||||||
|
}
|
||||||
customView()
|
customView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
|
import androidx.core.view.children
|
||||||
import cn.trans88.taxiappkotlin.Configurations
|
import cn.trans88.taxiappkotlin.Configurations
|
||||||
import cn.trans88.taxiappkotlin.R
|
import cn.trans88.taxiappkotlin.R
|
||||||
import cn.trans88.taxiappkotlin.R.string
|
import cn.trans88.taxiappkotlin.R.string
|
||||||
|
@ -25,14 +26,17 @@ import cn.trans88.taxiappkotlin.TaxiApp.Companion.HAOSHENG
|
||||||
import cn.trans88.taxiappkotlin.ext.logd
|
import cn.trans88.taxiappkotlin.ext.logd
|
||||||
import cn.trans88.taxiappkotlin.ext.loge
|
import cn.trans88.taxiappkotlin.ext.loge
|
||||||
import cn.trans88.taxiappkotlin.logic.model.Advertise
|
import cn.trans88.taxiappkotlin.logic.model.Advertise
|
||||||
|
import cn.trans88.taxiappkotlin.logic.model.BackgroundType
|
||||||
import cn.trans88.taxiappkotlin.logic.model.TextInfo
|
import cn.trans88.taxiappkotlin.logic.model.TextInfo
|
||||||
import cn.trans88.taxiappkotlin.ui.advertise.MaterialType
|
import cn.trans88.taxiappkotlin.ui.advertise.MaterialType
|
||||||
import cn.trans88.taxiappkotlin.ui.custom.JTextView
|
import cn.trans88.taxiappkotlin.ui.custom.JTextView
|
||||||
import cn.trans88.taxiappkotlin.ui.custom.JVideoView
|
import cn.trans88.taxiappkotlin.ui.custom.JVideoView
|
||||||
|
import cn.trans88.taxiappkotlin.util.FileUtil
|
||||||
import cn.trans88.taxiappkotlin.util.YoungUtil
|
import cn.trans88.taxiappkotlin.util.YoungUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
import com.google.gson.Gson
|
||||||
|
|
||||||
import kotlinx.android.synthetic.main.activity_main.view.*
|
import kotlinx.android.synthetic.main.activity_main.view.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -46,7 +50,7 @@ fun View.createView(context: Context, advertise: Advertise, seek: Int): View? {
|
||||||
val view = when (advertise.media_type) {
|
val view = when (advertise.media_type) {
|
||||||
//图片
|
//图片
|
||||||
MaterialType.IMAGE.ordinal -> {
|
MaterialType.IMAGE.ordinal -> {
|
||||||
YoungUtil.YoungLog("素材是图片:${Configurations.config(TaxiApp.instance()).downloadUrl()}${advertise.media_url} 是否在主线程:${isMainThread()}")
|
// YoungUtil.YoungLog("素材是图片:${Configurations.config(TaxiApp.instance()).downloadUrl()}${advertise.media_url} 是否在主线程:${isMainThread()}")
|
||||||
val image = ImageView(context)
|
val image = ImageView(context)
|
||||||
// val bitmap = BitmapFactory.decodeFile(advertise.pathName)
|
// val bitmap = BitmapFactory.decodeFile(advertise.pathName)
|
||||||
val bitmap = thumbnail(advertise.pathName, Configurations.config(TaxiApp.instance()).screenSizeX(), Configurations.config(TaxiApp.instance()).screenSizeY())
|
val bitmap = thumbnail(advertise.pathName, Configurations.config(TaxiApp.instance()).screenSizeX(), Configurations.config(TaxiApp.instance()).screenSizeY())
|
||||||
|
@ -56,7 +60,7 @@ fun View.createView(context: Context, advertise: Advertise, seek: Int): View? {
|
||||||
}
|
}
|
||||||
//动图
|
//动图
|
||||||
MaterialType.Gif.ordinal -> {
|
MaterialType.Gif.ordinal -> {
|
||||||
YoungUtil.YoungLog("素材是Gif:${Configurations.config(TaxiApp.instance()).downloadUrl()}${advertise.media_url}")
|
// YoungUtil.YoungLog("素材是Gif:${Configurations.config(TaxiApp.instance()).downloadUrl()}${advertise.media_url}")
|
||||||
val image = ImageView(context)
|
val image = ImageView(context)
|
||||||
val options: RequestOptions = RequestOptions()
|
val options: RequestOptions = RequestOptions()
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
@ -324,7 +328,18 @@ fun FrameLayout.playLogo() {
|
||||||
val image = ImageView(context)
|
val image = ImageView(context)
|
||||||
|
|
||||||
val program = File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(string.dir_program))
|
val program = File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(string.dir_program))
|
||||||
val dest = File(program, "logo")
|
val tempLogo = File(program,"logo.temp")
|
||||||
|
val isCustomLogo = Configurations.config(TaxiApp.instance()).isCustomLogo
|
||||||
|
"是否设置自定义logo:$isCustomLogo".logd()
|
||||||
|
FileUtil.restoreFileFromTmp(tempLogo)
|
||||||
|
val dest = if (tempLogo.exists() && isCustomLogo){
|
||||||
|
tempLogo
|
||||||
|
} else if (!isCustomLogo){
|
||||||
|
File(program, "logo404")
|
||||||
|
} else {
|
||||||
|
File(program, "logo")
|
||||||
|
}
|
||||||
|
// val dest = File(program, "logo")
|
||||||
if (dest.exists()) {
|
if (dest.exists()) {
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(dest)
|
.load(dest)
|
||||||
|
@ -350,6 +365,22 @@ fun FrameLayout.playLogo() {
|
||||||
addView(image)
|
addView(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 展示默认的logo
|
||||||
|
*/
|
||||||
|
fun FrameLayout.showDefaultLogo() {
|
||||||
|
YoungUtil.YoungLog("展示默认logo")
|
||||||
|
|
||||||
|
"当前子视图数量:${this.childCount}".logd()
|
||||||
|
|
||||||
|
this.children.iterator().forEach {
|
||||||
|
if (it is ImageView) {
|
||||||
|
"是ImageView,设置默认logo".logd()
|
||||||
|
it.setImageResource(R.mipmap.logo2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 压缩Bitmap防止内存太大
|
* 压缩Bitmap防止内存太大
|
||||||
|
|
|
@ -2,22 +2,33 @@ package cn.trans88.taxiappkotlin.ui.play
|
||||||
|
|
||||||
//import cn.trans88.taxiappkotlin.logic.Settings
|
//import cn.trans88.taxiappkotlin.logic.Settings
|
||||||
//import cn.trans88.taxiappkotlin.logic.enumType.CompanyType
|
//import cn.trans88.taxiappkotlin.logic.enumType.CompanyType
|
||||||
|
import android.Manifest
|
||||||
import android.animation.LayoutTransition
|
import android.animation.LayoutTransition
|
||||||
import android.animation.LayoutTransition.TransitionListener
|
import android.animation.LayoutTransition.TransitionListener
|
||||||
import android.animation.ObjectAnimator
|
import android.animation.ObjectAnimator
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.location.Criteria
|
||||||
import android.location.Location.distanceBetween
|
import android.location.Location.distanceBetween
|
||||||
|
import android.location.LocationListener
|
||||||
|
import android.location.LocationManager
|
||||||
import android.media.MediaMetadataRetriever
|
import android.media.MediaMetadataRetriever
|
||||||
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
import android.view.animation.AnimationUtils
|
import android.view.animation.AnimationUtils
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
|
@ -57,6 +68,7 @@ import cn.trans88.taxiappkotlin.ui.advertise.MaterialType
|
||||||
import cn.trans88.taxiappkotlin.ui.custom.JVideoView
|
import cn.trans88.taxiappkotlin.ui.custom.JVideoView
|
||||||
import cn.trans88.taxiappkotlin.util.DateUtil
|
import cn.trans88.taxiappkotlin.util.DateUtil
|
||||||
import cn.trans88.taxiappkotlin.util.YoungUtil
|
import cn.trans88.taxiappkotlin.util.YoungUtil
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -68,9 +80,17 @@ import java.util.*
|
||||||
//todo 这里不应该持有ui,应该要建立对应的livedata去回调给ui
|
//todo 这里不应该持有ui,应该要建立对应的livedata去回调给ui
|
||||||
class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, private val imageView: ImageView) : ViewModel(), GpsInformationListener, IPlay, LifecycleObserver {
|
class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, private val imageView: ImageView) : ViewModel(), GpsInformationListener, IPlay, LifecycleObserver {
|
||||||
|
|
||||||
|
private val providerMap = HashMap<String,String>()
|
||||||
|
var mLocationManager: LocationManager? = null
|
||||||
|
var isLocationEnabled = false
|
||||||
|
var currentLocation: android.location.Location? = null
|
||||||
|
var bestProvider: String? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
JoeyDownloadManager.getInstance().setIPlay(this)
|
JoeyDownloadManager.getInstance().setIPlay(this)
|
||||||
GpsReceiver.setGpsListener(this)
|
GpsReceiver.setGpsListener(this)
|
||||||
|
providerMap["gps"] = "卫星定位"
|
||||||
|
providerMap["network"] = "网络定位"
|
||||||
}
|
}
|
||||||
|
|
||||||
val TAG: String = "PlayViewModel"
|
val TAG: String = "PlayViewModel"
|
||||||
|
@ -85,6 +105,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
private var curAdvertise: Advertise? = null
|
private var curAdvertise: Advertise? = null
|
||||||
|
|
||||||
// private var nextAdvertise: Advertise? = null
|
// private var nextAdvertise: Advertise? = null
|
||||||
|
@Volatile
|
||||||
private var curLocation: Location? = null
|
private var curLocation: Location? = null
|
||||||
|
|
||||||
private var curLongitude: Double = 0.0
|
private var curLongitude: Double = 0.0
|
||||||
|
@ -137,19 +158,8 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
|
|
||||||
private val handler: Handler = Handler()
|
private val handler: Handler = Handler()
|
||||||
|
|
||||||
// private val refreshLiveData = MutableLiveData<Any?>()
|
|
||||||
|
|
||||||
val advertiseList = ArrayList<Advertise>()
|
val advertiseList = ArrayList<Advertise>()
|
||||||
|
|
||||||
//仓库中的广告一旦发生变化就会通知给activity进行更新播放
|
|
||||||
// val advertiseLiveData = Transformations.switchMap(playLiveData) {
|
|
||||||
// YoungUtil.YoungLog("通知activity播放")
|
|
||||||
// Repository.getAdvertise()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// val circularListLiveData =Transformations.switchMap(refreshLiveData){
|
|
||||||
// Repository.refreshCircularList();
|
|
||||||
// }
|
|
||||||
val taxiApp:TaxiApp = TaxiApp.instance() as TaxiApp
|
val taxiApp:TaxiApp = TaxiApp.instance() as TaxiApp
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,7 +254,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
executeTime = System.currentTimeMillis()
|
executeTime = System.currentTimeMillis()
|
||||||
"分时段播放结束,${DateUtil.dateTimeFormat.format(Date())}".loge()
|
"分时段播放结束,${DateUtil.dateTimeFormat.format(Date())}".loge()
|
||||||
endTimedAd(advertise)
|
endTimedAd(advertise)
|
||||||
"taxiApp.isTimedAdvertise:${Configurations.config(taxiApp.activity).isTimedAdvertise}".loge()
|
// "taxiApp.isTimedAdvertise:${Configurations.config(taxiApp.activity).isTimedAdvertise}".loge()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taxiApp.timer.schedule(endTask,endDate,endTimeDiff)
|
taxiApp.timer.schedule(endTask,endDate,endTimeDiff)
|
||||||
|
@ -353,7 +363,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
}
|
}
|
||||||
// saveCountAdLog(advertise)
|
// saveCountAdLog(advertise)
|
||||||
}
|
}
|
||||||
"当前播放的广告:${Repository.getTestPlayCircularList().toString()}".loge()
|
// "当前播放的广告:${Repository.getTestPlayCircularList().toString()}".loge()
|
||||||
playLiveData.postValue(advertise)
|
playLiveData.postValue(advertise)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +432,14 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
fun playLogo() {
|
fun playLogo() {
|
||||||
if (curAdvertise == null) {
|
if (curAdvertise == null) {
|
||||||
YoungUtil.YoungLog("播放logo")
|
YoungUtil.YoungLog("播放logo")
|
||||||
fl_play.playLogo()
|
fl_play.apply {
|
||||||
|
val logoView = this.findViewWithTag<View>("logo")
|
||||||
|
if (logoView != null) {
|
||||||
|
removeView(logoView)
|
||||||
|
}
|
||||||
|
playLogo()
|
||||||
|
}
|
||||||
|
// fl_play.playLogo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,7 +790,6 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
*/
|
*/
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun initPlayLogger(advertise: Advertise) {
|
private fun initPlayLogger(advertise: Advertise) {
|
||||||
|
|
||||||
// curLongitude =12.4444
|
// curLongitude =12.4444
|
||||||
// curlatitude =12.33333333
|
// curlatitude =12.33333333
|
||||||
if (null == curLogger) {
|
if (null == curLogger) {
|
||||||
|
@ -805,7 +821,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
duration = advertise.duration.toLong()
|
duration = advertise.duration.toLong()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
YoungUtil.YoungLog("初始化curLogger")
|
YoungUtil.YoungLog("初始化curLogger:" + curLogger)
|
||||||
} else {
|
} else {
|
||||||
YoungUtil.YoungLog("初始化curLogger不等于空")
|
YoungUtil.YoungLog("初始化curLogger不等于空")
|
||||||
}
|
}
|
||||||
|
@ -824,13 +840,13 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
*/
|
*/
|
||||||
override fun onLocationChanged(longitude: Double, latitude: Double, bearing: Float, speed: Float, satelliteNumber: Int) {
|
override fun onLocationChanged(longitude: Double, latitude: Double, bearing: Float, speed: Float, satelliteNumber: Int) {
|
||||||
// KuroExecutor.execute(runnable = Runnable {
|
// KuroExecutor.execute(runnable = Runnable {
|
||||||
|
|
||||||
ThreadUtil.executeByPool(
|
ThreadUtil.executeByPool(
|
||||||
Runnable {
|
Runnable {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (satelliteNumber == 0) {
|
if (satelliteNumber == 0) {
|
||||||
YoungUtil.YoungLog("卫星数量为0,删除定点")
|
YoungUtil.YoungLog("卫星数量为0,删除定点")
|
||||||
clearAreaAdvertise()
|
clearAreaAdvertise()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//YoungUtil.YoungLog("当前坐标 latitude:$latitude,longitude: $longitude , 速度 :$speed")
|
//YoungUtil.YoungLog("当前坐标 latitude:$latitude,longitude: $longitude , 速度 :$speed")
|
||||||
//保存坐标地址
|
//保存坐标地址
|
||||||
|
@ -841,7 +857,9 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
saveLocation(longitude, latitude, bearing, speed)
|
saveLocation(longitude, latitude, bearing, speed)
|
||||||
|
|
||||||
val regions = DaoUtil.getRegion().loadAll()
|
val regions = DaoUtil.getRegion().loadAll()
|
||||||
|
"regions.size:${regions.size}".logd()
|
||||||
for (region in regions) {
|
for (region in regions) {
|
||||||
|
"regionAdId:${region.regionAdId},index:${regions.indexOf(region)}".logd()
|
||||||
YoungUtil.YoungLog("当前两点间距离:${DistanceUtil.getDistance(region.lat, region.lng, latitude, longitude)}")
|
YoungUtil.YoungLog("当前两点间距离:${DistanceUtil.getDistance(region.lat, region.lng, latitude, longitude)}")
|
||||||
YoungUtil.YoungLog("points: "+ latitude + " & " + region.lat + " & " + longitude + " & " + region.lng);
|
YoungUtil.YoungLog("points: "+ latitude + " & " + region.lat + " & " + longitude + " & " + region.lng);
|
||||||
if (DistanceUtil.inRadius(region.lat, region.lng, latitude, longitude, region.radius)) {
|
if (DistanceUtil.inRadius(region.lat, region.lng, latitude, longitude, region.radius)) {
|
||||||
|
@ -867,7 +885,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
val advertise = setAdvertiseByPosition(positionAdvertise, region.id, longitude, latitude)
|
val advertise = setAdvertiseByPosition(positionAdvertise, region.id, longitude, latitude)
|
||||||
DaoUtil.getAdvertise().insert(advertise)
|
DaoUtil.getAdvertise().insert(advertise)
|
||||||
RefreshPlayer.refresh()
|
RefreshPlayer.refresh()
|
||||||
}else{
|
} else {
|
||||||
YoungUtil.YoungLog("positionAdvertise is null");
|
YoungUtil.YoungLog("positionAdvertise is null");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -886,33 +904,35 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(locationTimer!=null){
|
if(locationTimer!=null){
|
||||||
//YoungUtil.YoungLog("收到新的坐标,取消之前定时")
|
YoungUtil.YoungLog("收到新的坐标,取消之前定时")
|
||||||
locationTimer!!.cancel()
|
locationTimer!!.cancel()
|
||||||
locationTimer!!.purge()
|
locationTimer!!.purge()
|
||||||
locationTimer =null
|
locationTimer = null
|
||||||
}
|
}
|
||||||
|
|
||||||
locationTimer =Timer()
|
locationTimer = Timer()
|
||||||
//如果3秒没有收到坐标变化,清空定点广告
|
//如果30秒没有收到坐标变化,清空定点广告
|
||||||
locationTimer!!.schedule(object :TimerTask(){
|
locationTimer!!.schedule(object :TimerTask(){
|
||||||
override fun run() {
|
override fun run() {
|
||||||
YoungUtil.YoungLog("长时间没新的坐标,恢复普通广告")
|
YoungUtil.YoungLog("长时间没新的坐标,恢复普通广告")
|
||||||
clearAreaAdvertise()
|
clearAreaAdvertise()
|
||||||
}
|
}
|
||||||
},3*1000)
|
},30*1000)
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearAreaAdvertise() {
|
fun clearAreaAdvertise() {
|
||||||
val list = getAdvertise().queryBuilder().where(Properties.BelongTo.eq(AREA.ordinal)).list()
|
val list = getAdvertise().queryBuilder().where(Properties.BelongTo.eq(AREA.ordinal)).list()
|
||||||
for (advertise in list) {
|
list?.let {
|
||||||
getAdvertise().delete(advertise)
|
for (advertise in it) {
|
||||||
try {
|
getAdvertise().delete(advertise)
|
||||||
RefreshPlayer.refresh()
|
try {
|
||||||
} catch (e: InterruptedException) {
|
RefreshPlayer.refresh()
|
||||||
e.printStackTrace()
|
} catch (e: InterruptedException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -952,7 +972,10 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
distance = floatArray[0]
|
distance = floatArray[0]
|
||||||
elapse = timestamp - curLocation?.timestamp!!
|
elapse = timestamp - curLocation?.timestamp!!
|
||||||
}
|
}
|
||||||
DaoUtil.getLocationDao().insert(location)
|
//过滤掉距离过大的数据,edit by ljh 2023/8/8
|
||||||
|
if (location.distance < 10 * 1000){
|
||||||
|
DaoUtil.getLocationDao().insert(location)
|
||||||
|
}
|
||||||
curLocation = location
|
curLocation = location
|
||||||
} else {
|
} else {
|
||||||
val tamp = System.currentTimeMillis() - curLocation!!.timestamp
|
val tamp = System.currentTimeMillis() - curLocation!!.timestamp
|
||||||
|
@ -1028,6 +1051,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
pathName = positionAdvertise.pathName
|
pathName = positionAdvertise.pathName
|
||||||
duration = positionAdvertise.duration
|
duration = positionAdvertise.duration
|
||||||
region_id = regionId
|
region_id = regionId
|
||||||
|
createAt = System.currentTimeMillis()
|
||||||
this.longitude = longitude
|
this.longitude = longitude
|
||||||
this.latitude = latitude
|
this.latitude = latitude
|
||||||
}
|
}
|
||||||
|
@ -1042,4 +1066,92 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout,
|
||||||
override fun setLogo() {
|
override fun setLogo() {
|
||||||
playLogo()
|
playLogo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化定位
|
||||||
|
*/
|
||||||
|
fun initLocation(){
|
||||||
|
//从系统服务中获取定位管理器
|
||||||
|
mLocationManager = TaxiApp.instance().getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
||||||
|
// 创建一个定位准则对象
|
||||||
|
val criteria = Criteria()
|
||||||
|
// 设置定位精确度
|
||||||
|
criteria.accuracy = Criteria.ACCURACY_FINE
|
||||||
|
// 设置是否需要海拔信息
|
||||||
|
criteria.isAltitudeRequired = true
|
||||||
|
// 设置是否需要方位信息
|
||||||
|
criteria.isBearingRequired = true
|
||||||
|
// 设置是否允许运营商收费
|
||||||
|
criteria.isCostAllowed = true
|
||||||
|
// 设置对电源的需求
|
||||||
|
criteria.powerRequirement = Criteria.POWER_LOW
|
||||||
|
|
||||||
|
// 获取定位管理器的最佳定位提供者
|
||||||
|
// 获取定位管理器的最佳定位提供者
|
||||||
|
bestProvider = mLocationManager?.getBestProvider(criteria, true)
|
||||||
|
|
||||||
|
bestProvider?.let {
|
||||||
|
if (mLocationManager != null && mLocationManager!!.isProviderEnabled(it)) { // 定位提供者当前可用
|
||||||
|
"定位类型为${providerMap[it]},开始定位".loge()
|
||||||
|
beginLocation(it,15*1000) // 开始定位
|
||||||
|
isLocationEnabled = true
|
||||||
|
} else { // 定位提供者暂不可用
|
||||||
|
"${providerMap[bestProvider!!].toString()} 不可用".loge()
|
||||||
|
isLocationEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始定位
|
||||||
|
* @param method String
|
||||||
|
*/
|
||||||
|
private fun beginLocation(method: String,minTime:Long):Boolean {
|
||||||
|
// 检查当前设备是否已经开启了定位功能
|
||||||
|
if (ActivityCompat.checkSelfPermission(TaxiApp.instance(), Manifest.permission.ACCESS_FINE_LOCATION)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED
|
||||||
|
) {
|
||||||
|
"location not opened,请授予定位权限并开启定位功能".loge()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
"定位功能已打开".loge()
|
||||||
|
// 设置定位管理器的位置变更监听器
|
||||||
|
//minTime表示 位置信息将每隔 多少 毫秒进行一次更新
|
||||||
|
//minDistance表示 如果设备移动的距离超过 多少 米,位置信息将进行更新,如果你只关心时间间隔而不关心距离间隔,则可以将此值设置为 0。
|
||||||
|
mLocationManager?.requestLocationUpdates(method, minTime, 0f, mLocationListener)
|
||||||
|
// 获取最后一次成功定位的位置信息
|
||||||
|
"获取最后一次成功定位的位置信息".logd()
|
||||||
|
val location: android.location.Location? = mLocationManager?.getLastKnownLocation(method)
|
||||||
|
currentLocation = location
|
||||||
|
"currentLocation改变,currentLocation是否为空${currentLocation == null},经度:${currentLocation?.longitude},纬度:${currentLocation?.latitude}".logd()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义一个位置变更监听器
|
||||||
|
private val mLocationListener: LocationListener = object : LocationListener {
|
||||||
|
override fun onLocationChanged(location: android.location.Location) {
|
||||||
|
"locationChanged: 经度:${location.longitude},纬度:${location.latitude}".logd()
|
||||||
|
currentLocation = location
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onProviderDisabled(arg0: String) {
|
||||||
|
"onProviderDisabled,arg0:$arg0".logd()
|
||||||
|
}
|
||||||
|
override fun onProviderEnabled(arg0: String) {
|
||||||
|
"onProviderEnabled,arg0:$arg0".logd()
|
||||||
|
}
|
||||||
|
override fun onStatusChanged(arg0: String, arg1: Int, arg2: Bundle) {
|
||||||
|
"onStatusChanged,arg0:$arg0".logd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取位置变更监听器
|
||||||
|
* @return LocationListener?
|
||||||
|
*/
|
||||||
|
fun getLocationListener(): LocationListener{
|
||||||
|
return mLocationListener
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.trans88.taxiappkotlin.ui.play
|
package cn.trans88.taxiappkotlin.ui.play
|
||||||
|
|
||||||
import cn.trans88.kurotool.util.TimeUtil
|
import cn.trans88.kurotool.util.TimeUtil
|
||||||
|
import cn.trans88.taxiappkotlin.ext.logd
|
||||||
import cn.trans88.taxiappkotlin.ext.loge
|
import cn.trans88.taxiappkotlin.ext.loge
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao
|
import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao.Properties
|
import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao.Properties
|
||||||
|
@ -8,10 +9,12 @@ import cn.trans88.taxiappkotlin.logic.dao.DaoUtil
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.DaoUtil.getAdvertise
|
import cn.trans88.taxiappkotlin.logic.dao.DaoUtil.getAdvertise
|
||||||
import cn.trans88.taxiappkotlin.logic.dao.TimeSpanDao
|
import cn.trans88.taxiappkotlin.logic.dao.TimeSpanDao
|
||||||
import cn.trans88.taxiappkotlin.logic.model.Advertise
|
import cn.trans88.taxiappkotlin.logic.model.Advertise
|
||||||
|
import cn.trans88.taxiappkotlin.logic.model.PositionAdvertise
|
||||||
import cn.trans88.taxiappkotlin.logic.model.TimeSpan
|
import cn.trans88.taxiappkotlin.logic.model.TimeSpan
|
||||||
import cn.trans88.taxiappkotlin.logic.network.JoeyDownloadManager
|
import cn.trans88.taxiappkotlin.logic.network.JoeyDownloadManager
|
||||||
import cn.trans88.taxiappkotlin.ui.advertise.MaterialType
|
import cn.trans88.taxiappkotlin.ui.advertise.MaterialType
|
||||||
import cn.trans88.taxiappkotlin.util.YoungUtil
|
import cn.trans88.taxiappkotlin.util.YoungUtil
|
||||||
|
import org.greenrobot.greendao.query.LazyList
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
fun Advertise.isReady(): Boolean {
|
fun Advertise.isReady(): Boolean {
|
||||||
|
@ -190,7 +193,54 @@ fun Advertise.isPlayNow(): Boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Advertise.isOverdue():Boolean{
|
fun Advertise.isOverdue():Boolean{
|
||||||
val timeList = DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(this.ad_id)).limit(10).list()
|
//#edit by ljh @2023/8/7 使用缓存加懒加载防止内存溢出
|
||||||
|
var timeList:LazyList<TimeSpan>? = null
|
||||||
|
try {
|
||||||
|
timeList = DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(this.ad_id)).limit(10).listLazy()
|
||||||
|
|
||||||
|
timeList?.forEach {
|
||||||
|
val curTime = System.currentTimeMillis()
|
||||||
|
val startDayTime: Long = it.date_start
|
||||||
|
val endDayTime: Long = it.date_end
|
||||||
|
|
||||||
|
val startDay: String = TimeUtil.getDateToString(startDayTime)
|
||||||
|
val endDay: String = TimeUtil.getDateToString(endDayTime)
|
||||||
|
|
||||||
|
val startHour: Int = TimeUtil.getHour(it.day_start)
|
||||||
|
val startMinute: Int = TimeUtil.getMinute(it.day_start)
|
||||||
|
val startSecond: Int = TimeUtil.getSecond(it.day_start)
|
||||||
|
|
||||||
|
val endHour: Int = TimeUtil.getHour(it.day_end)
|
||||||
|
val endMinute: Int = TimeUtil.getMinute(it.day_end)
|
||||||
|
val endSecond: Int = TimeUtil.getSecond(it.day_end)
|
||||||
|
|
||||||
|
val newStartDay = TimeUtil.getNewTime(startDay, startHour, startMinute, startSecond)
|
||||||
|
val newEndDay = TimeUtil.getNewTime(endDay, endHour, endMinute, endSecond)
|
||||||
|
val startTime: Long = TimeUtil.getStringToDate(newStartDay)
|
||||||
|
var endTime: Long = TimeUtil.getStringToDate(newEndDay)
|
||||||
|
|
||||||
|
if (endTime <= 0) {
|
||||||
|
endTime = Long.MAX_VALUE
|
||||||
|
}
|
||||||
|
//如果时间已经大于结束时间了,直接将广告删除
|
||||||
|
if (curTime>endTime){
|
||||||
|
DaoUtil.deleteAdvertise(this)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
} finally {
|
||||||
|
timeList?.let {
|
||||||
|
if (!timeList.isClosed){
|
||||||
|
"timeList.close()".logd()
|
||||||
|
timeList.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun PositionAdvertise.isOverdue():Boolean{
|
||||||
|
val timeList = DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(this.task_id)).limit(10).list()
|
||||||
|
|
||||||
timeList?.forEach {
|
timeList?.forEach {
|
||||||
val curTime = System.currentTimeMillis()
|
val curTime = System.currentTimeMillis()
|
||||||
|
@ -218,7 +268,8 @@ fun Advertise.isOverdue():Boolean{
|
||||||
}
|
}
|
||||||
//如果时间已经大于结束时间了,直接将广告删除
|
//如果时间已经大于结束时间了,直接将广告删除
|
||||||
if (curTime>endTime){
|
if (curTime>endTime){
|
||||||
DaoUtil.deleteAdvertise(this)
|
"该定点广告${this.task_id}过期了".loge()
|
||||||
|
DaoUtil.deleteByPositionAdvertise(this)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package cn.trans88.taxiappkotlin.util
|
||||||
|
|
||||||
|
import cn.trans88.taxiappkotlin.Configurations
|
||||||
|
import cn.trans88.taxiappkotlin.TaxiApp
|
||||||
|
import cn.trans88.taxiappkotlin.ext.logd
|
||||||
|
import cn.trans88.taxiappkotlin.logic.Repository
|
||||||
|
import cn.trans88.taxiappkotlin.logic.model.BackgroundType
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Author: LJH
|
||||||
|
* @Time: 2023/7/5
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
object FileUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 恢复temp临时文件
|
||||||
|
* @param file File
|
||||||
|
*/
|
||||||
|
fun restoreFileFromTmp(file: File) {
|
||||||
|
if (file.exists() && file.extension == "temp") {
|
||||||
|
val isCustomLogo = Configurations.config(TaxiApp.instance()).isCustomLogo
|
||||||
|
|
||||||
|
if (isCustomLogo){
|
||||||
|
val newFilePath = file.parent + "/" + file.nameWithoutExtension
|
||||||
|
val newFile = File(newFilePath)
|
||||||
|
|
||||||
|
// 重命名文件
|
||||||
|
file.renameTo(newFile)
|
||||||
|
"文件已恢复为:$newFilePath".logd()
|
||||||
|
} else {
|
||||||
|
"没有设置logo不恢复临时文件".logd()
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
"找不到临时文件或文件已恢复".logd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ import java.io.InputStreamReader;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
|
|
||||||
public static String getCpuName() {
|
public static String getCpuName() {
|
||||||
try {
|
try {
|
||||||
FileReader fr = new FileReader("/proc/cpuinfo");
|
FileReader fr = new FileReader("/proc/cpuinfo");
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.trans88.taxiappkotlin.util
|
||||||
|
|
||||||
import cn.trans88.kurotool.datastructure.CircularList
|
import cn.trans88.kurotool.datastructure.CircularList
|
||||||
import cn.trans88.kurotool.util.TimeUtil
|
import cn.trans88.kurotool.util.TimeUtil
|
||||||
|
import cn.trans88.taxiappkotlin.TaxiApp
|
||||||
import cn.trans88.taxiappkotlin.logic.model.Advertise
|
import cn.trans88.taxiappkotlin.logic.model.Advertise
|
||||||
import cn.trans88.taxiappkotlin.logic.model.SyncTimeModel
|
import cn.trans88.taxiappkotlin.logic.model.SyncTimeModel
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
@ -84,60 +85,62 @@ object SyncUtil {
|
||||||
* 计算出 同步第几个广告的位置及需要延迟的时间
|
* 计算出 同步第几个广告的位置及需要延迟的时间
|
||||||
*/
|
*/
|
||||||
fun getSyncSingleTime(pastTime:Long, list: MutableList<Advertise>?): SyncTimeModel {
|
fun getSyncSingleTime(pastTime:Long, list: MutableList<Advertise>?): SyncTimeModel {
|
||||||
if (list == null || list.size == 0) return SyncTimeModel()
|
synchronized(TaxiApp::class.java){
|
||||||
|
if (list == null || list.size == 0) return SyncTimeModel()
|
||||||
// if (circularList == null || circularList.size() == 0) return 0
|
// if (circularList == null || circularList.size() == 0) return 0
|
||||||
var all = 0
|
var all = 0
|
||||||
|
|
||||||
var currentPosition =0
|
var currentPosition =0
|
||||||
var sum =0
|
var sum =0
|
||||||
|
|
||||||
val syncTimeModel = SyncTimeModel()
|
val syncTimeModel = SyncTimeModel()
|
||||||
|
|
||||||
for (index in 0 until list.size) {
|
|
||||||
// YoungUtil.YoungLog("getSyncTime index :$index TID: ${Thread.currentThread().id}")
|
|
||||||
val advertise = list[index]
|
|
||||||
all += advertise.duration.toInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (all > 0){
|
|
||||||
val curr =System.currentTimeMillis()
|
|
||||||
// val curr = pastTime
|
|
||||||
val past = TimeUtil.pastSeconds(null, "00:00", curr)
|
|
||||||
// val past = pastTime
|
|
||||||
YoungUtil.YoungLog("当前过去多少秒: $past,广告列表总时长 $all")
|
|
||||||
|
|
||||||
val passModuleTime = past % all//当前模块过了多少时间
|
|
||||||
|
|
||||||
var delay:Long = 0
|
|
||||||
|
|
||||||
for (index in 0 until list.size) {
|
for (index in 0 until list.size) {
|
||||||
// YoungUtil.YoungLog("getSyncTime index :$index TID: ${Thread.currentThread().id}")
|
// YoungUtil.YoungLog("getSyncTime index :$index TID: ${Thread.currentThread().id}")
|
||||||
val advertise = list[index]
|
val advertise = list[index]
|
||||||
|
all += advertise.duration.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
sum += advertise.duration.toInt()
|
if (all > 0){
|
||||||
|
val curr =System.currentTimeMillis()
|
||||||
|
// val curr = pastTime
|
||||||
|
val past = TimeUtil.pastSeconds(null, "00:00", curr)
|
||||||
|
// val past = pastTime
|
||||||
|
YoungUtil.YoungLog("当前过去多少秒: $past,广告列表总时长 $all")
|
||||||
|
|
||||||
if (sum>=passModuleTime){
|
val passModuleTime = past % all//当前模块过了多少时间
|
||||||
currentPosition =index+1
|
|
||||||
delay =sum -passModuleTime
|
|
||||||
|
|
||||||
if (currentPosition >= list.size) {
|
var delay:Long = 0
|
||||||
YoungUtil.YoungLog("同步时当前播放广告位置大于列表长度,重置为0")
|
|
||||||
currentPosition = 0
|
for (index in 0 until list.size) {
|
||||||
|
// YoungUtil.YoungLog("getSyncTime index :$index TID: ${Thread.currentThread().id}")
|
||||||
|
val advertise = list[index]
|
||||||
|
|
||||||
|
sum += advertise.duration.toInt()
|
||||||
|
|
||||||
|
if (sum>=passModuleTime){
|
||||||
|
currentPosition =index+1
|
||||||
|
delay =sum -passModuleTime
|
||||||
|
|
||||||
|
if (currentPosition >= list.size) {
|
||||||
|
YoungUtil.YoungLog("同步时当前播放广告位置大于列表长度,重置为0")
|
||||||
|
currentPosition = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
syncTimeModel.currentPosition =currentPosition
|
||||||
|
syncTimeModel.delay =delay
|
||||||
|
|
||||||
|
YoungUtil.YoungLog("同步时间为:${syncTimeModel.delay},日期:${Date(curr + delay)} ,播放的位置:${syncTimeModel.currentPosition},总时间:$sum,过去的时间:$passModuleTime")
|
||||||
|
return syncTimeModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
syncTimeModel.currentPosition =currentPosition
|
|
||||||
syncTimeModel.delay =delay
|
|
||||||
|
|
||||||
YoungUtil.YoungLog("同步时间为:${syncTimeModel.delay},日期:${Date(curr + delay)} ,播放的位置:${syncTimeModel.currentPosition},总时间:$sum,过去的时间:$passModuleTime")
|
|
||||||
return syncTimeModel
|
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
YoungUtil.YoungLog("节目所有时长为0 ,不做同步")
|
||||||
}
|
}
|
||||||
}else{
|
return syncTimeModel
|
||||||
YoungUtil.YoungLog("节目所有时长为0 ,不做同步")
|
|
||||||
}
|
}
|
||||||
return syncTimeModel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,6 @@ object Xixun {
|
||||||
screenListeners.add(listener)
|
screenListeners.add(listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getCardId(): String {
|
fun getCardId(): String {
|
||||||
val cardID = File("/data/joey/signed/card.id")
|
val cardID = File("/data/joey/signed/card.id")
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":187,"versionName":"3.3.3-beta26.3.3.8.2-debug","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.3.3.8.2-debug{187}.apk","fullName":"debug","baseName":"debug","dirName":""},"path":"TaxiApp_v3.3.3-beta26.3.3.8.2-debug{187}.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":207,"versionName":"3.3.3-beta26.3.8.1-debug","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.3.8.1-debug{207}.apk","fullName":"debug","baseName":"debug","dirName":""},"path":"TaxiApp_v3.3.3-beta26.3.8.1-debug{207}.apk","properties":{}}]
|
|
@ -4,5 +4,5 @@
|
||||||
# Location of the SDK. This is only used by Gradle.
|
# Location of the SDK. This is only used by Gradle.
|
||||||
# For customization when using a Version Control System, please read the
|
# For customization when using a Version Control System, please read the
|
||||||
# header note.
|
# header note.
|
||||||
#Wed Jun 28 13:44:25 GMT+08:00 2023
|
#Tue Jul 18 17:55:51 GMT+08:00 2023
|
||||||
sdk.dir=D\:\\Android\\sdk
|
sdk.dir=D\:\\Android\\sdk
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
||||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":188,"versionName":"3.3.3-beta26.3.3.8.3-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.3.3.8.3-release{188}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.3.3.8.3-release{188}.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":208,"versionName":"3.3.3-beta26.3.8.2-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.3.8.2-release{208}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.3.8.2-release{208}.apk","properties":{}}]
|
Loading…
Reference in New Issue
Block a user