新增软解码切换功能

This commit is contained in:
刘金华 2024-03-21 17:42:43 +08:00
parent 1c2cdacadb
commit a361a2c11c
20 changed files with 96 additions and 18 deletions

View File

@ -21,8 +21,8 @@ android {
applicationId "net.sysolution.taxiapp"
minSdkVersion 21
targetSdkVersion 29
versionCode 249
versionName "3.3.3-beta26.4.0.8-debug"
versionCode 251
versionName "3.3.3-beta26.4.0.9-release"
//alphaxx - ,bug
//Betaxx -

View File

@ -454,6 +454,14 @@ public class Configurations {
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putInt("logInterval", logInterval).apply();
}
public String progressList(){
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("progressList", "");
}
public void progressListSave(String s){
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("progressList", s).apply();
}
}

View File

@ -15,6 +15,7 @@ import cn.trans88.taxiappkotlin.logic.dao.DaoSession
import cn.trans88.taxiappkotlin.logic.dao.HelperDaoDB
import cn.trans88.taxiappkotlin.logic.exception.CrashHandler
import cn.trans88.taxiappkotlin.logic.model.Advertise
import cn.trans88.taxiappkotlin.logic.model.AdvertiseProcess
import cn.trans88.taxiappkotlin.logic.model.BackgroundType
import cn.trans88.taxiappkotlin.logic.model.Regions
import cn.trans88.taxiappkotlin.logic.network.JoeyDownloadManager
@ -39,6 +40,7 @@ import java.util.*
import java.util.concurrent.CopyOnWriteArrayList
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.collections.HashSet
class TaxiApp:Application() {
@ -67,6 +69,8 @@ class TaxiApp:Application() {
val timerTaskMap = HashMap<String,kotlin.collections.ArrayList<TimerTask>>()
//存储定时广告的列表
var timedAds:ArrayList<Advertise> = ArrayList()
//存储未上传成功的下载进度
var processList:HashSet<AdvertiseProcess> = HashSet()
var activity:PlayActivity? = null
//gps日志定时器

View File

@ -1,5 +1,7 @@
package cn.trans88.taxiappkotlin.logic.model;
import java.util.Objects;
public class AdvertiseProcess {
private String type = "notify_download_ad_progress";
private String ad_id;
@ -20,4 +22,19 @@ public class AdvertiseProcess {
public void setProgress(String progress) {
this.progress = progress;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AdvertiseProcess that = (AdvertiseProcess) o;
return Objects.equals(type, that.type) &&
Objects.equals(ad_id, that.ad_id) &&
Objects.equals(progress, that.progress);
}
@Override
public int hashCode() {
return Objects.hash(type, ad_id, progress);
}
}

View File

@ -192,6 +192,7 @@ public class JoeyDownloadManager {
downloadListener = new JoeyDownloadListener() {
@Override
protected void completed(BaseDownloadTask task) {
YoungUtil.YoungLog("下载完成 --》 completed");
YoungUtil.YoungLog("Download "
+ task.getUrl()
+ " successful, [Size/Speed ==> "
@ -226,7 +227,7 @@ public class JoeyDownloadManager {
advertiseProcess.setProgress(String.valueOf(100));
String progressJson = new Gson().toJson(advertiseProcess);
YoungUtil.YoungLog("广告:"+task.getTag()+",下载完成进度100");
WsManager.INSTANCE.send(progressJson);
// WsManager.INSTANCE.send(progressJson);
try {
RefreshPlayer.refresh();
@ -313,11 +314,12 @@ public class JoeyDownloadManager {
advertiseProcess.setProgress(String.valueOf(100));
String progressJson = new Gson().toJson(advertiseProcess);
YoungUtil.YoungLog("广告:"+task.getTag().toString()+",下载完成进度100");
WsManager.INSTANCE.send(progressJson);
try{
Thread.sleep(500);
}catch (Exception e){}
WsManager.INSTANCE.send(progressJson);
// WsManager.INSTANCE.send(progressJson);
// try{
// Thread.sleep(500);
// }catch (Exception e){}
// WsManager.INSTANCE.send(progressJson);
}
// if (progress%5==0){
// AdvertiseProcess advertiseProcess =new AdvertiseProcess();

View File

@ -22,6 +22,7 @@ import cn.trans88.taxiappkotlin.ui.play.isOverdue
import cn.trans88.taxiappkotlin.util.YoungUtil
import com.google.gson.Gson
import com.google.gson.JsonParser
import com.google.gson.reflect.TypeToken
import com.trs88.kurolibrary.execute.KuroExecutor
import com.trs88.kurolibrary.file.KuroFileUtil
import java.io.*
@ -298,6 +299,7 @@ object ProcessingCommands {
//edit by ljh @2024/3/14
Configurations.config(TaxiApp.instance()).isSoftDecodeSave(loggerSwitch.isSoftDeCode)
taxiApp.isSoftDecode = loggerSwitch.isSoftDeCode
"是否软解码:${taxiApp.isSoftDecode}".logd()
baseResponse.type = type
val response = gson.toJson(baseResponse)
@ -356,6 +358,7 @@ object ProcessingCommands {
beatTimer!!.cancel()
beatTimer!!.purge()
beatTimer = null
}
beatTimer = Timer()
@ -398,6 +401,22 @@ object ProcessingCommands {
* 发送所有广告信息
*/
private fun sendAllAdvertiseInfo(task: String, type: String) {
//提交未上传成功的下载进度
try {
val progressListJson = Configurations.config(taxiApp).progressList()
if (!progressListJson.isNullOrEmpty()){
"progressListJson:$progressListJson".logd()
val progressList = gson.fromJson<AdvertiseProcess>(progressListJson,object : TypeToken<Set<AdvertiseProcess>>(){}.type) as HashSet<AdvertiseProcess>
for (advertiseProcess in progressList) {
send(gson.toJson(advertiseProcess))
}
Configurations.config(taxiApp).progressListSave("")
taxiApp.processList.clear()
}
} catch (e: Exception) {
"exception:${e?.message}".loge()
}
val baseResponse = gson.fromJson<BaseResponse>(task)
val positionAdvertises = DaoUtil.getPositionAdvertise().loadAll()
@ -826,6 +845,12 @@ object ProcessingCommands {
sanleResponse.type = type
val response = gson.toJson(sanleResponse)
send(response)
val advertiseProcess = AdvertiseProcess()
advertiseProcess.ad_id = positionAdvertise.task_id
advertiseProcess.progress = 100.toString()
val progressJson = Gson().toJson(advertiseProcess)
send(progressJson)
}
/**
@ -1042,6 +1067,12 @@ object ProcessingCommands {
sanleResponse.type = type
val response = gson.toJson(sanleResponse)
send(response)
val advertiseProcess = AdvertiseProcess()
advertiseProcess.ad_id = sanleAdvertise.task_id
advertiseProcess.progress = 100.toString()
val progressJson = Gson().toJson(advertiseProcess)
send(progressJson)
// send("服务器日志 ${Xixun.getCardId()} 添加广告 id =${sanleAdvertise.id}")
}

View File

@ -14,6 +14,7 @@ import cn.trans88.taxiappkotlin.ext.logd
import cn.trans88.taxiappkotlin.ext.loge
import cn.trans88.taxiappkotlin.logic.Repository
import cn.trans88.taxiappkotlin.logic.dao.DaoUtil
import cn.trans88.taxiappkotlin.logic.model.AdvertiseProcess
import cn.trans88.taxiappkotlin.logic.model.CurrentPlayAdvertises
import cn.trans88.taxiappkotlin.util.KuroTimer
import cn.trans88.taxiappkotlin.util.KuroTimerTask
@ -357,7 +358,22 @@ object WsManager {
// if(!(heartbeatContext.equals(msg))){
// Repository.taxiApp.saveLog("回复服务器 $msg")
// }
if (msg.contains("notify_download_ad_progress")) {
"notify_download_ad_progress ----> $msg".logd()
if (mWebSocket == null) {
try {
val process = Repository.taxiApp.gson.fromJson<AdvertiseProcess>(
msg,
AdvertiseProcess::class.java
)
Repository.taxiApp.processList.add(process)
val json = Repository.taxiApp.gson.toJson(Repository.taxiApp.processList)
Configurations.config(Repository.taxiApp).progressListSave(json)
} catch (e:Exception){
"exception${e?.message}".loge()
}
}
}
mWebSocket?.send(msg)
// mWebSocket?.send(msg) ?: throw IllegalArgumentException("mWebSocket is null not send!")
}

View File

@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Mar 18 15:40:17 GMT+08:00 2024
#Thu Mar 21 16:48:54 GMT+08:00 2024
sdk.dir=D\:\\Android\\sdk

View File

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":249,"versionName":"3.3.3-beta26.4.0.8-debug","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.4.0.8-debug{249}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.4.0.8-debug{249}.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":251,"versionName":"3.3.3-beta26.4.0.9-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.4.0.9-release{251}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.4.0.9-release{251}.apk","properties":{}}]