diff --git a/.gradle/5.6.4/executionHistory/executionHistory.bin b/.gradle/5.6.4/executionHistory/executionHistory.bin index 0ed50dd..b3e96f3 100644 Binary files a/.gradle/5.6.4/executionHistory/executionHistory.bin and b/.gradle/5.6.4/executionHistory/executionHistory.bin differ diff --git a/.gradle/5.6.4/executionHistory/executionHistory.lock b/.gradle/5.6.4/executionHistory/executionHistory.lock index 26f8f8d..b78a759 100644 Binary files a/.gradle/5.6.4/executionHistory/executionHistory.lock and b/.gradle/5.6.4/executionHistory/executionHistory.lock differ diff --git a/.gradle/5.6.4/fileHashes/fileHashes.bin b/.gradle/5.6.4/fileHashes/fileHashes.bin index 074dec8..4fa7c19 100644 Binary files a/.gradle/5.6.4/fileHashes/fileHashes.bin and b/.gradle/5.6.4/fileHashes/fileHashes.bin differ diff --git a/.gradle/5.6.4/fileHashes/fileHashes.lock b/.gradle/5.6.4/fileHashes/fileHashes.lock index 227ef72..6a5bb66 100644 Binary files a/.gradle/5.6.4/fileHashes/fileHashes.lock and b/.gradle/5.6.4/fileHashes/fileHashes.lock differ diff --git a/.gradle/5.6.4/fileHashes/resourceHashesCache.bin b/.gradle/5.6.4/fileHashes/resourceHashesCache.bin index 3c05a87..8223d25 100644 Binary files a/.gradle/5.6.4/fileHashes/resourceHashesCache.bin and b/.gradle/5.6.4/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/5.6.4/javaCompile/classAnalysis.bin b/.gradle/5.6.4/javaCompile/classAnalysis.bin index 8c6c18a..1eefccc 100644 Binary files a/.gradle/5.6.4/javaCompile/classAnalysis.bin and b/.gradle/5.6.4/javaCompile/classAnalysis.bin differ diff --git a/.gradle/5.6.4/javaCompile/jarAnalysis.bin b/.gradle/5.6.4/javaCompile/jarAnalysis.bin index be235c4..b96149f 100644 Binary files a/.gradle/5.6.4/javaCompile/jarAnalysis.bin and b/.gradle/5.6.4/javaCompile/jarAnalysis.bin differ diff --git a/.gradle/5.6.4/javaCompile/javaCompile.lock b/.gradle/5.6.4/javaCompile/javaCompile.lock index 39175ec..24b9895 100644 Binary files a/.gradle/5.6.4/javaCompile/javaCompile.lock and b/.gradle/5.6.4/javaCompile/javaCompile.lock differ diff --git a/.gradle/5.6.4/javaCompile/taskHistory.bin b/.gradle/5.6.4/javaCompile/taskHistory.bin index b7dc5c5..e3b6c38 100644 Binary files a/.gradle/5.6.4/javaCompile/taskHistory.bin and b/.gradle/5.6.4/javaCompile/taskHistory.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 79e8651..0cbb9e0 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties index a8c2cb1..52089b0 100644 --- a/.gradle/buildOutputCleanup/cache.properties +++ b/.gradle/buildOutputCleanup/cache.properties @@ -1,2 +1,2 @@ -#Tue Jun 25 17:25:11 GMT+08:00 2024 +#Sat Oct 26 16:34:57 CST 2024 gradle.version=5.6.4 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 6fe697e..59d4c0c 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 20e8aa6..1bdf584 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,9 +4,9 @@ diff --git a/.idea/libraries/Gradle____app_libs_xixun_card_settings_1_2_4_jar.xml b/.idea/libraries/Gradle____app_libs_xixun_card_settings_1_2_4_jar.xml deleted file mode 100644 index d99c23e..0000000 --- a/.idea/libraries/Gradle____app_libs_xixun_card_settings_1_2_4_jar.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml index 7c2ab08..1610896 100644 --- a/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_activity_activity_1_2_3_aar.xml b/.idea/libraries/Gradle__androidx_activity_activity_1_2_3_aar.xml index 87412e8..952988b 100644 --- a/.idea/libraries/Gradle__androidx_activity_activity_1_2_3_aar.xml +++ b/.idea/libraries/Gradle__androidx_activity_activity_1_2_3_aar.xml @@ -1,11 +1,10 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml b/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml index b2158ac..ce6700e 100644 --- a/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml +++ b/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml b/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml index 74437d7..f4a0b4d 100644 --- a/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml +++ b/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml index 25283a2..b4aa53d 100644 --- a/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml index 4488e12..27f816b 100644 --- a/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_3_0_aar.xml b/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_3_0_aar.xml index 06f4f71..ffbe0e7 100644 --- a/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_3_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_3_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml index 3aa31e4..d62af6b 100644 --- a/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_3_0_aar.xml b/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_3_0_aar.xml index a629c8e..4b2898d 100644 --- a/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_3_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_3_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml b/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml index 2208415..ce7fa42 100644 --- a/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +++ b/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml b/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml index 7ea0efb..94708a0 100644 --- a/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml b/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml index a42f8cc..9f8ac59 100644 --- a/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml index d5ca524..38da836 100644 --- a/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml b/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml index eafc05e..6b589c5 100644 --- a/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +++ b/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_1_aar.xml b/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_1_aar.xml index 7a2df36..34f3865 100644 --- a/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_1_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_1.xml b/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_1.xml index 24d3804..86a9527 100644 --- a/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_1.xml +++ b/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml index 008eba3..ce01650 100644 --- a/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_core_core_1_3_2_aar.xml b/.idea/libraries/Gradle__androidx_core_core_1_3_2_aar.xml index 817ac21..dabf7b7 100644 --- a/.idea/libraries/Gradle__androidx_core_core_1_3_2_aar.xml +++ b/.idea/libraries/Gradle__androidx_core_core_1_3_2_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml b/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml index ec4d413..99c5ecc 100644 --- a/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_core_core_ktx_1_3_2_aar.xml b/.idea/libraries/Gradle__androidx_core_core_ktx_1_3_2_aar.xml index decddbe..0b3ac88 100644 --- a/.idea/libraries/Gradle__androidx_core_core_ktx_1_3_2_aar.xml +++ b/.idea/libraries/Gradle__androidx_core_core_ktx_1_3_2_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml index e8dd337..4dc8b34 100644 --- a/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml index abcc510..daddb61 100644 --- a/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml index 666fe5b..86f4d85 100644 --- a/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml index ef3bd74..0c21385 100644 --- a/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml @@ -1,11 +1,10 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml index 0a64342..2ae20f5 100644 --- a/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml index 3ddc352..cb4df68 100644 --- a/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml @@ -1,11 +1,10 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_4_aar.xml b/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_4_aar.xml index 3e8d164..bea434a 100644 --- a/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_4_aar.xml +++ b/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_4_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml index 97ebbe0..ca9728b 100644 --- a/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml index cb73bb0..4fdad2f 100644 --- a/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0.xml index 9354d44..d819b07 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_1.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_1.xml index a1e1912..c0972be 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_1.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml index f4b4806..2dc273f 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_2_0_aar.xml index 9664f5b..0b33e19 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml index 2ac0ee3..5d77e15 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_1_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_1_aar.xml index f0af239..7a05caf 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_1_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_ktx_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_ktx_2_2_0_aar.xml index db2b1d4..0f7318a 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_ktx_2_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_ktx_2_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_ktx_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_ktx_2_2_0_aar.xml index f33d7ba..70a42f1 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_ktx_2_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_ktx_2_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_reactivestreams_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_reactivestreams_2_2_0_aar.xml index 25dbd71..579efb3 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_reactivestreams_2_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_reactivestreams_2_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_reactivestreams_ktx_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_reactivestreams_ktx_2_2_0_aar.xml index 882c3fc..49a501d 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_reactivestreams_ktx_2_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_reactivestreams_ktx_2_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml index 5b3ff71..042f14f 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_1_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_1_aar.xml index 08b3a8d..d9e2ce7 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_1_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_ktx_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_ktx_2_2_0_aar.xml index 236000a..f4243fb 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_ktx_2_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_ktx_2_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml index b6c983f..e5a52d3 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_1_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_1_aar.xml index f2e5155..f3a5946 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_1_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_ktx_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_ktx_2_2_0_aar.xml index 8a865c5..25f17de 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_ktx_2_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_ktx_2_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml index 8134aef..da05221 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml index 6b79487..3d4116f 100644 --- a/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml index ece91b4..daef145 100644 --- a/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml index 3f6590c..1f4b22a 100644 --- a/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml @@ -1,11 +1,10 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml index 9d8d52e..4e7f44b 100644 --- a/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_room_room_runtime_2_2_5_aar.xml b/.idea/libraries/Gradle__androidx_room_room_runtime_2_2_5_aar.xml index 6512739..7a19601 100644 --- a/.idea/libraries/Gradle__androidx_room_room_runtime_2_2_5_aar.xml +++ b/.idea/libraries/Gradle__androidx_room_room_runtime_2_2_5_aar.xml @@ -1,11 +1,10 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml index cd46ce6..4e2d45b 100644 --- a/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml index c825e2e..7f1cf0a 100644 --- a/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_sqlite_sqlite_2_0_1_aar.xml b/.idea/libraries/Gradle__androidx_sqlite_sqlite_2_0_1_aar.xml index 4a9df9d..9d1d57b 100644 --- a/.idea/libraries/Gradle__androidx_sqlite_sqlite_2_0_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_sqlite_sqlite_2_0_1_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_sqlite_sqlite_framework_2_0_1_aar.xml b/.idea/libraries/Gradle__androidx_sqlite_sqlite_framework_2_0_1_aar.xml index e556688..27bf27a 100644 --- a/.idea/libraries/Gradle__androidx_sqlite_sqlite_framework_2_0_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_sqlite_sqlite_framework_2_0_1_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml index a6023b4..6d0f5de 100644 --- a/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_core_1_4_0_aar.xml b/.idea/libraries/Gradle__androidx_test_core_1_4_0_aar.xml index 2022e9a..3ea09fb 100644 --- a/.idea/libraries/Gradle__androidx_test_core_1_4_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_core_1_4_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml index aee91a4..c808a0f 100644 --- a/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_4_0_aar.xml b/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_4_0_aar.xml index 2f244c0..7536e07 100644 --- a/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_4_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_4_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml index e56a04d..a2f4de1 100644 --- a/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_4_0_aar.xml b/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_4_0_aar.xml index eff1647..9651c07 100644 --- a/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_4_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_4_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml b/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml index 47efe3f..21f654a 100644 --- a/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_3_aar.xml b/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_3_aar.xml index dafd0bd..a1baa0b 100644 --- a/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_3_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_3_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml index b6f1703..25f7e27 100644 --- a/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_monitor_1_4_0_aar.xml b/.idea/libraries/Gradle__androidx_test_monitor_1_4_0_aar.xml index 1031de7..a7bfcee 100644 --- a/.idea/libraries/Gradle__androidx_test_monitor_1_4_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_monitor_1_4_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml index 512d7e8..d87dcbb 100644 --- a/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_test_runner_1_4_0_aar.xml b/.idea/libraries/Gradle__androidx_test_runner_1_4_0_aar.xml index c19e72c..4898848 100644 --- a/.idea/libraries/Gradle__androidx_test_runner_1_4_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_runner_1_4_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml index e12eb5a..7574818 100644 --- a/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml index dd02ec8..923b76e 100644 --- a/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml index 98d9ca1..eb28695 100644 --- a/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml index 9cb307e..d85a289 100644 --- a/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml b/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml index e99155b..ce88471 100644 --- a/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml index c758de5..78f8967 100644 --- a/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml index d869eeb..0499c1c 100644 --- a/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__com_alibaba_fastjson_1_2_46.xml b/.idea/libraries/Gradle__com_alibaba_fastjson_1_2_46.xml index 819a55f..5491976 100644 --- a/.idea/libraries/Gradle__com_alibaba_fastjson_1_2_46.xml +++ b/.idea/libraries/Gradle__com_alibaba_fastjson_1_2_46.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_amitshekhar_android_debug_db_1_0_6_aar.xml b/.idea/libraries/Gradle__com_amitshekhar_android_debug_db_1_0_6_aar.xml index 6d9cc34..3a6129a 100644 --- a/.idea/libraries/Gradle__com_amitshekhar_android_debug_db_1_0_6_aar.xml +++ b/.idea/libraries/Gradle__com_amitshekhar_android_debug_db_1_0_6_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_amitshekhar_android_debug_db_base_1_0_6_aar.xml b/.idea/libraries/Gradle__com_amitshekhar_android_debug_db_base_1_0_6_aar.xml index 3fff01f..e37d251 100644 --- a/.idea/libraries/Gradle__com_amitshekhar_android_debug_db_base_1_0_6_aar.xml +++ b/.idea/libraries/Gradle__com_amitshekhar_android_debug_db_base_1_0_6_aar.xml @@ -1,39 +1,9 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/.idea/libraries/Gradle__com_andkulikov_transitionseverywhere_2_0_0_beta01_aar.xml b/.idea/libraries/Gradle__com_andkulikov_transitionseverywhere_2_0_0_beta01_aar.xml index 39566e8..3ccab73 100644 --- a/.idea/libraries/Gradle__com_andkulikov_transitionseverywhere_2_0_0_beta01_aar.xml +++ b/.idea/libraries/Gradle__com_andkulikov_transitionseverywhere_2_0_0_beta01_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_5_1_aar.xml b/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_5_1_aar.xml index 4d19277..6b5433c 100644 --- a/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_5_1_aar.xml +++ b/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_5_1_aar.xml @@ -1,56 +1,11 @@ - + - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/.idea/libraries/Gradle__com_github_bumptech_glide_annotations_4_10_0.xml b/.idea/libraries/Gradle__com_github_bumptech_glide_annotations_4_10_0.xml index af7cba6..7f95cc8 100644 --- a/.idea/libraries/Gradle__com_github_bumptech_glide_annotations_4_10_0.xml +++ b/.idea/libraries/Gradle__com_github_bumptech_glide_annotations_4_10_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_github_bumptech_glide_disklrucache_4_10_0.xml b/.idea/libraries/Gradle__com_github_bumptech_glide_disklrucache_4_10_0.xml index 80b664c..9f4a309 100644 --- a/.idea/libraries/Gradle__com_github_bumptech_glide_disklrucache_4_10_0.xml +++ b/.idea/libraries/Gradle__com_github_bumptech_glide_disklrucache_4_10_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_github_bumptech_glide_gifdecoder_4_10_0_aar.xml b/.idea/libraries/Gradle__com_github_bumptech_glide_gifdecoder_4_10_0_aar.xml index 89edd76..974046d 100644 --- a/.idea/libraries/Gradle__com_github_bumptech_glide_gifdecoder_4_10_0_aar.xml +++ b/.idea/libraries/Gradle__com_github_bumptech_glide_gifdecoder_4_10_0_aar.xml @@ -1,11 +1,10 @@ - + - diff --git a/.idea/libraries/Gradle__com_github_bumptech_glide_glide_4_10_0_aar.xml b/.idea/libraries/Gradle__com_github_bumptech_glide_glide_4_10_0_aar.xml index 027fb43..8bfcbae 100644 --- a/.idea/libraries/Gradle__com_github_bumptech_glide_glide_4_10_0_aar.xml +++ b/.idea/libraries/Gradle__com_github_bumptech_glide_glide_4_10_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_github_joeyupdo_YJTools_v1_0_5_aar.xml b/.idea/libraries/Gradle__com_github_joeyupdo_YJTools_v1_0_5_aar.xml index 7e9ddb3..c6a522c 100644 --- a/.idea/libraries/Gradle__com_github_joeyupdo_YJTools_v1_0_5_aar.xml +++ b/.idea/libraries/Gradle__com_github_joeyupdo_YJTools_v1_0_5_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_github_xy02_ARxLib_0_1_5_aar.xml b/.idea/libraries/Gradle__com_github_xy02_ARxLib_0_1_5_aar.xml index bd240a0..6b31694 100644 --- a/.idea/libraries/Gradle__com_github_xy02_ARxLib_0_1_5_aar.xml +++ b/.idea/libraries/Gradle__com_github_xy02_ARxLib_0_1_5_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_github_yuweiguocn_GreenDaoUpgradeHelper_v2_2_1_aar.xml b/.idea/libraries/Gradle__com_github_yuweiguocn_GreenDaoUpgradeHelper_v2_2_1_aar.xml index 51f425a..335665d 100644 --- a/.idea/libraries/Gradle__com_github_yuweiguocn_GreenDaoUpgradeHelper_v2_2_1_aar.xml +++ b/.idea/libraries/Gradle__com_github_yuweiguocn_GreenDaoUpgradeHelper_v2_2_1_aar.xml @@ -1,42 +1,8 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/.idea/libraries/Gradle__com_google_android_exoplayer_exoplayer_r1_5_11_aar.xml b/.idea/libraries/Gradle__com_google_android_exoplayer_exoplayer_r1_5_11_aar.xml deleted file mode 100644 index 44bb24f..0000000 --- a/.idea/libraries/Gradle__com_google_android_exoplayer_exoplayer_r1_5_11_aar.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_google_android_material_material_1_1_0_aar.xml b/.idea/libraries/Gradle__com_google_android_material_material_1_1_0_aar.xml index eb53151..5f85bdb 100644 --- a/.idea/libraries/Gradle__com_google_android_material_material_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__com_google_android_material_material_1_1_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_google_android_material_material_1_4_0_aar.xml b/.idea/libraries/Gradle__com_google_android_material_material_1_4_0_aar.xml index a425a34..b438965 100644 --- a/.idea/libraries/Gradle__com_google_android_material_material_1_4_0_aar.xml +++ b/.idea/libraries/Gradle__com_google_android_material_material_1_4_0_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1.xml b/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1.xml index 2b834ea..cda8019 100644 --- a/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1.xml +++ b/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_5.xml b/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_5.xml index c679021..e5f223d 100644 --- a/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_5.xml +++ b/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_5.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_jakewharton_disklrucache_2_0_2.xml b/.idea/libraries/Gradle__com_jakewharton_disklrucache_2_0_2.xml index 6b3961f..7dbe47e 100644 --- a/.idea/libraries/Gradle__com_jakewharton_disklrucache_2_0_2.xml +++ b/.idea/libraries/Gradle__com_jakewharton_disklrucache_2_0_2.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_liulishuo_filedownloader_library_1_7_5_aar.xml b/.idea/libraries/Gradle__com_liulishuo_filedownloader_library_1_7_5_aar.xml index 95adfe9..a5dc6b9 100644 --- a/.idea/libraries/Gradle__com_liulishuo_filedownloader_library_1_7_5_aar.xml +++ b/.idea/libraries/Gradle__com_liulishuo_filedownloader_library_1_7_5_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_orhanobut_logger_2_2_0_aar.xml b/.idea/libraries/Gradle__com_orhanobut_logger_2_2_0_aar.xml index e527686..4a36c01 100644 --- a/.idea/libraries/Gradle__com_orhanobut_logger_2_2_0_aar.xml +++ b/.idea/libraries/Gradle__com_orhanobut_logger_2_2_0_aar.xml @@ -1,42 +1,8 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/.idea/libraries/Gradle__com_permissionx_guolindev_permissionx_1_1_1_aar.xml b/.idea/libraries/Gradle__com_permissionx_guolindev_permissionx_1_1_1_aar.xml index 75562d4..df60b38 100644 --- a/.idea/libraries/Gradle__com_permissionx_guolindev_permissionx_1_1_1_aar.xml +++ b/.idea/libraries/Gradle__com_permissionx_guolindev_permissionx_1_1_1_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_arm64_8_1_2_aar.xml b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_arm64_8_1_2_aar.xml index 0a6fe1b..115816c 100644 --- a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_arm64_8_1_2_aar.xml +++ b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_arm64_8_1_2_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_armv5_8_1_2_aar.xml b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_armv5_8_1_2_aar.xml index 24078c1..694eb46 100644 --- a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_armv5_8_1_2_aar.xml +++ b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_armv5_8_1_2_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_armv7a_8_1_2_aar.xml b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_armv7a_8_1_2_aar.xml index 57e48f3..c9c915b 100644 --- a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_armv7a_8_1_2_aar.xml +++ b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_armv7a_8_1_2_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_base_8_1_2_aar.xml b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_base_8_1_2_aar.xml index e107f8d..867784e 100644 --- a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_base_8_1_2_aar.xml +++ b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_base_8_1_2_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_java_8_1_2_aar.xml b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_java_8_1_2_aar.xml index 73434da..a54c3ad 100644 --- a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_java_8_1_2_aar.xml +++ b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_java_8_1_2_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_x64_8_1_2_aar.xml b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_x64_8_1_2_aar.xml index 1fe4259..7f3acb2 100644 --- a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_x64_8_1_2_aar.xml +++ b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_x64_8_1_2_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_x86_8_1_2_aar.xml b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_x86_8_1_2_aar.xml index 826b547..e08ba64 100644 --- a/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_x86_8_1_2_aar.xml +++ b/.idea/libraries/Gradle__com_shuyu_gsyVideoPlayer_x86_8_1_2_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_shuyu_gsyvideoplayer_androidvideocache_8_1_2_aar.xml b/.idea/libraries/Gradle__com_shuyu_gsyvideoplayer_androidvideocache_8_1_2_aar.xml index de05a6a..55f26c5 100644 --- a/.idea/libraries/Gradle__com_shuyu_gsyvideoplayer_androidvideocache_8_1_2_aar.xml +++ b/.idea/libraries/Gradle__com_shuyu_gsyvideoplayer_androidvideocache_8_1_2_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1.xml b/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1.xml index 662b001..46341a3 100644 --- a/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1.xml +++ b/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_okhttp3_logging_interceptor_4_3_1.xml b/.idea/libraries/Gradle__com_squareup_okhttp3_logging_interceptor_4_3_1.xml index 75d6a1e..a8abbbf 100644 --- a/.idea/libraries/Gradle__com_squareup_okhttp3_logging_interceptor_4_3_1.xml +++ b/.idea/libraries/Gradle__com_squareup_okhttp3_logging_interceptor_4_3_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_1_0.xml b/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_1_0.xml index d792aab..d84509f 100644 --- a/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_1_0.xml +++ b/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_1_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_3_1.xml b/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_3_1.xml index 4c65c84..b788619 100644 --- a/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_3_1.xml +++ b/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_3_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_okio_okio_2_3_0.xml b/.idea/libraries/Gradle__com_squareup_okio_okio_2_3_0.xml index 7ed4348..b7449b8 100644 --- a/.idea/libraries/Gradle__com_squareup_okio_okio_2_3_0.xml +++ b/.idea/libraries/Gradle__com_squareup_okio_okio_2_3_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_okio_okio_2_4_1.xml b/.idea/libraries/Gradle__com_squareup_okio_okio_2_4_1.xml index f67c11b..efb5416 100644 --- a/.idea/libraries/Gradle__com_squareup_okio_okio_2_4_1.xml +++ b/.idea/libraries/Gradle__com_squareup_okio_okio_2_4_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_retrofit2_adapter_rxjava2_2_7_1.xml b/.idea/libraries/Gradle__com_squareup_retrofit2_adapter_rxjava2_2_7_1.xml index 16452ab..184f4ee 100644 --- a/.idea/libraries/Gradle__com_squareup_retrofit2_adapter_rxjava2_2_7_1.xml +++ b/.idea/libraries/Gradle__com_squareup_retrofit2_adapter_rxjava2_2_7_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_retrofit2_converter_gson_2_7_1.xml b/.idea/libraries/Gradle__com_squareup_retrofit2_converter_gson_2_7_1.xml index 23b2faa..6a73c28 100644 --- a/.idea/libraries/Gradle__com_squareup_retrofit2_converter_gson_2_7_1.xml +++ b/.idea/libraries/Gradle__com_squareup_retrofit2_converter_gson_2_7_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_retrofit2_converter_scalars_2_7_1.xml b/.idea/libraries/Gradle__com_squareup_retrofit2_converter_scalars_2_7_1.xml index facdcbf..65e13c1 100644 --- a/.idea/libraries/Gradle__com_squareup_retrofit2_converter_scalars_2_7_1.xml +++ b/.idea/libraries/Gradle__com_squareup_retrofit2_converter_scalars_2_7_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_squareup_retrofit2_retrofit_2_7_1.xml b/.idea/libraries/Gradle__com_squareup_retrofit2_retrofit_2_7_1.xml index 9d8b84f..9162cd9 100644 --- a/.idea/libraries/Gradle__com_squareup_retrofit2_retrofit_2_7_1.xml +++ b/.idea/libraries/Gradle__com_squareup_retrofit2_retrofit_2_7_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__com_zhouyou_rxeasyhttp_2_1_5_aar.xml b/.idea/libraries/Gradle__com_zhouyou_rxeasyhttp_2_1_5_aar.xml index 8089807..ad39536 100644 --- a/.idea/libraries/Gradle__com_zhouyou_rxeasyhttp_2_1_5_aar.xml +++ b/.idea/libraries/Gradle__com_zhouyou_rxeasyhttp_2_1_5_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml b/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml index 2e557f1..83c2aee 100644 --- a/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml +++ b/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml index 4f51d3f..ed9c23b 100644 --- a/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml +++ b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_2_17.xml b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_2_17.xml index 8c2c539..f81bce5 100644 --- a/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_2_17.xml +++ b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_2_17.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml b/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml index 62012ea..8154b06 100644 --- a/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +++ b/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__junit_junit_4_12.xml b/.idea/libraries/Gradle__junit_junit_4_12.xml index f7d27c4..c1ba9af 100644 --- a/.idea/libraries/Gradle__junit_junit_4_12.xml +++ b/.idea/libraries/Gradle__junit_junit_4_12.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__junit_junit_4_13_2.xml b/.idea/libraries/Gradle__junit_junit_4_13_2.xml index 198592d..e9404b1 100644 --- a/.idea/libraries/Gradle__junit_junit_4_13_2.xml +++ b/.idea/libraries/Gradle__junit_junit_4_13_2.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0.xml b/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0.xml index fbe9697..3918e71 100644 --- a/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0.xml +++ b/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__net_zetetic_android_database_sqlcipher_3_5_7_aar.xml b/.idea/libraries/Gradle__net_zetetic_android_database_sqlcipher_3_5_7_aar.xml index 0cabf77..6d922ff 100644 --- a/.idea/libraries/Gradle__net_zetetic_android_database_sqlcipher_3_5_7_aar.xml +++ b/.idea/libraries/Gradle__net_zetetic_android_database_sqlcipher_3_5_7_aar.xml @@ -1,8 +1,7 @@ - + - diff --git a/.idea/libraries/Gradle__org_greenrobot_greendao_3_3_0.xml b/.idea/libraries/Gradle__org_greenrobot_greendao_3_3_0.xml index 8b99426..bc4d4f0 100644 --- a/.idea/libraries/Gradle__org_greenrobot_greendao_3_3_0.xml +++ b/.idea/libraries/Gradle__org_greenrobot_greendao_3_3_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_greenrobot_greendao_api_3_3_0.xml b/.idea/libraries/Gradle__org_greenrobot_greendao_api_3_3_0.xml index 0592949..dd736b2 100644 --- a/.idea/libraries/Gradle__org_greenrobot_greendao_api_3_3_0.xml +++ b/.idea/libraries/Gradle__org_greenrobot_greendao_api_3_3_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml index 09cf23d..0a48d0d 100644 --- a/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3.xml index 1a77dd8..7c99fb6 100644 --- a/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3.xml +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3.xml index 3d45e8e..b3c5c0d 100644 --- a/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3.xml +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml b/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml index 1fa0fa9..012775f 100644 --- a/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml +++ b/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_61.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_61.xml index 3462c6f..d4f54cd 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_61.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_61.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_71.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_71.xml index a9a8b5e..cbd50cb 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_71.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_71.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_1_3_61.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_1_3_61.xml index 3e92ca6..462e3a4 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_1_3_61.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_1_3_61.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_41.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_41.xml index 20c3d80..f9b285d 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_41.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_41.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_71.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_71.xml index d281ded..781aadb 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_71.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_71.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_41.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_41.xml index f00e404..2e24395 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_41.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_41.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_71.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_71.xml index 56639f4..9381d36 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_71.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_71.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_61.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_61.xml index 711122d..acfd4c3 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_61.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_61.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_71.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_71.xml index 0f8c8cd..d465715 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_71.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_71.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_3_0.xml b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_3_0.xml index d2fd50f..1feb90b 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_3_0.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_3_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_1_3_0.xml b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_1_3_0.xml index b7c548b..f828c58 100644 --- a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_1_3_0.xml +++ b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_1_3_0.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_3.xml b/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_3.xml index 2e05a80..f5fd4fd 100644 --- a/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_3.xml +++ b/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_3.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__tv_danmaku_ijk_media_ijkplayer_exo_0_8_8_aar.xml b/.idea/libraries/Gradle__tv_danmaku_ijk_media_ijkplayer_exo_0_8_8_aar.xml index 7afbfcb..ea53401 100644 --- a/.idea/libraries/Gradle__tv_danmaku_ijk_media_ijkplayer_exo_0_8_8_aar.xml +++ b/.idea/libraries/Gradle__tv_danmaku_ijk_media_ijkplayer_exo_0_8_8_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/libraries/Gradle__tv_danmaku_ijk_media_ijkplayer_java_0_8_8_aar.xml b/.idea/libraries/Gradle__tv_danmaku_ijk_media_ijkplayer_java_0_8_8_aar.xml index cd6664c..5b2cddf 100644 --- a/.idea/libraries/Gradle__tv_danmaku_ijk_media_ijkplayer_java_0_8_8_aar.xml +++ b/.idea/libraries/Gradle__tv_danmaku_ijk_media_ijkplayer_java_0_8_8_aar.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index bc01c18..59eae42 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - \ No newline at end of file diff --git a/.idea/modules/app/taxiapp-ktl.app.iml b/.idea/modules/app/taxiapp-ktl.app.iml index ffd8e70..9054eda 100644 --- a/.idea/modules/app/taxiapp-ktl.app.iml +++ b/.idea/modules/app/taxiapp-ktl.app.iml @@ -3,7 +3,6 @@ - @@ -11,16 +10,11 @@ @@ -35,15 +29,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/kurolibrary/taxiapp-ktl.kurolibrary.iml b/.idea/modules/kurolibrary/taxiapp-ktl.kurolibrary.iml index 06795d9..76894b3 100644 --- a/.idea/modules/kurolibrary/taxiapp-ktl.kurolibrary.iml +++ b/.idea/modules/kurolibrary/taxiapp-ktl.kurolibrary.iml @@ -3,7 +3,6 @@ - @@ -11,16 +10,11 @@ @@ -36,11 +30,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/kurotool/taxiapp-ktl.kurotool.iml b/.idea/modules/kurotool/taxiapp-ktl.kurotool.iml index 192b1fc..e371261 100644 --- a/.idea/modules/kurotool/taxiapp-ktl.kurotool.iml +++ b/.idea/modules/kurotool/taxiapp-ktl.kurotool.iml @@ -3,7 +3,6 @@ - @@ -11,16 +10,11 @@ @@ -39,13 +33,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/taxiapp-ktl.iml b/.idea/modules/taxiapp-ktl.iml index 51f844c..11543a1 100644 --- a/.idea/modules/taxiapp-ktl.iml +++ b/.idea/modules/taxiapp-ktl.iml @@ -1,13 +1,5 @@ - - - - - - diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 18cb69c..81c5279 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,11 +18,13 @@ android { buildToolsVersion "29.0.2" defaultConfig { +// VehiclePlayer applicationId "net.sysolution.taxiapp" +// applicationId "net.sysolution.vehicleplayer" minSdkVersion 21 targetSdkVersion 29 - versionCode 257 - versionName "3.3.3-beta26.4.1.4-release" + versionCode 259 + versionName "3.3.3-beta26.4.1.7-release" //alphaxx - 预览版本,不会对外发布,由测试人员测试,会有很多bug //Betaxx - 公开测试版本,会发给其他工作人员,会有较多版本 @@ -65,7 +67,10 @@ android { 3.3.3-beta26.4.0.7-release 优化GPS上报,每次取250条数据,小于250条时等待8分钟后再次上传 3.3.3-beta26.4.1.2-release 修复收到的GPS卫星数量为0时频繁刷新问题 3.3.3-beta26.4.1.4-release 有GPS日志时,每次100条以内的日志进行上报,上报成功继续上报剩余的日志,传完为止,上报失败或无gps日志时,每隔2分钟后重新监测日志进行上报 - 3.3.3-beta26.4.1.5-release 修复有计次广告的时候重启后过了好几分钟才播的问题 + 3.3.3-beta26.4.1.5-release 修复有计次广告的时候重启后过了好几分钟才播的问题,2分钟存一次静止点 + 3.3.3-beta26.4.1.6-release 修复有计次广告的时候重启后过了好几分钟才播的问题,2分钟存一次静止点 + 3.3.3-beta26.4.1.7-release 增加分时段+计次功能,修复到次数的广告暂停不及时 + 暂没解决实际播放次数和上传次数不一致,因为日志大于10条才上传 **/ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -110,7 +115,9 @@ android { variant.outputs.all { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { +// outputFileName = "TaxiApp_v${defaultConfig.versionName}{${defaultConfig.versionCode}}.apk" outputFileName = "TaxiApp_v${defaultConfig.versionName}{${defaultConfig.versionCode}}.apk" +// outputFileName = "VehiclePlayer_v${defaultConfig.versionName}{${defaultConfig.versionCode}}.apk" } } } @@ -209,19 +216,24 @@ dependencies { // //exo // implementation 'com.google.android.exoplayer:exoplayer:2.8.1' -// implementation 'com.google.android.exoplayer:exoplayer:2.14.2' -// implementation 'com.google.android.exoplayer:exoplayer-core:2.14.2' -// implementation 'com.google.android.exoplayer:exoplayer-ui:2.14.2' + implementation 'com.google.android.exoplayer:exoplayer:2.14.2' + implementation 'com.google.android.exoplayer:exoplayer-core:2.14.2' + implementation 'com.google.android.exoplayer:exoplayer-ui:2.14.2' // implementation 'com.github.Trans88:KuroLibrary:0.1.3' implementation 'com.zhouyou:rxeasyhttp:2.1.5' implementation 'com.shuyu:gsyVideoPlayer-java:8.1.2' + implementation 'org.java-websocket:Java-WebSocket:1.5.7' + //根据你的需求ijk模式的so implementation 'com.shuyu:gsyVideoPlayer-armv5:8.1.2' implementation 'com.shuyu:gsyVideoPlayer-armv7a:8.1.2' implementation 'com.shuyu:gsyVideoPlayer-arm64:8.1.2' implementation 'com.shuyu:gsyVideoPlayer-x64:8.1.2' implementation 'com.shuyu:gsyVideoPlayer-x86:8.1.2' + +// implementation files('libs/jackson.jar') +// implementation files('libs/ormlite-android-4.45.jar') } diff --git a/app/libs/jackson.jar b/app/libs/jackson.jar new file mode 100644 index 0000000..9929c93 Binary files /dev/null and b/app/libs/jackson.jar differ diff --git a/app/libs/ormlite-android-4.45.jar b/app/libs/ormlite-android-4.45.jar new file mode 100644 index 0000000..9ba926c Binary files /dev/null and b/app/libs/ormlite-android-4.45.jar differ diff --git a/app/libs/ormlite-core-4.45.jar b/app/libs/ormlite-core-4.45.jar new file mode 100644 index 0000000..86f1192 Binary files /dev/null and b/app/libs/ormlite-core-4.45.jar differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 76b6fb8..7dbabfb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -80,6 +80,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/BootBroadcast.kt b/app/src/main/java/cn/trans88/taxiappkotlin/BootBroadcast.kt index e58a07f..37111a9 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/BootBroadcast.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/BootBroadcast.kt @@ -3,24 +3,27 @@ package cn.trans88.taxiappkotlin import android.content.BroadcastReceiver import android.content.Context import android.content.Intent +import android.os.Build +import androidx.annotation.RequiresApi import cn.trans88.taxiappkotlin.ui.play.PlayActivity import cn.trans88.taxiappkotlin.util.YoungUtil + /** * 系统启动广告唤醒activity */ class BootBroadcast : BroadcastReceiver() { + @RequiresApi(Build.VERSION_CODES.O) override fun onReceive(context: Context, intent: Intent) { val action = intent.action YoungUtil.YoungLog("BootBroadcast收到开机广播") if (null != action && action == Intent.ACTION_BOOT_COMPLETED) { - /* - val startActivity = Intent(context, PlayActivity::class.java) - startActivity.setPackage(context.packageName) - startActivity.flags = Intent.FLAG_ACTIVITY_NEW_TASK - context.startActivity(startActivity) - */ + +// val startActivity = Intent(context, PlayActivity::class.java) +// startActivity.setPackage(context.packageName) +// startActivity.flags = Intent.FLAG_ACTIVITY_NEW_TASK +// context.startActivity(startActivity) } } } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/NetworkChangeReceiver.java b/app/src/main/java/cn/trans88/taxiappkotlin/NetworkChangeReceiver.java new file mode 100644 index 0000000..47adecf --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/NetworkChangeReceiver.java @@ -0,0 +1,45 @@ +package cn.trans88.taxiappkotlin; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.os.RemoteException; +import android.util.Log; + +import com.google.gson.Gson; + +public class NetworkChangeReceiver extends BroadcastReceiver { + public Gson gson = new Gson(); + private Boolean b = false; + public static final String TAG = NetworkChangeReceiver.class.getSimpleName(); + public volatile static boolean isNetworkAvailable = false; + + @Override + public void onReceive(Context context, Intent intent) { + ConnectivityManager connectivityManager = (ConnectivityManager) TaxiApp.Companion.instance().getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();//获取网络状态 + System.out.println("网络状态改变"); + try { + if (!b) { + b = true; //conn重启会莫名触发一次,所以第一次不执行 + return; + } + if (activeNetworkInfo != null && activeNetworkInfo.isAvailable()) { + Log.d(TAG, "onReceive([context, intent]): 网络可用"); + isNetworkAvailable = true; + } else { + Log.d(TAG, "onReceive([context, intent]): 网络失效"); + isNetworkAvailable = false; + } + } catch (Exception e) { + Log.e(TAG, e.getMessage()); + } + } + +} + + + diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/TaxiApp.kt b/app/src/main/java/cn/trans88/taxiappkotlin/TaxiApp.kt index 5f6d86a..a9ede49 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/TaxiApp.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/TaxiApp.kt @@ -3,13 +3,12 @@ package cn.trans88.taxiappkotlin import android.app.Application import android.content.Context import android.content.Intent +import android.content.IntentFilter import android.media.MediaCodecList -import android.os.Looper import android.util.Log import cn.trans88.kurotool.util.LogLevel import cn.trans88.kurotool.util.LogUtil import cn.trans88.taxiappkotlin.ext.logd -import cn.trans88.taxiappkotlin.logic.Repository import cn.trans88.taxiappkotlin.logic.dao.DaoMaster import cn.trans88.taxiappkotlin.logic.dao.DaoSession import cn.trans88.taxiappkotlin.logic.dao.HelperDaoDB @@ -22,68 +21,82 @@ import cn.trans88.taxiappkotlin.logic.network.JoeyDownloadManager import cn.trans88.taxiappkotlin.net.BizInterceptor import cn.trans88.taxiappkotlin.ui.custom.JVideoView import cn.trans88.taxiappkotlin.ui.play.PlayActivity +import cn.trans88.taxiappkotlin.ui.play.PlayViewModel import cn.trans88.taxiappkotlin.util.DateUtil -import cn.trans88.taxiappkotlin.util.KuroTimer import cn.trans88.taxiappkotlin.util.YoungUtil import com.facebook.stetho.Stetho import com.google.gson.Gson import com.shuyu.gsyvideoplayer.player.IjkPlayerManager import com.shuyu.gsyvideoplayer.player.PlayerFactory import com.shuyu.gsyvideoplayer.utils.GSYVideoType -import com.trs88.kurolibrary.log.* +import com.trs88.kurolibrary.log.KuroConsolePrinter +import com.trs88.kurolibrary.log.KuroFileLogPrinter +import com.trs88.kurolibrary.log.KuroLogConfig +import com.trs88.kurolibrary.log.KuroLogManager +import com.trs88.kurolibrary.log.KuroLogType import com.trs88.kurolibrary.restful.retrofit.KuroApiFactory import com.zhouyou.http.EasyHttp import io.reactivex.plugins.RxJavaPlugins import tv.danmaku.ijk.media.player.IjkMediaPlayer -import java.io.* -import java.util.* +import java.io.BufferedWriter +import java.io.File +import java.io.IOException +import java.io.OutputStreamWriter +import java.util.Timer +import java.util.TimerTask import java.util.concurrent.CopyOnWriteArrayList -import kotlin.collections.ArrayList -import kotlin.collections.HashMap -import kotlin.collections.HashSet -class TaxiApp:Application() { + +class TaxiApp : Application() { private lateinit var daoSession: DaoSession private lateinit var daoMaster: DaoMaster + private lateinit var playViewModel: PlayViewModel var gson = Gson() var defaultBackgroundType = "" //缓存数据库所有广告 - var daoAds:CopyOnWriteArrayList = CopyOnWriteArrayList() + var daoAds: CopyOnWriteArrayList = CopyOnWriteArrayList() var cacheDaoAds: ArrayList = ArrayList() //缓存数据库regions - var regionsList:CopyOnWriteArrayList = CopyOnWriteArrayList() + var regionsList: CopyOnWriteArrayList = CopyOnWriteArrayList() - var nextVideoView:JVideoView? = null + var nextVideoView: JVideoView? = null var clearOrderTimer = Timer() var isDoubleClearOrder = 0 val timer = Timer() + //定时任务是否执行 - var isTimed:Boolean = false + var isTimed: Boolean = false + //单个广告里的定时任务 - val timerTaskMap = HashMap>() + val timerTaskMap = HashMap>() + //存储定时广告的列表 - var timedAds:ArrayList = ArrayList() + var timedAds: ArrayList = ArrayList() + //存储未上传成功的下载进度 - var processList:HashSet = HashSet() - var activity:PlayActivity? = null + var processList: HashSet = HashSet() + var activity: PlayActivity? = null //gps日志定时器 var gpsTimer: Timer? = null + //存储静止点坐标定时器 var quietGpsTimer: Timer? = null + //播放日志摘要定时器 var playerLogSummaryTimer: Timer? = null var testCount = 0 val TAG = "TaxiApp" - val poolSize = Runtime.getRuntime().availableProcessors()*2+1 -// lateinit var listener:Player.Listener + val poolSize = Runtime.getRuntime().availableProcessors() * 2 + 1 + + // lateinit var listener:Player.Listener // var player: SimpleExoPlayer? = null // lateinit var factory: ProgressiveMediaSource.Factory var sendLogTimes = 0 @@ -93,33 +106,41 @@ class TaxiApp:Application() { //是否软解码 var isSoftDecode = false - companion object{ - private var instance:Application? =null +// var executor = Executors.newSingleThreadExecutor(); + + companion object { + private var instance: Application? = null fun instance() = instance!! val XIXUN = "XIXUN"; + val LEDOK = "LEDOK"; val SANLE = "SANLE"; val HAOSHENG = "HAOSHENG"; val MAIDIER = "MAIDIER"; val isTest = false - val testCardid:String = "y60-a20-40919" + val testCardid: String = "y60-a20-40919" var isActive = false var startSyncMode = false // var isFirstRegister = true } +// private val executor: Executor = Executors.newSingleThreadExecutor() +// fun getExecutor(): Executor { +// return executor +// } + /** * 保存日志到卡内存 * @param text String */ - fun saveLog(text:String){ - try{ + fun saveLog(text: String) { + try { val output = openFileOutput("logs", Context.MODE_APPEND) val writer = BufferedWriter(OutputStreamWriter(output)) writer.use { writer.write("${DateUtil.nowTime()} :: $text") writer.newLine() //换行 } - } catch (e: IOException){ + } catch (e: IOException) { e.printStackTrace() } } @@ -142,9 +163,12 @@ class TaxiApp:Application() { //add by yzd @20211130 用config替换原有的配置文件 Configurations.config(this).init(); //初始化异常捕捉 //yzd 注释于20211110 - CrashHandler.getInstance(this).setInfo("熙讯ID", Configurations.config(TaxiApp.instance()).cardId()).setPost("").setDep(5).init() + CrashHandler.getInstance(this) + .setInfo("熙讯ID", Configurations.config(TaxiApp.instance()).cardId()).setPost("") + .setDep(5).init() - KuroApiFactory.initRetrofit("http://taxihub.cn:2346/v1/cms/taxi/").setInterceptor(BizInterceptor()) + KuroApiFactory.initRetrofit("http://taxihub.cn:2346/v1/cms/taxi/") + .setInterceptor(BizInterceptor()) setLogUtil() @@ -161,7 +185,7 @@ class TaxiApp:Application() { // if (types[j].equals("video/avc", ignoreCase = true)) { // if (types[j].contains("decoder", ignoreCase = true)) { // Log.e("yzd_t", "Found AVC decoder: " + codec.getName()) - Log.e("yzd_t", "Found decoder: " + codec.getName()) + Log.e("yzd_t", "Found decoder: " + codec.getName()) // } } } @@ -187,7 +211,7 @@ class TaxiApp:Application() { initKuroLog() //edit by yzd //安卓8以上不允许后台启动服务 - if(!TaxiApp.isActive) { + if (!TaxiApp.isActive) { val startActivity = Intent(this, PlayActivity::class.java) startActivity.setPackage(this.packageName) startActivity.flags = Intent.FLAG_ACTIVITY_NEW_TASK @@ -195,20 +219,39 @@ class TaxiApp:Application() { } Thread(Runnable { - Thread.sleep(10*1000) + Thread.sleep(10 * 1000) val file = File(filesDir, "/log") YoungUtil.RecursionDeleteFile(file) }).start() + + registerNetworkChangeReceiver() //配置exoPlayer的player // initPlayer() + //TODO + //初始化socket,不通过三平台直接接收ledok的节目 +// startConnect() +// Thread { +// TaskSocketServer(this, 3338).listen() +// }.start() + } +// var ss: TaskSocketServer? = null + +// private fun startConnect() { +// ThreadProcessor.getInstance().addThread { +// ss = TaskSocketServer(this, 3338) +// ss!!.listen() +// Log.d(TAG, "startConnect: ss is null ${ss == null}") +// } +// } + /** * 获取daoSession * @return DaoSession */ - fun getDaoSession():DaoSession{ + fun getDaoSession(): DaoSession { return daoSession } @@ -216,18 +259,18 @@ class TaxiApp:Application() { * 获取DaoMaster * @return DaoMaster */ - fun getDaoMaster():DaoMaster{ + fun getDaoMaster(): DaoMaster { return daoMaster } private fun initKuroLog() { val file = File(filesDir, "/log") - if (!file.exists()){ + if (!file.exists()) { file.mkdirs() } - KuroLogManager.init(object : KuroLogConfig(){ + KuroLogManager.init(object : KuroLogConfig() { // override fun injectJsonParser(): JsonParser { // return JsonParser { // Gson().toJson(it) @@ -253,7 +296,7 @@ class TaxiApp:Application() { override fun printLogLevel(): Int { return KuroLogType.V } - }, KuroConsolePrinter(), KuroFileLogPrinter.getInstance(file.path, 3*24*60*60*1000)) + }, KuroConsolePrinter(), KuroFileLogPrinter.getInstance(file.path, 3 * 24 * 60 * 60 * 1000)) } private fun setRxJavaErrorHandler() { @@ -266,10 +309,10 @@ class TaxiApp:Application() { * 删除缓存列表的单个广告 * @param advertise Advertise */ - fun removeCacheAd(advertise: Advertise){ + fun removeCacheAd(advertise: Advertise) { var index = 0; for (daoAd in daoAds) { - if (daoAd.ad_id.equals(advertise.ad_id)){ + if (daoAd.ad_id.equals(advertise.ad_id)) { index = daoAds.indexOf(daoAd) break } @@ -280,17 +323,17 @@ class TaxiApp:Application() { /** * 更新集合里的Region */ - fun updateCacheRegions(newRegion: Regions){ + fun updateCacheRegions(newRegion: Regions) { //edit by ljh @2023/8/11 var index = -1 for (region in regionsList) { - if (newRegion.autoId == region.autoId){ + if (newRegion.autoId == region.autoId) { index = regionsList.indexOf(region) } } if (index != -1) { regionsList.removeAt(index) - regionsList.add(index,newRegion) + regionsList.add(index, newRegion) "updateCacheRegions:${newRegion.regionAdId},autoId:${newRegion.autoId}".logd() } "updateCacheRegions:${index}".logd() @@ -300,32 +343,41 @@ class TaxiApp:Application() { * 更新集合里的广告 * @param newAdvertise Advertise */ - fun updateCacheAdvertise(newAdvertise: Advertise){ + fun updateCacheAdvertise(newAdvertise: Advertise) { "updateCacheAdvertise:${newAdvertise}".logd() var index = -1 for (daoAd in daoAds) { - if (newAdvertise.ad_id.equals(daoAd.ad_id)){ + if (newAdvertise.ad_id.equals(daoAd.ad_id)) { index = daoAds.indexOf(daoAd) } } if (index != -1) { daoAds.removeAt(index) - daoAds.add(index,newAdvertise) + daoAds.add(index, newAdvertise) } } - private fun setLogUtil(){ + private fun setLogUtil() { val file = File(filesDir, "/log") - if (!file.exists()){ + if (!file.exists()) { file.mkdirs() } - val dest =File(file,"/log.txt") - if(!dest.exists()){ + val dest = File(file, "/log.txt") + if (!dest.exists()) { dest.createNewFile() } - LogUtil.setShowLevel(LogLevel.V).setLogWriteFile(dest).setLogWriteEnable(Configurations.config(TaxiApp.instance()).enableWriteLog()) + LogUtil.setShowLevel(LogLevel.V).setLogWriteFile(dest) + .setLogWriteEnable(Configurations.config(TaxiApp.instance()).enableWriteLog()) + } + + private lateinit var networkChangeReceiver: NetworkChangeReceiver + private fun registerNetworkChangeReceiver() { + networkChangeReceiver = NetworkChangeReceiver() + val filter = IntentFilter() + filter.addAction("android.net.conn.CONNECTIVITY_CHANGE") + registerReceiver(networkChangeReceiver, filter) } } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/aidl/localserver/TaxiServiceAIDL.kt b/app/src/main/java/cn/trans88/taxiappkotlin/aidl/localserver/TaxiServiceAIDL.kt index 33773a8..b9546fd 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/aidl/localserver/TaxiServiceAIDL.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/aidl/localserver/TaxiServiceAIDL.kt @@ -66,7 +66,6 @@ class TaxiServiceAIDL:Service() { if (bindModel.server != null && bindModel.server!=""){ bindModel.server = bindModel.server+"/" } - if (bindModel.server != null && bindModel.server!=""){ bindModel.tlsServer = bindModel.tlsServer+"/" } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkActivity.kt b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkActivity.kt new file mode 100644 index 0000000..afab06a --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkActivity.kt @@ -0,0 +1,252 @@ +package cn.trans88.taxiappkotlin.ledok + +import android.content.Context +import android.graphics.BitmapFactory +import android.media.MediaPlayer +import android.net.Uri +import android.os.Bundle +import android.os.Handler +import android.util.DisplayMetrics +import android.util.Log +import android.view.View +import android.view.WindowManager +import android.widget.FrameLayout +import android.widget.ImageView +import android.widget.VideoView +import androidx.appcompat.app.AppCompatActivity +import cn.trans88.taxiappkotlin.R +import cn.trans88.taxiappkotlin.TaxiApp +import com.google.android.exoplayer2.ExoPlayer +import com.google.android.exoplayer2.MediaItem +import com.google.android.exoplayer2.Player +import com.google.android.exoplayer2.SimpleExoPlayer +import com.google.android.exoplayer2.ui.AspectRatioFrameLayout +import com.google.android.exoplayer2.ui.PlayerView +import java.io.File + +class LedOkActivity : AppCompatActivity() { + companion object { + const val TAG = "LedOkActivity" + private var instance: LedOkActivity? = null + fun instance() = instance + + fun isPersistPlay(): Boolean { + return TaxiApp.instance().getSharedPreferences("config", Context.MODE_PRIVATE) + .getBoolean("isPlayLedOkActivity", false); + } + fun persistPlay() { + TaxiApp.instance().getSharedPreferences("config", Context.MODE_PRIVATE) + .edit().putBoolean("isPlayLedOkActivity", true).commit() + } + fun cancelPersistPlay() { + TaxiApp.instance().getSharedPreferences("config", Context.MODE_PRIVATE) + .edit().putBoolean("isPlayLedOkActivity", false).commit() + } + } + + private lateinit var exoPlayer: ExoPlayer + private lateinit var playerView: PlayerView + + private lateinit var videoView: LedOkVideoView + + private lateinit var imageView: ImageView + private lateinit var frameLayout: FrameLayout + private lateinit var handler: Handler + private lateinit var playList: ArrayList + private var currentIndex: Int = 0 + private lateinit var screen: Pair + + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + instance = this + setContentView(R.layout.activity_ledok) + enterFullScreen() + screen = getScreenResolution(this) + Log.d(TAG, "onCreate: width:${screen.first}, height:${screen.second}") + exoPlayer = SimpleExoPlayer.Builder(this).build() + playerView = createPlayerView() + handler = Handler() + imageView = createImageView() + videoView = createVideoView() + frameLayout = createFrameLayout() + startPlayback() + } + + /** + * 动态创建图片视图 + */ + private fun createImageView(): ImageView { + return ImageView(this).apply { + layoutParams = FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT + ) + scaleType = ImageView.ScaleType.FIT_XY + layoutParams.width = screen.first + layoutParams.height = screen.second + } + } + + + /** + * 动态创建视频视图 + * 不推荐使用 + */ + private fun createVideoView(): LedOkVideoView { + return LedOkVideoView(this).apply { + layoutParams = FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT // 你可以根据需要设置高度 + ) + layoutParams.width = screen.first + layoutParams.height = screen.second + + setOnPreparedListener { mediaPlayer: MediaPlayer -> + mediaPlayer.start() + mediaPlayer.setOnCompletionListener { + playNext() + } + } + setOnErrorListener { _, _, _ -> + playNext() + true + } + } + } + + /** + * 动态创建视频视图 + */ + private fun createPlayerView(): PlayerView { + return PlayerView(this).apply { + layoutParams = FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT + ) + fitsSystemWindows = false + layoutParams.width = screen.first + layoutParams.height = screen.second + // 拉伸全屏 + resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL + // 隐藏控制器 + useController = false + // 关闭缓冲显示 + setShowBuffering(PlayerView.SHOW_BUFFERING_NEVER) + player = exoPlayer.apply { + playWhenReady = true + addListener(object : Player.Listener { + override fun onPlaybackStateChanged(playbackState: Int) { + if (playbackState == Player.STATE_ENDED) { + playNext() + } + } + }) + } + } + } + + private fun createFrameLayout(): FrameLayout { + return findViewById(R.id.ledok_layout).apply { + addView(videoView) + addView(imageView) + addView(playerView) + } + } + + private fun startPlayback() { + playList = intent.getParcelableArrayListExtra(LedOkCommands.PLAYLIST) + currentIndex = -1 + playNext() + } + + private fun playNext() { + currentIndex = (currentIndex + 1) % playList.size + val currentItem = playList[currentIndex] + when (currentItem.type) { + "image" -> playImage(currentItem) +// "video" -> playVideo(currentItem) + "video" -> playPlayer(currentItem) + } + } + + private fun playImage(item: Item) { + imageView.setImageBitmap(BitmapFactory.decodeFile(File(item.path).absolutePath)) + + playerView.visibility = PlayerView.GONE + imageView.visibility = ImageView.VISIBLE + + handler.postDelayed({ + playNext() + }, (item.time * 1000).toLong()) + Log.d(TAG, "playImage: ${item.name}, ${item.path}") + } + + private fun playVideo(item: Item) { + imageView.visibility = ImageView.GONE + videoView.setVideoURI(Uri.parse(item.path)) + videoView.visibility = VideoView.VISIBLE + +// enterFullScreen() + Log.d(TAG, "playVideo: ${item.name}") + } + + private fun playPlayer(item: Item) { + if (!File(item.path).exists()) { + playNext() + } + exoPlayer.setMediaItem(MediaItem.fromUri(item.path)) + exoPlayer.prepare() + imageView.visibility = ImageView.GONE + playerView.visibility = VideoView.VISIBLE + Log.d(TAG, "playPlayer: ${item.name}, ${item.path}") + } + + private fun enterFullScreen() { + window.decorView.systemUiVisibility = ( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_FULLSCREEN + or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + ) + supportActionBar?.hide() + } + + override fun onWindowFocusChanged(hasFocus: Boolean) { + super.onWindowFocusChanged(hasFocus) + if (hasFocus) { + enterFullScreen() // 确保在窗口聚焦时保持全屏 + } + } + + + private fun getScreenResolution(context: Context): Pair { + val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager + val displayMetrics = DisplayMetrics() + windowManager.defaultDisplay.getRealMetrics(displayMetrics) + return Pair(displayMetrics.widthPixels, displayMetrics.heightPixels) + } + + override fun onResume() { + super.onResume() + persistPlay() + exoPlayer?.play() + } + + override fun onPause() { + super.onPause() + exoPlayer?.pause() + } + + + override fun onDestroy() { + super.onDestroy() + exoPlayer?.release() + videoView?.stopPlayback() + handler?.removeCallbacksAndMessages(null) + frameLayout?.removeAllViews() + Log.d(TAG, "onDestroy: ") + } +} \ No newline at end of file diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkAdvertise.kt b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkAdvertise.kt new file mode 100644 index 0000000..965fa14 --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkAdvertise.kt @@ -0,0 +1,66 @@ +package cn.trans88.taxiappkotlin.ledok + +import android.os.Parcel +import android.os.Parcelable +import cn.trans88.taxiappkotlin.logic.model.BindModel + +data class LedOkAdvertise( + val type: String, + val task: Task +) + +data class LedOkBindModel( + val _type: String, + val bindModel: BindModel +) + +data class BingModel( + val action: String, + val accountIdToken: String, + val server: String, + val tlsServer: String +) + +data class Task( + val taskId: String, + val items: List +) + +data class Item( + val itemId: String, + val type: String, + val name: String, + val time: Int, + var path: String +) : Parcelable { + constructor(parcel: Parcel) : this( + parcel.readString()!!, + parcel.readString()!!, + parcel.readString()!!, + parcel.readInt()!!, + parcel.readString()!! + ) { + } + + override fun writeToParcel(parcel: Parcel, flags: Int) { + parcel.writeString(itemId) + parcel.writeString(type) + parcel.writeString(name) + parcel.writeInt(time) + parcel.writeString(path) + } + + override fun describeContents(): Int { + return 0 + } + + companion object CREATOR : Parcelable.Creator { + override fun createFromParcel(parcel: Parcel): Item { + return Item(parcel) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } +} diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkCommands.kt b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkCommands.kt new file mode 100644 index 0000000..a2ac0fe --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkCommands.kt @@ -0,0 +1,378 @@ +package cn.trans88.taxiappkotlin.ledok + + +import android.content.Intent +import android.os.Build +import android.os.Environment +import android.os.FileUtils +import android.util.Base64 +import android.util.Log +import androidx.annotation.RequiresApi +import cn.trans88.taxiappkotlin.R +import cn.trans88.taxiappkotlin.TaxiApp +import cn.trans88.taxiappkotlin.TaxiApp.Companion.instance +import cn.trans88.taxiappkotlin.logic.network.JoeyDownloadListener +import cn.trans88.taxiappkotlin.play.kuroPlay.IKuroPlay +import com.google.gson.Gson +import com.liulishuo.filedownloader.BaseDownloadTask +import com.liulishuo.filedownloader.FileDownloadListener +import com.liulishuo.filedownloader.FileDownloader +import org.java_websocket.WebSocket +import java.io.BufferedReader +import java.io.File +import java.io.FileOutputStream +import java.io.FileReader +import java.io.IOException +import java.io.OutputStream +import java.net.NetworkInterface +import java.net.SocketException +import java.nio.ByteBuffer +import java.util.concurrent.CountDownLatch +import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType + +object LedOkCommands { + + private var countDownLatch: CountDownLatch? = null + val gson = Gson() + private const val BASEURL_DOWNLOAD = "http://192.168.1.12:8088/download/" + private const val PATH_DOWNLOAD = "/taxiapp/download" + + public const val PLAYLIST = "LedOkCommands:playlist" + + private const val TAG = "LedOkCommands" + val playlist: MutableList = mutableListOf() + private var currentFile: String? = null + + val downloadDir = File( + TaxiApp.instance().filesDir, + TaxiApp.instance().getString(R.string.dir_program) + ) + + + fun startLedOkActivity() { + try { + val downloadDir = File( + TaxiApp.instance().filesDir, + TaxiApp.instance().getString(R.string.dir_program) + ) + val jsonPath = "${downloadDir}/program"; + var taskJson = readFileContent(jsonPath); + val ledOkAdvertise: LedOkAdvertise = + Gson().fromJson(taskJson, LedOkAdvertise::class.java) + playlist.clear() + for (item in ledOkAdvertise.task.items) { + item.path = "${downloadDir}/${item.itemId}" + Log.d(TaskSocketServer.TAG, "processPackage: path: ${item.path}") + playlist.add(item) + } + if (playlist.isNotEmpty()) { + LedOkActivity.persistPlay() + val applicationContext = instance().applicationContext + val intent = Intent(applicationContext, LedOkActivity::class.java) + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP) + intent.putExtra(PLAYLIST, java.util.ArrayList(playlist)) + applicationContext.startActivity(intent) + } else { + Log.d(TaskSocketServer.TAG, "processPackage: 播放列表 $playlist") + } + } catch (e: Exception) { + e.printStackTrace() + } + } + + + fun readFileContent(fileName: String?): String? { + val file = File(fileName) + if (!file.exists()) { + return null + } + var reader: BufferedReader? = null + val sbf = StringBuffer() + try { + reader = BufferedReader(FileReader(file)) + var tempStr: String? + while ((reader.readLine().also { tempStr = it }) != null) { + sbf.append(tempStr) + } + reader.close() + return sbf.toString() + } catch (e: IOException) { + e.printStackTrace() + } finally { + if (reader != null) { + try { + reader.close() + } catch (e1: IOException) { + e1.printStackTrace() + } + } + } + return sbf.toString() + } + /** + * ledok平台的命令 + */ + fun executeByLedOk(conn: WebSocket, command: String) { + Log.d(TAG, "executeByLedOk: command: $command") + try { + val ledOkAdvertise = gson.fromJson(command, LedOkAdvertise::class.java) + Log.d(TAG, "executeByLedOk: baskTask: $ledOkAdvertise") + if (ledOkAdvertise.type != null) { + when (ledOkAdvertise.type) { + "consult" -> consult(conn, ledOkAdvertise) + "proStart" -> proStart(conn, ledOkAdvertise) + "fileStart" -> fileStart(conn, ledOkAdvertise) + "fileEnd" -> fileEnd(conn, ledOkAdvertise) + "proEnd" -> proEnd(conn, ledOkAdvertise) + else -> Log.w(TAG, "executeByLedOk: 三乐 未知命令") + } + } + } catch (e: Exception) { + Log.e(TAG, "executeByLedOk: 三乐长连接执行命令出现异常: ${e.printStackTrace()}") + } + } + + fun consult(conn: WebSocket, ledOkAdvertise: LedOkAdvertise) { +// if ("program".equals(ledOkAdvertise.proName)) { + val items = ledOkAdvertise.task.items + val idList: MutableList = mutableListOf() + playlist.clear() + for (item in items) { + val file = File("${downloadDir.absolutePath}/${item.itemId}") + if (!file.exists()) { + idList.add(item.itemId) + } + item.path = file.absolutePath + playlist.add(item) + } + val resMap = HashMap() + resMap["type"] = "consult" + resMap["idList"] = idList + conn.send(gson.toJson(resMap)) +// } + } + + fun proStart(conn: WebSocket, ledOkAdvertise: LedOkAdvertise) { + Log.d(TAG, "proStart: ") + } + + + fun fileStart(conn: WebSocket, ledOkAdvertise: LedOkAdvertise) { + Log.d(TAG, "fileStart: ") + currentFile = ledOkAdvertise.task.items[0].itemId + Log.d(TAG, "fileStart: currentFIle: $currentFile") + } + + fun fileEnd(conn: WebSocket, ledOkAdvertise: LedOkAdvertise) { + Log.d(TAG, "fileEnd: ") + val currentFilePath = File("${downloadDir.absolutePath}/$currentFile") + Log.d(TAG, "fileEnd: currentFilePath: $currentFilePath") +// if (!currentFilePath.exists()) { +// val resMap = HashMap() +// resMap["type"] = "AckFailed" +// conn.send(gson.toJson(resMap)) +// } else { +// currentFile = null +// } + currentFile = null + } + + fun proEnd(conn: WebSocket, ledOkAdvertise: LedOkAdvertise) { + Log.d(TAG, "proEnd: ") + playAdvertise(ledOkAdvertise) + val resMap = HashMap() + resMap["type"] = "AckSuccess" + conn.send(gson.toJson(resMap)) + } + + + fun receiveFile(conn: WebSocket, message: ByteBuffer) { + Log.d(TAG, "executeByLedOk: command: ") + try { + val data = ByteArray(message.remaining()); + message.get(data) + val downloadDir = File( + TaxiApp.instance().filesDir, + TaxiApp.instance().getString(R.string.dir_program) + ) + if (!downloadDir.exists()) { + downloadDir.mkdirs() + } + Log.d(TAG, "prepareAdvertise: downloadDir: " + downloadDir.absolutePath) + val downloadFile = File("${downloadDir.absolutePath}/$currentFile") + FileOutputStream(downloadFile).use { outputStream -> + outputStream.write(data) + } + } catch (e: Exception) { + Log.e(TAG, "executeByLedOk: 三乐长连接执行命令出现异常: ${e.printStackTrace()}") + val resMap = HashMap() + resMap["type"] = "AckFailed" + conn.send(gson.toJson(resMap)) + } + } + + + /** + * 播放广告 + */ + private fun playAdvertise(advertise: LedOkAdvertise) { + Log.d(TAG, "playAdvertise: 开始播放") + val context = TaxiApp.instance().applicationContext + var intent = Intent(context, LedOkActivity::class.java) + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP) + intent.putExtra(PLAYLIST, ArrayList(playlist)) + TaxiApp.instance().applicationContext.startActivity(intent) + } + + +// /** +// * 放置广告 +// * 1. 处理ledOk指定类型广告 +// * 2. 转换为可播放广告 +// * 3. 准备播放广告, 下载资源文件 +// * 4. 播放节目 +// */ +// private fun placeTaskAd(conn: WebSocket, ledOkAdvertise: LedOkAdvertise) { +//// val ledOkAdvertise = addLedOkAdvertise(task, type); +//// val advertise = ledOkAdvertiseToAdvertise(ledOkAdvertise) +//// val taskId = ledOkAdvertise.task.task_id +//// val items = ledOkAdvertise.task.items +// +//// prepareAdvertise(ledOkAdvertise) +// playAdvertise(ledOkAdvertise) +// +// val resMap = HashMap() +// resMap.put("code", 200) +// resMap.put("message", "success") +// resMap.put("data", null) +// resMap.put("errors", null) +// conn.send(gson.toJson(resMap)) +// } + + /** + * 添加ledok广告 + */ +// private fun addLedOkAdvertise(task: String, type: String): LedOkAdvertise { +// val ledOkAdvertise = gson.fromJson(task, LedOkAdvertise::class.java) +// Log.d(TAG, "addLedOkAdvertise: 刚收到的添加三乐广告命令,还没有做处理的${ledOkAdvertise}") +// ledOkAdvertise.apply { +// val program = File( +// TaxiApp.instance().filesDir, +// TaxiApp.instance().getString(R.string.dir_program) +// ) +// val dest = File(program, this.task_id) +// belongTo = AdvertiseType.GROUP.ordinal +// pathName = dest.path +// //#edit by ljh 2023/2/6 +// isCount = false +// isTimedAd = false +// if (time_section != null && time_section.size > 0) { +// isTimedAd = true +// Log.d(TAG, "addLedOkAdvertise: ${task_id}是分时段播放广告,后面再判断是否计次") +// } else if (play_numbers > 0) { +// isCount = true +// Log.d( +// TAG, +// "addLedOkAdvertise: ${task_id}计次播放,该广告播放次数为${ledOkAdvertise.play_numbers}" +// ) +// } +// Log.d(TAG, "addLedOkAdvertise: mxkl_url:$mxkl_url") +// } +// +// val ledOkTaskIds = LedOkRepository.getLedOkTaskIds() +// +// if (!ledOkTaskIds.contains(ledOkAdvertise.task_id)) { +// LedOkRepository.insert(ledOkAdvertise) +// } +// return ledOkAdvertise; +// } + + + /** + * ledok广告转播放的广告 + */ +// private fun ledOkAdvertiseToAdvertise(ledOkAdvertise: LedOkAdvertise): Advertise { +// return Advertise().apply { +// belongTo = ledOkAdvertise.belongTo +// ad_id = ledOkAdvertise.task_id +// id = ledOkAdvertise.id +// media_type = ledOkAdvertise.media_type +// media_url = ledOkAdvertise.media_url +// pathName = ledOkAdvertise.pathName +// duration = ledOkAdvertise.duration +// createAt = ledOkAdvertise.createAt +// +// play_numbers = ledOkAdvertise.play_numbers +// isCount = ledOkAdvertise.isCount +// mxkl_url = ledOkAdvertise.mxkl_url +// +// isTimedAd = ledOkAdvertise.isTimedAd +// is_exclusive = ledOkAdvertise.is_exclusive +// time_Span = ledOkAdvertise.time_span +// time_section = ledOkAdvertise.time_section +// } +// } + + + /** + * 准备广告 + */ +// @Synchronized +// private fun prepareAdvertise(advertise: LedOkAdvertise) { +// Log.d(TAG, "prepareAdvertise: 准备节目") +//// val downloadDir = +//// Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) +// val downloadDir = File( +// TaxiApp.instance().filesDir, +// TaxiApp.instance().getString(R.string.dir_program) +// ) +// if (!downloadDir.exists()) { +// downloadDir.mkdirs() +// } +// Log.d(TAG, "prepareAdvertise: downloadDir: " + downloadDir.absolutePath) +// val items = advertise.task.items +// countDownLatch = CountDownLatch(items.size) +// playlist.clear() +// for (item in items) { +// val itemId = item.item_id +// val name = item.name +// val downloadUrl = item.path +// val savePathName = "$downloadDir/LedOk-$itemId-$name" +// val downloadFile = downloadFile(downloadUrl, savePathName, itemId) +// playlist.add(downloadFile) +// } +// countDownLatch?.await(); +// } + + /** + * 下载文件 + */ +// private fun downloadFile(downloadUrl: String, pathName: String, itemId: String): String { +// val file = File(pathName) +// if (file.exists()) { +// Log.d(TAG, "downloadFile: 本地存在,停止下载") +// countDownLatch?.countDown() +// } else { +// Log.d(TAG, "downloadFile: 本地不存在,开始下载") +// FileDownloader.getImpl() +// .create(downloadUrl) +// .setPath(pathName) +// .setTag(itemId) +// .setListener(object : JoeyDownloadListener() { +// override fun completed(task: BaseDownloadTask?) { +// super.completed(task) +// countDownLatch?.countDown() +// } +// +// override fun error(task: BaseDownloadTask?, e: Throwable?) { +// super.error(task, e) +// countDownLatch?.countDown() +// } +// }) +// .start() +// } +// return pathName; +// } + + +} \ No newline at end of file diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkVideoView.kt b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkVideoView.kt new file mode 100644 index 0000000..3333004 --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/LedOkVideoView.kt @@ -0,0 +1,16 @@ +package cn.trans88.taxiappkotlin.ledok + +import android.content.Context +import android.util.AttributeSet +import android.widget.VideoView + +class LedOkVideoView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : VideoView(context, attrs) { + + override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec) + setMeasuredDimension(widthMeasureSpec, heightMeasureSpec) + } + +} \ No newline at end of file diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ledok/TaskProcessor.java b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/TaskProcessor.java new file mode 100644 index 0000000..8f56e8c --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/TaskProcessor.java @@ -0,0 +1,984 @@ +package cn.trans88.taxiappkotlin.ledok; + +import android.content.Context; +import android.text.TextUtils; +import android.util.Log; + +import com.trs88.kurolibrary.log.KuroLog; + +import java.util.Timer; + +import cn.trans88.taxiappkotlin.TaxiApp; + +public class TaskProcessor { + + public static class TaskState { + public static int TaskIsNull = 0; + public static int TaskItemIsNull = 1; + public static int ItemProgramIsNull = 2; + public static int LayerIsNull = 3; + public static int LayerSourcesIsNull = 4; + public static int SourcesIsNull = 5; + public static int TaskIsRight = 6; + } + + private static volatile TaskProcessor taskProcessor; + private Context context; + public boolean existTimeSend = false; + private Timer timerSend; + + public static synchronized TaskProcessor getInstance(Context context) { + if (taskProcessor == null) { + synchronized (TaxiApp.Companion.instance()) { + taskProcessor = new TaskProcessor(context); + } + } + return taskProcessor; + } + + private TaskProcessor(Context context) { + this.context = context; + } + + + + +// public void addM2mZipTask(String data) throws Exception { +// if (TextUtils.isEmpty(data)) return; +// boolean flag = false; +// KuroLog.i("TAG", "开始添加平台U盘任务"); +// Log.i("TAG", "开始添加平台U盘任务"); +// Commands command = null; +// try { +// PlayXixunTaskCommand commandp = JsonMapper.getInstance().readValue(data, PlayXixunTaskCommand.class); +// command = new Commands(commandp.id, commandp.preDownloadURL, commandp.notificationURL, JsonMapper.getInstance().writeValueAsString(commandp.task)); +// flag = false; +// } catch (Exception e) { +// ProgramBean programBean = JsonMapper.getInstance().readValue(data, ProgramBean.class); +// //防止重新下载 +// programBean.totalSize = 0; +// TaskItem item = new TaskItem(); +// item._program = programBean; +// List list = new ArrayList<>(); +// list.add(item); +// CommandTask commandTask = new CommandTask(); +// commandTask.items = list; +// commandTask.cmdId = programBean._id; +// commandTask._id = programBean._id; +// command = new Commands(programBean._id, null, null, JsonMapper.getInstance().writeValueAsString(commandTask)); +// flag = true; +// } +// int tasktstate = correctTask(command, flag); +// if (tasktstate == TaskState.TaskIsRight) { +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(Commands.class); +// //判断是否已经存在,若果已经存在修改表中数据,否则创建新的数据 +// if (dao != null) { +// try { +// //edit by ljh on @2024/3/7,修复节目没清除问题 +// dao.deleteBuilder().delete(); +//// for (Commands task : dao.queryForAll()) { +//// dao.delete(task); +//// } +// dao.deleteBuilder().clear(); +// } catch (SQLException e) { +// e.printStackTrace(); +// KuroLog.i("TAG", e.getMessage()); +// } +// dao.create(command); +// } +// // Log.i("TAG", "添加LEDOK任务成功"); +// } else if (tasktstate == TaskState.TaskIsNull) { +// throw new Exception("TaskState.TaskIsNull"); +// } else if (tasktstate == TaskState.TaskItemIsNull) { +// throw new Exception("TaskState.TaskItemIsNull"); +// } else if (tasktstate == TaskState.ItemProgramIsNull) { +// throw new Exception("TaskState.ItemProgramIsNull"); +// } else if (tasktstate == TaskState.LayerIsNull) { +// throw new Exception("TaskState.LayerIsNull"); +// } else if (tasktstate == TaskState.LayerSourcesIsNull) { +// throw new Exception("TaskState.LayerSourcesIsNull"); +// } +// +// } + + +// public boolean addTask(Commands commands) throws Exception { +// KuroLog.i("TAG", "addTask()"); +// Log.i("TAG", "addTask()"); +// boolean isSuccess = false; +// int tasktstate = correctTask(commands); +// if (tasktstate == TaskState.TaskIsRight) { +// isSuccess = true; +// } else if (tasktstate == TaskState.TaskIsNull) { +// throw new Exception("TaskState.TaskIsNull"); +// } else if (tasktstate == TaskState.TaskItemIsNull) { +// throw new Exception("TaskState.TaskItemIsNull"); +// } else if (tasktstate == TaskState.ItemProgramIsNull) { +// throw new Exception("TaskState.ItemProgramIsNull"); +// } else if (tasktstate == TaskState.LayerIsNull) { +// throw new Exception("TaskState.LayerIsNull"); +// } else if (tasktstate == TaskState.LayerSourcesIsNull) { +// throw new Exception("TaskState.LayerSourcesIsNull"); +// } +// return isSuccess; +// } + + public boolean addTask(String taskJson) throws Exception { + if (TextUtils.isEmpty(taskJson)) return false; + + KuroLog.i("TAG", "开始添加LEDOK任务"); + Log.i("TAG", "开始添加LEDOK任务"); +// Configurations cfg = Configurations.getConfigurations(); +// cfg.setValue("mustUpload", "false"); +// DataService.mustUpload = false; +// PlayXixunTaskCommand commandp = JsonMapper.getInstance().readValue(taskJson, PlayXixunTaskCommand.class); +// Commands command = new Commands(commandp.id, commandp.preDownloadURL, commandp.notificationURL, JsonMapper.getInstance().writeValueAsString(commandp.task)); +// boolean isSuccess = false; +// int tasktstate = correctTask(command, false); +// Log.d("TaskProcessor", String.valueOf(tasktstate)); +// if (tasktstate == TaskState.TaskIsRight) { +// isSuccess = true; +// if (commandp.task.insert) { +// TaskProcessor.getInstance(context).clearInsertBase(); +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(InsertCommand.class); +// dao.create(new InsertCommand(command.id, command.preDownloadURL, command.notificationURL, command.taskText)); +// } else { +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(Commands.class); +// if (dao != null) { +// try { +// //edit by ljh on @2024/3/7,修复节目没清除问题 +// dao.deleteBuilder().delete(); +//// for (Commands task : dao.queryForAll()) { +//// dao.delete(task); +//// } +// dao.deleteBuilder().clear(); +// dao.create(new InsertCommand(command.id, command.preDownloadURL, command.notificationURL, command.taskText)); +// } catch (SQLException e) { +// e.printStackTrace(); +// KuroLog.i("TAG", e.getMessage()); +// Log.i("TAG", e.getMessage()); +// } +// } +// } +// // Log.i("TAG", "添加LEDOK任务成功"); +// } else if (tasktstate == TaskState.TaskIsNull) { +// throw new Exception("TaskState.TaskIsNull"); +// } else if (tasktstate == TaskState.TaskItemIsNull) { +// throw new Exception("TaskState.TaskItemIsNull"); +// } else if (tasktstate == TaskState.ItemProgramIsNull) { +// throw new Exception("TaskState.ItemProgramIsNull"); +// } else if (tasktstate == TaskState.LayerIsNull) { +// throw new Exception("TaskState.LayerIsNull"); +// } else if (tasktstate == TaskState.LayerSourcesIsNull) { +// throw new Exception("TaskState.LayerSourcesIsNull"); +// } +// return isSuccess; + return false; + } + + //更新SourceFile表 +// public void updateSourceFile(SourceFile sourceFile) { +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(SourceFile.class); +// try { +// dao.createOrUpdate(sourceFile); +// } catch (SQLException throwables) { +// throwables.printStackTrace(); +// } +// } + +// public void deleteSourceFile() { +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(SourceFile.class); +// if (dao != null) { +// try { +// //edit by ljh on @2024/3/7,修复节目没清除问题 +// dao.deleteBuilder().delete(); +//// for (SourceFile task : dao.queryForAll()) { +//// dao.delete(task); +//// } +// dao.deleteBuilder().clear(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } +// } +// +// } + +// public int correctTask(Commands cs) throws SQLException, JsonProcessingException { +// KuroLog.i("TAG", "任务_correctTask"); +// Log.i("TAG", "任务_correctTask"); +// +// CommandTask programsTask = null; +// try { +// programsTask = JsonMapper.getInstance().readValue(cs.taskText, CommandTask.class); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// //记录新的命令里包含的节目 +// List programBeans = new ArrayList<>(); +// if (programsTask == null) { +// return TaskState.TaskIsNull; +// } +// if (programsTask.items == null || programsTask.items.size() < 1) +// return TaskState.TaskItemIsNull; +// List items = programsTask.items; +// //定时节目 +// // List timerProgram= new ArrayList<>(); +// Collections.sort(items, new Comparator() { +// public int compare(TaskItem arg0, TaskItem arg1) { +// return arg0.priority - arg1.priority; +// } +// }); +// long totalSize = 0; +// for (TaskItem item : items) { +// if (item._program == null) return TaskState.ItemProgramIsNull; +// //检验节目totalsize是否正确,把已经计算的source的id添加到此集合中 +// List idList = new ArrayList<>(); +// long programTotalSize = 0; +// item._program.commandId = cs.id; +// item._program.task_id = programsTask._id; +// item._program.item_id = item._id; +// item._program.repeat = item.repeatTimes; +// item._program.isDownloadOk = false; +// +// item._program.task_name = programsTask.name; +// item._program.preDownloadURL = cs.preDownloadURL; +// item._program.notificationURL = cs.notificationURL; +// item._program.insert = programsTask.insert; +// item._program.orderInsert = programsTask.orderInsert; +// item._program.program_type = "advanced"; +// if (item._program.layers == null || item._program.layers.size() < 1) +// return TaskState.LayerIsNull; +// +// for (ProgramLayer layer : item._program.layers) { +// +// if (layer.sources == null || layer.sources.size() <= 0) { +// return TaskState.LayerSourcesIsNull; +// } +// if (layer.sources.size() > 1) +// Collections.sort(layer.sources, new Comparator() { +// public int compare(ProgramSource arg0, ProgramSource arg1) { +// return arg0.playTime - arg1.playTime; +// } +// }); +// +// int playTime = 0; +// for (int i = 0; i < layer.sources.size(); i++) { +// ProgramSource source = layer.sources.get(i); +// if (source == null) return TaskState.SourcesIsNull; +// source.cmdId = cs.id; +// source.itemId = item._id; +// //相同的id不重复计算size +// if (source.size != 0 && !idList.contains(source.id)) { +// idList.add(source.id); +// programTotalSize += source.size; +// } +// //简易节目没有宽高,用于区别高级节目和简易节目 +// if (source.width == 0 && source.height == 0) { +// if (item._program.width != 0 && item._program.height != 0) { +// source.width = item._program.width; +// source.height = item._program.height; +// } else { +// item._program.width = DataService.screenWidth; +// item._program.height = DataService.screenHeight; +// source.width = DataService.screenWidth; +// source.height = DataService.screenHeight; +// } +// item._program.program_type = "simple"; +// //简易节目没有playTime +// source.playTime = playTime; +// playTime += source.timeSpan; +// } +// } +// } +// //根据sortXB给4.0平台分区重新排序 +// int[] sortXB = item._program.sortXB;//120 +// if (sortXB != null && sortXB.length == item._program.layers.size()) { +// List newLayers = new ArrayList<>(); +// for (int i = 0; i < sortXB.length; i++) { +// +// for (int j = 0; j < sortXB.length; j++) { +// if (i == sortXB[j]) { +// newLayers.add(item._program.layers.get(sortXB[i])); +// } +// } +// } +// Collections.reverse(newLayers); +// item._program.layers.clear(); +// item._program.layers = newLayers; +// item._program.sortXB = null; +// } +// if (item._program.orderInsert) { +// +// item._program.isTimer = false; +// item._program.schedules = null; +// +// } else if (item.schedules != null && item.schedules.size() > 0) { +// item._program.isTimer = true; +// item._program.timerState = false; +// List schedules = item.schedules; +// //如果定时缺少定时的某些属性就将其改为普通节目; +// for (Schedule s : schedules) { +// if (s.dateType == null || s.timeType == null) { +// item._program.isTimer = false; +// item._program.schedules = null; +// item.schedules = null; +// break; +// } +// } +// } +// +// item._program.schedules = item.schedules; +// analysType(item._program); +// programBeans.add(item._program); +// totalSize += item._program.totalSize; +// if (item._program.totalSize != programTotalSize) { +// item._program.totalSize = programTotalSize; +// } +// } +// +// //当节目为简易节目时需要,保存source的宽高,所以这里需要重新设置tasktext; +// +// cs.taskText = JsonMapper.getInstance().writeValueAsString(programsTask); +// clearDisk(totalSize); +// // LiveDataBus.get().with("NewMLComming").postValue(new NewMLComming(programsTask.append, cs.id, programBeans)); +// +// Log.d("TAG", "添加了新节目,correctTask --> NewMLComming"); +// SingleHandler.getInstance().sendMessage(new ShellBus("NewMLComming", new NewMLComming(programsTask.append, cs.id, programBeans))); +// +// return TaskState.TaskIsRight; +// } + +// private void analysType(ProgramBean _program) { +// if (_program.programType != ProgramType.NOLL) return; +// if (_program.orderInsert && _program.insert) { +// _program.programType = ProgramType.INSERT_ORDER; +// } else if (!_program.orderInsert && _program.insert) { +// if (_program.schedules != null && _program.schedules.size() > 0) { +// _program.programType = ProgramType.INSERT_TIME; +// } else { +// _program.programType = ProgramType.INSERT_NORMAL; +// } +// } else if (_program.schedules != null && _program.schedules.size() > 0) { +// _program.programType = ProgramType.TIME; +// } else { +// _program.programType = ProgramType.NORMAL; +// } +// } + +// public int correctTask(TimedSendProgram cs) throws SQLException, JsonProcessingException { +// KuroLog.i("TAG", "任务_定时发送节目任务"); +// Log.i("TAG", "任务_定时发送节目任务"); +// ObjectMapper mapper = new ObjectMapper(); +// mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) +// .configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false) +// .configure(DeserializationFeature.WRAP_EXCEPTIONS, true); +// CommandTask programsTask = null; +// try { +// programsTask = mapper.readValue(cs.taskText, CommandTask.class); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// //记录新的命令里包含的节目 +// List programBeans = new ArrayList<>(); +// if (programsTask == null) { +// return TaskState.TaskIsNull; +// } +// if (programsTask.items == null || programsTask.items.size() < 1) +// return TaskState.TaskItemIsNull; +// List items = programsTask.items; +// //定时节目 +// // List timerProgram= new ArrayList<>(); +// long totalSize = 0; +// for (TaskItem item : items) { +// if (item._program == null) return TaskState.ItemProgramIsNull; +// item._program.commandId = cs.id; +// item._program.task_id = programsTask._id; +// item._program.item_id = item._id; +// item._program.repeat = item.repeatTimes; +// item._program.isDownloadOk = false; +// item._program.schedules = item.schedules; +// item._program.task_name = programsTask.name; +// item._program.preDownloadURL = cs.preDownloadURL; +// item._program.notificationURL = cs.notificationURL; +// item._program.insert = programsTask.insert; +// item._program.program_type = "advanced"; +// if (item._program.layers == null || item._program.layers.size() < 1) +// return TaskState.LayerIsNull; +// +// for (ProgramLayer layer : item._program.layers) { +// +// if (layer.sources == null || layer.sources.size() <= 0) { +// return TaskState.LayerSourcesIsNull; +// } +// Collections.sort(layer.sources, new Comparator() { +// public int compare(ProgramSource arg0, ProgramSource arg1) { +// return arg0.playTime - arg1.playTime; +// } +// }); +// +// int playTime = 0; +// for (int i = 0; i < layer.sources.size(); i++) { +// ProgramSource source = layer.sources.get(i); +// if (source == null) return TaskState.SourcesIsNull; +// source.cmdId = cs.id; +// source.itemId = item._id; +// //简易节目没有宽高,用于区别高级节目和简易节目 +// if (source.width == 0 && source.height == 0) { +// if (item._program.width != 0 && item._program.height != 0) { +// source.width = item._program.width; +// source.height = item._program.height; +// } else { +// item._program.width = DataService.screenWidth; +// item._program.height = DataService.screenHeight; +// source.width = DataService.screenWidth; +// source.height = DataService.screenHeight; +// } +// item._program.program_type = "simple"; +// //简易节目没有playTime +// source.playTime = playTime; +// playTime += source.timeSpan; +// } +// } +// } +// if (item.schedules != null && item.schedules.size() > 0) { +// +// item._program.isTimer = true; +// item._program.timerState = false; +// //timerProgram.add(item._program); +// } +// analysType(item._program); +// programBeans.add(item._program); +// totalSize += item._program.totalSize; +// } +// +// //当节目为简易节目时需要,保存source的宽高,所以这里需要重新设置tasktext; +// +// cs.taskText = mapper.writeValueAsString(programsTask); +// clearDisk(totalSize); +// // LiveDataBus.get().with("NewMLComming").postValue(new NewMLComming(programsTask.append, cs.id, programBeans)); +// +// SingleHandler.getInstance().sendMessage(new ShellBus("NewMLComming", new NewMLComming(programsTask.append, cs.id, programBeans))); +// return TaskState.TaskIsRight; +// } + +// public int correctTask(Commands cs, boolean flag) throws SQLException, JsonProcessingException { +// KuroLog.i("TAG", "LEDOK任务_correctTask"); +// Log.i("TAG", "LEDOK任务_correctTask"); +// +// CommandTask programsTask = null; +// try { +// programsTask = JsonMapper.getInstance().readValue(cs.taskText, CommandTask.class); +// programsTask.isLedok = true; +// } catch (IOException e) { +// e.printStackTrace(); +// } +// //记录新的命令里包含的节目 +// List programBeans = new ArrayList<>(); +// if (programsTask == null) { +// return TaskState.TaskIsNull; +// } +// if (programsTask.items == null || programsTask.items.size() < 1) +// return TaskState.TaskItemIsNull; +// List items = programsTask.items; +// //定时节目 +// // List timerProgram= new ArrayList<>(); +// long totalSize = 0; +// for (TaskItem item : items) { +// if (item._program == null) return TaskState.ItemProgramIsNull; +// item._program.commandId = cs.id; +// item._program.isLedok = true; +// item._program.task_id = programsTask._id; +// item._program.item_id = item._id; +// item._program.repeat = item.repeatTimes; +// item._program.isDownloadOk = false; +// item._program.schedules = item.schedules; +// item._program.task_name = programsTask.name; +// item._program.preDownloadURL = cs.preDownloadURL; +// item._program.notificationURL = cs.notificationURL; +// item._program.insert = programsTask.insert; +// item._program.orderInsert = programsTask.orderInsert; +// item._program.program_type = "advanced"; +// // +// Log.d("taskPro",item._program.layers.size()+"aaa"+item._program.layers.toString()); +// if (item._program.layers == null || item._program.layers.size() < 1) +// return TaskState.LayerIsNull; +// +// for (ProgramLayer layer : item._program.layers) { +// +// if (layer.sources == null || layer.sources.size() <= 0) { +// return TaskState.LayerSourcesIsNull; +// } +// Collections.sort(layer.sources, new Comparator() { +// public int compare(ProgramSource arg0, ProgramSource arg1) { +// return arg0.playTime - arg1.playTime; +// } +// }); +// int playTime = 0; +// +// for (ProgramSource source : layer.sources) { +// if (source == null) return TaskState.SourcesIsNull; +// source.cmdId = cs.id; +// source.itemId = item._id; +// if (layer.border != null) { +// source.top += layer.border.img_size[1]; +// source.left += layer.border.img_size[1]; +// source.width -= layer.border.img_size[1] * 2; +// source.height -= layer.border.img_size[1] * 2; +// } +// ; +// if (flag) { +// if (!TextUtils.isEmpty(source.fileExt)) { +// if (source.fileExt.startsWith(".")) { +// source.id += source.fileExt; +// } else { +// source.id = source.id + "." + source.fileExt; +// } +// } +// } +// if (source.width == 0 && source.height == 0) { +// if (item._program.width != 0 && item._program.height != 0) { +// source.width = item._program.width; +// source.height = item._program.height; +// } else { +// item._program.width = DataService.screenWidth; +// item._program.height = DataService.screenHeight; +// source.width = DataService.screenWidth; +// source.height = DataService.screenHeight; +// } +// item._program.program_type = "simple"; +// //简易节目没有playTime +// source.playTime = playTime; +// playTime += source.timeSpan; +// } +// if (item._program.splitWidths != null && item._program.splitWidths.size() > 0) { +// source.splitWidth = item._program.splitWidths; +// if (item._program.width != 0 && item._program.height != 0) { +// source.vWidth = item._program.width; +// source.vHeight = item._program.height; +// } else { +// item._program.width = DataService.screenWidth; +// item._program.height = DataService.screenHeight; +// source.vWidth = DataService.screenWidth; +// source.vHeight = DataService.screenHeight; +// } +// } +// } +// } +// if (item._program.orderInsert) { +// item._program.isTimer = false; +// +// } else if (item.schedules != null && item.schedules.size() > 0) { +// item._program.isTimer = true; +// item._program.timerState = false; +// //timerProgram.add(item._program); +// } +// analysType(item._program); +// programBeans.add(item._program); +// totalSize += item._program.totalSize; +// } +// //当节目为简易节目时需要,保存source的宽高,所以这里需要重新设置tasktext; +// +// cs.taskText = JsonMapper.getInstance().writeValueAsString(programsTask); +// clearDisk(totalSize); +// // LiveDataBus.get().with("NewMLComming").postValue(new NewMLComming(programsTask.append, cs.id, programBeans)); +// +// SingleHandler.getInstance().sendMessage(new ShellBus("NewMLComming", new NewMLComming(programsTask.append, cs.id, programBeans))); +// return TaskState.TaskIsRight; +// } +//public int correctTask(Commands cs, boolean flag) throws SQLException, JsonProcessingException { +// KuroLog.i("TAG", "LEDOK任务_correctTask"); +// Log.i("TAG", "LEDOK任务_correctTask"); +// +// CommandTask programsTask = null; +// try { +// programsTask = JsonMapper.getInstance().readValue(cs.taskText, CommandTask.class); +// programsTask.isLedok = true; +// } catch (IOException e) { +// e.printStackTrace(); +// } +// //记录新的命令里包含的节目 +// List programBeans = new ArrayList<>(); +// if (programsTask == null) { +// return TaskState.TaskIsNull; +// } +// if (programsTask.items == null || programsTask.items.size() < 1) +// return TaskState.TaskItemIsNull; +// List items = programsTask.items; +// Log.d("TaskProcessor", String.valueOf(items.size())); +// //定时节目 +// // List timerProgram= new ArrayList<>(); +// long totalSize = 0; +// for (TaskItem item : items) { +// if (item._program == null) return TaskState.ItemProgramIsNull; +// item._program.commandId = cs.id; +// item._program.isLedok = true; +// item._program.task_id = programsTask._id; +// item._program.item_id = item._id; +// item._program.repeat = item.repeatTimes; +// item._program.isDownloadOk = false; +// item._program.schedules = item.schedules; +// item._program.task_name = programsTask.name; +// item._program.preDownloadURL = cs.preDownloadURL; +// item._program.notificationURL = cs.notificationURL; +// item._program.insert = programsTask.insert; +// item._program.orderInsert = programsTask.orderInsert; +// item._program.program_type = "advanced"; +// if (item._program.layers == null || item._program.layers.size() < 1) +// return TaskState.LayerIsNull; +// +// for (ProgramLayer layer : item._program.layers) { +// +// if (layer.sources == null || layer.sources.size() <= 0) { +// return TaskState.LayerSourcesIsNull; +// } +// Collections.sort(layer.sources, new Comparator() { +// public int compare(ProgramSource arg0, ProgramSource arg1) { +// return arg0.playTime - arg1.playTime; +// } +// }); +// int playTime = 0; +// +// for (ProgramSource source : layer.sources) { +// if (source == null) return TaskState.SourcesIsNull; +// source.cmdId = cs.id; +// source.itemId = item._id; +// if (layer.border != null) { +// source.top += layer.border.img_size[1]; +// source.left += layer.border.img_size[1]; +// source.width -= layer.border.img_size[1] * 2; +// source.height -= layer.border.img_size[1] * 2; +// } +// ; +// if (flag) { +// if (!TextUtils.isEmpty(source.fileExt)) { +// if (source.fileExt.startsWith(".")) { +// source.id += source.fileExt; +// } else { +// source.id = source.id + "." + source.fileExt; +// } +// } +// } +// if (source.width == 0 && source.height == 0) { +// if (item._program.width != 0 && item._program.height != 0) { +// source.width = item._program.width; +// source.height = item._program.height; +// } else { +// item._program.width = DataService.screenWidth; +// item._program.height = DataService.screenHeight; +// source.width = DataService.screenWidth; +// source.height = DataService.screenHeight; +// } +// item._program.program_type = "simple"; +// //简易节目没有playTime +// source.playTime = playTime; +// playTime += source.timeSpan; +// } +// if (item._program.splitWidths != null && item._program.splitWidths.size() > 0) { +// source.splitWidth = item._program.splitWidths; +// if (item._program.width != 0 && item._program.height != 0) { +// source.vWidth = item._program.width; +// source.vHeight = item._program.height; +// } else { +// item._program.width = DataService.screenWidth; +// item._program.height = DataService.screenHeight; +// source.vWidth = DataService.screenWidth; +// source.vHeight = DataService.screenHeight; +// } +// } +// } +// } +// if (item._program.orderInsert) { +// item._program.isTimer = false; +// +// } else if (item.schedules != null && item.schedules.size() > 0) { +// item._program.isTimer = true; +// item._program.timerState = false; +// //timerProgram.add(item._program); +// } +// analysType(item._program); +// programBeans.add(item._program); +// totalSize += item._program.totalSize; +// } +// //当节目为简易节目时需要,保存source的宽高,所以这里需要重新设置tasktext; +// +// cs.taskText = JsonMapper.getInstance().writeValueAsString(programsTask); +// clearDisk(totalSize); +// // LiveDataBus.get().with("NewMLComming").postValue(new NewMLComming(programsTask.append, cs.id, programBeans)); +// +// SingleHandler.getInstance().sendMessage(new ShellBus("NewMLComming", new NewMLComming(programsTask.append, cs.id, programBeans))); +// return TaskState.TaskIsRight; +//} +// public long disks = 120 * 1024 * 1024l; +// +// public void clearDisk(long totalSize) { +// long diskSize = servant.getAvailableMemorySize() / 1024 / 1024; +// Log.i("TAG", "内存剩余大小:" + diskSize + "M"); +// long remain = servant.getAvailableMemorySize() - totalSize; +// if (remain < disks) { +// Log.i("TAG", "内部不足120M.........."); +// Log.i("TAG", "开始清理磁盘。。。。。。。。。。。。。。"); +// TaskProcessor.getInstance(context).clearAllTask(); +//// if (remain < disks) { +//// Log.i("TAG", "内存仍然不足120M"); +//// } +// if (servant.getAvailableMemorySize() - totalSize < disks) { +// Log.i("TAG", "内存仍然不足120M"); +// } +// } +// } +// +// public ProgramsTask_dto getTask() { +// ProgramsTask_dto dto = new ProgramsTask_dto(); +// try { +// List commandsList = MyDatabaseHelper.getInstance(context).getDao(Commands.class).queryForAll(); +// if (commandsList == null || commandsList.size() == 0) return null; +// Commands commands = commandsList.get(commandsList.size() - 1); +// CommandTask task = JsonMapper.getInstance().readValue(commands.taskText, CommandTask.class); +// dto._department = task._department; +// dto._id = task._id; +// dto.name = task.name; +// dto.items = new ArrayList(); +// for (TaskItem item : task.items) { +// TaskItem_dto dto_item = new TaskItem_dto(); +// dto_item._program = new Program_dto(); +// dto_item._id = item._id; +// dto_item.priority = item.priority; +// dto_item.repeatTimes = item.repeatTimes; +// dto_item.schedules = item.schedules; +// dto_item._program.departmentId = item._program.departmentId; +// dto_item._program.height = item._program.height; +// dto_item._program.width = item._program.width; +// dto_item._program.id = item._program._id; +// dto_item._program.layers = item._program.layers; +// dto_item._program.name = item._program.name; +// dto_item._program.playSourceOnTime = item._program.playSourceOnTime; +// dto_item._program.totalSize = item._program.totalSize; +// dto_item._program.version = item._program.version; +// dto.items.add(dto_item); +// } +// return dto; +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return dto; +// } +// +// public int getSourceState(String id) { +// if (!new File(servant.getCanUsedPath(context) + id).exists()) { +// return FileState.Not_Download; +// } +// int state = FileState.Not_Download; +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(SourceFile.class); +// try { +// SourceFile sourceFile = dao.queryForId(id); +// //如果没有记录或者记录没下载完成就添加到下载队列中去 +// if (sourceFile == null) return FileState.Not_Download; +// if (sourceFile.isDownloadOK != FileState.Is_Downloaded) { +// state = FileState.Not_Download; +// } else { +// state = FileState.Is_Downloaded; +// } +// } catch (SQLException e) { +// e.printStackTrace(); +// } +// return state; +// } + + //开启定时发送节目的的定时 +// public void stopTimedSendProgram() { +// if (!existTimeSend) return; +// KuroLog.i("TAG:取消定时发送"); +// if (timerSend != null) { +// timerSend.cancel(); +// timerSend = null; +// } +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(TimedSendProgram.class); +// //判断是否已经存在,若果已经存在修改表中数据,否则创建新的数据 +// try { +// //edit by ljh on @2024/3/7,修复节目没清除问题 +// dao.deleteBuilder().delete(); +//// for (TimedSendProgram program : dao.queryForAll()) { +//// dao.delete(program); +//// } +// } catch (SQLException throwables) { +// throwables.printStackTrace(); +// } +// } + + +// public void startTimedSendProgram(TimedSendProgram program) { +// try { +// //2021-11-02 17:26 +// if (program != null && !TextUtils.isEmpty(program.executeDate)) { +// existTimeSend = true; +// KuroLog.i("TAG:定时发送节目时间:" + program.executeDate); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); +// Date date = sdf.parse(program.executeDate); +// if (System.currentTimeMillis() >= date.getTime()) { +// dealTimerSend(program); +// } else { +// if (timerSend != null) { +// timerSend.cancel(); +// timerSend = null; +// } +// timerSend = new Timer(); +// timerSend.schedule(new TimerTask() { +// @Override +// public void run() { +// dealTimerSend(program); +// } +// }, date); +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// } + +// public void dealTimerSend(TimedSendProgram program) { +// try { +// int state = correctTask(program); +// if (state == TaskState.TaskIsRight) { +// //executeDate不为null时节目为定时发送节目,需要保存;否则可以直接删除 +// TaskProcessor.getInstance(context).clearCommandsBase(); +// Commands commands = new Commands(program.id, "", "", program.taskText); +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(Commands.class); +// //判断是否已经存在,若果已经存在修改表中数据,否则创建新的数据 +// if (dao.idExists(commands.id)) { +// dao.deleteById(commands.id); +// dao.create(commands); +// } else { +// dao.create(commands); +// } +// Dao dao1 = MyDatabaseHelper.getInstance(context).getDao(TimedSendProgram.class); +// //判断是否已经存在,若果已经存在修改表中数据,否则创建新的数据 +// if (dao1.idExists(program.id)) { +// dao1.deleteById(program.id); +// } +// } +// } catch (SQLException throwables) { +// throwables.printStackTrace(); +// } catch (JsonProcessingException e) { +// e.printStackTrace(); +// } +// } + + //清除数据库表 + public void clearCommandsBase() { + KuroLog.i("TAG:删除Commands表"); + Log.i("TAG","clearCommandsBase,删除Commands表"); +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(Commands.class); +// if (dao != null) { +// try { +// //edit by ljh on @2024/3/7,修复节目没清除问题 +// dao.deleteBuilder().delete(); +//// for (Commands task : dao.queryForAll()) { +//// dao.delete(task); +//// Logs.logD("删除Commands task"); +//// } +// dao.deleteBuilder().clear(); +// Logs.logD("删除Commands表完成"); +// } catch (SQLException e) { +// Logs.logE("删除Commands表失败:"+e.getMessage()); +// e.printStackTrace(); +// } +// } + + } + + public void clearGpsCommandsBase() { + KuroLog.i("TAG:删除Commands表"); +// Logs.logD("clearGpsCommandsBase,删除Commands表"); +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(GpsCommands.class); +// if (dao != null) { +// try { +// //edit by ljh on @2024/3/7,修复节目没清除问题 +// dao.deleteBuilder().delete(); +//// for (GpsCommands task : dao.queryForAll()) { +//// dao.delete(task); +//// } +// dao.deleteBuilder().clear(); +// } catch (SQLException e) { +// Logs.logE("删除Commands表失败:"+e.getMessage()); +// e.printStackTrace(); +// } +// } + + } + + //清除数据库表 + public void clearInsertBase() { + Log.i("TAG", "删除Insert表"); +// Dao dao = MyDatabaseHelper.getInstance(context).getDao(InsertCommand.class); +// if (dao != null) { +// try { +// //edit by ljh on @2024/3/7,修复节目没清除问题 +// dao.deleteBuilder().delete(); +//// for (InsertCommand task : dao.queryForAll()) { +//// dao.delete(task); +//// } +// dao.deleteBuilder().clear(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } +// } + + } + + public void clearDatabase() { + KuroLog.i("TAG:删除数据库"); + Log.i("TAG","TAG:删除数据库"); + clearCommandsBase(); + clearSendedTimedBase(); + clearLogDatabase(); + clearInsertBase(); + clearGpsCommandsBase(); +// LinuxCommandUnit.execLinuxCommand(); +// MyDatabaseHelper.commandsIsNull = true; + } + + public void clearSendedTimedBase() { +// KuroLog.i("TAG:删除定时发送节目表"); +// Logs.logD("删除定时发送节目表"); +// Dao dao1 = MyDatabaseHelper.getInstance(context).getDao(TimedSendProgram.class); +// if (dao1 != null) { +// try { +// //edit by ljh on @2024/3/7,修复节目没清除问题 +// dao1.deleteBuilder().delete(); +//// for (TimedSendProgram task1 : dao1.queryForAll()) { +//// dao1.delete(task1); +//// } +// dao1.deleteBuilder().clear(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } +// } + } + + public void clearLogDatabase() { + KuroLog.i("TAG:删除播放日志表"); +// Logs.logD("删除播放日志表"); +// MyDatabaseHelper.getInstance(AdApp.getApp()).removeUploadedLog(System.currentTimeMillis()); + } + + + public synchronized void clearAllTask() { + KuroLog.i("TAG", "clearAllTask。。。。。。"); + Log.i("TAG", "clearAllTask。。。。。。"); +// Configurations.getConfigurations().commandTaskJsonSave(""); +// //清除正在播放的节目 +// try { +// // LiveDataBus.get().with("clearSource").postValue("1"); +// SingleHandler.getInstance().sendMessage(new ShellBus("clearSource", "1")); +// clearDatabase(); +// //删除下载成功的数据库数据 +// deleteSourceFile(); +// //清除缓存的文件 +// DiskProcessor.delAllFile(servant.getCanUsedPath(context)); +// KuroLog.i("TAG", "清除文件完成。。。。。。"); +// } catch (Exception e) { +// e.printStackTrace(); +// } + } +} diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ledok/TaskSocketServer.kt b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/TaskSocketServer.kt new file mode 100644 index 0000000..39bc35f --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/TaskSocketServer.kt @@ -0,0 +1,615 @@ +package cn.trans88.taxiappkotlin.ledok + +import android.content.Context +import android.content.Intent +import android.util.Log +import cn.trans88.taxiappkotlin.R +import cn.trans88.taxiappkotlin.TaxiApp +import cn.trans88.taxiappkotlin.TaxiApp.Companion.instance +import cn.trans88.taxiappkotlin.ledok.LedOkCommands.PLAYLIST +import cn.trans88.taxiappkotlin.ledok.LedOkCommands.playlist +import cn.trans88.taxiappkotlin.logic.model.BindModel +import cn.trans88.taxiappkotlin.logic.network.ConnManger +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import com.trs88.kurolibrary.log.KuroLog +import java.io.BufferedReader +import java.io.DataOutputStream +import java.io.File +import java.io.FileOutputStream +import java.io.FileReader +import java.io.IOException +import java.io.InputStream +import java.net.ServerSocket +import java.net.Socket +import java.util.Timer +import java.util.TimerTask +import java.util.concurrent.TimeUnit + +class TaskSocketServer(private val context: Context, port: Int) { + companion object { + val TAG: String = TaskSocketServer::class.java.simpleName + } + + var timer: Timer? = null + + private var file: File? = null + private var fos: FileOutputStream? = null + private var dos: DataOutputStream? = null + private var startFlag = 0 + private var endFlag = 0 + + //private byte[] globleBuff = new byte[1020]; + var m_iCurFileSize: Int = 0 //当前文件的大小 + var m_iCurFileRecvLength: Int = 0 //当前文件接收到的字节 + private val bFileOpr = false + var jsonBuff: ByteBuffer = ByteBuffer() + + private var soc: ServerSocket? = null + private var client: Socket? = null + private val dir: String? = null + private var downloadDir: File? = null + private val prot = 3333 + private var recreate = true + + fun destroy() { + Log.i(TAG, "destroy killLive。。。。") + killLive() + clear() + if (client != null) { + try { + client!!.close() + } catch (e: IOException) { + e.printStackTrace() + } + client = null + } + try { + if (soc != null) soc!!.close() + soc = null + } catch (e: IOException) { + e.printStackTrace() + } + } + + fun listen() { + Log.i(TAG, "listen") + keepLive() + while (soc != null && !soc!!.isClosed) { + try { + //只保持一个链接,新的进来就把老的断开 + val socket = soc!!.accept() + socket.soTimeout = 5000 + if (client != null) { + client!!.close() + } + client = socket + Log.i(TAG, "new client is connected") + clear() + //edit by ljh@2024/4/28 优化ledOk发节目旧连接没断开,新连接发送不了数据问题 + ThreadProcessor.getInstance().addThread { + recvDataFromClient() + } + } catch (e: Exception) { + Log.d(TAG, "Exception msg: " + e.message) + e.printStackTrace() + } + } + Log.i(TAG, "server 断开重建。。。。") + } + + private fun keepLive() { + if (timer == null) { + timer = Timer() + timer!!.schedule(object : TimerTask() { + override fun run() { + if (soc != null && !soc!!.isClosed) { + Log.i(TAG, "server live 。。。。") + recreate = false + } else { + Log.i(TAG, "server death 。。。。") + recreate = true + } + } + }, 5000, (30 * 1000).toLong()) + } + } + + + private fun killLive() { + Log.i(TAG, "killLive。。。。") + if (timer != null) { + timer!!.cancel() + timer = null + } + } + + fun sendDataToClient(msg: String) { + try { + val bs = msg.toByteArray() + if (client != null) { + client!!.getOutputStream().write(bs) + } + } catch (e: Exception) { + e.printStackTrace() + } + } + + fun recvDataFromClient() { + var len = -1 + val buff = ByteArray(4096) + var input: InputStream? = null + try { + input = client!!.getInputStream() + while ((input.read(buff).also { len = it }) != -1 + ) { + processData(buff, len) + } + } catch (e: Exception) { + e.printStackTrace() + Log.i(TAG, "出错重置。。。。") + clear(); + try { + client?.close(); + } catch (e: IOException) { + e.printStackTrace(); + } + } finally { + clear() + if (input != null) { + try { + input.close() + } catch (e: IOException) { + throw RuntimeException(e) + } + } + if (client != null) { + try { + client!!.close() + } catch (e: IOException) { + throw RuntimeException(e) + } + } + } + } + + fun clear() { + if (file != null) { + file!!.delete() + file = null + } + if (fos != null) { + try { + fos!!.close() + fos = null + } catch (e: IOException) { + e.printStackTrace() + } + } + if (dos != null) { + try { + dos!!.close() + dos = null + } catch (e: IOException) { + e.printStackTrace() + } + } + startFlag = 0 + endFlag = 0 + m_iCurFileSize = 0 + m_iCurFileRecvLength = 0 + jsonBuff.clear() + } + + + private fun processData(buff: ByteArray, len: Int) { + var i = 0 + while (i < len) { + if (file != null) { + //文件已经打开,说明已经收到了fileStart,下面的数据准备写入文件 + val iRestLength = len - i + // m_iCurFileSize表示 ledOk发过来文件的大小,m_iCurFileRecvLength表示 当前文件接收到的字,累加起来 + val iRestFileLength = m_iCurFileSize - m_iCurFileRecvLength +// Log.d( +// TAG, +// "m_iCurFileSize:$m_iCurFileSize\nm_iCurFileRecvLength:$m_iCurFileRecvLength\niRestFileLength:$iRestFileLength" +// ) +// Log.d(TAG, "processData: file: ") + //buff中剩余的字节数 大于 剩余未写入文件的字节数 + if (iRestLength >= iRestFileLength) { + //并且剩余文件未写入字节数 大于 0 + if (iRestFileLength > 0) { + //直接将iRestFileLength长度字节数写入文件,buff索引向后移动iRestFileLength个字节 + try { + val restBuff = ByteArray(iRestFileLength) + System.arraycopy(buff, i, restBuff, 0, iRestFileLength) + //// Log.i(TAG,"BS:"+Arrays.toString(restBuff)); + if (fos == null) { + fos = FileOutputStream(file) + if (dos == null) { + dos = DataOutputStream(fos) + } + //Log.i(TAG,"BS:"+Arrays.toString(restBuff)); + KuroLog.i("TAG:processData:0") + dos!!.write(restBuff) + } else { + if (dos == null) { + dos = DataOutputStream(fos) + } + //Log.i(TAG,"BS:"+Arrays.toString(restBuff));\ + KuroLog.i("TAG:processData:1") + dos!!.write(restBuff) + } + m_iCurFileRecvLength += iRestFileLength + i += iRestFileLength + //文件写完了,关闭当前文件 + startFlag = 0 + } catch (e: Exception) { + //Log.i(tag, "10000000000000000000"); + e.printStackTrace() + } + } else { + //Log.i(tag, "iRestFileLength <= 0"); + if (iRestFileLength < 0) { + Log.i(TAG, "iRestFileLength < 0") + } + } + } else { + try { + val restBuff = ByteArray(iRestLength) + //// Log.i(TAG,"BS:"+Arrays.toString(restBuff)); + System.arraycopy(buff, i, restBuff, 0, iRestLength) + //Log.i(tag, "00"); + if (file != null) { + //Log.i(tag, "01"); + if (fos == null) { + fos = FileOutputStream(file) + if (dos == null) { + dos = DataOutputStream(fos) + } + KuroLog.i("TAG:processData:2") + dos!!.write(restBuff) + } else { + if (dos == null) { + dos = DataOutputStream(fos) + } + // KuroLog.i("TAG:processData:3"); + dos!!.write(restBuff) + } + } + m_iCurFileRecvLength += iRestLength + } catch (e: Exception) { + //Log.i(tag, "1111111111111111111111111"); + e.printStackTrace() + } + return + } + } + // + if (startFlag == 0) { + if (buff[i] == '{'.toByte()) { + startFlag = 1 + jsonBuff.append(buff[i]) + } + } else if (startFlag == 1) { + if (buff[i] == '"'.toByte()) { + startFlag = 2 + jsonBuff.append(buff[i]) + } else { + startFlag = 0 + jsonBuff.clear() + } + } else if (startFlag == 2) { + if (buff[i] == '_'.toByte()) { + startFlag = 3 + jsonBuff.append(buff[i]) + } else { + startFlag = 0 + jsonBuff.clear() + } + } else if (startFlag == 3) { + if (buff[i] == 't'.toByte()) { + startFlag = 4 + jsonBuff.append(buff[i]) + } else { + startFlag = 0 + jsonBuff.clear() + } + } else if (startFlag == 4) { + if (buff[i] == 'y'.toByte()) { + startFlag = 5 + jsonBuff.append(buff[i]) + } else { + startFlag = 0 + jsonBuff.clear() + } + } else if (startFlag == 5) { + if (buff[i] == 'p'.toByte()) { + startFlag = 6 + jsonBuff.append(buff[i]) + } else { + startFlag = 0 + jsonBuff.clear() + } + } else if (startFlag == 6) { + if (buff[i] == 'e'.toByte()) { + startFlag = 7 + jsonBuff.append(buff[i]) + } else { + startFlag = 0 + jsonBuff.clear() + } + } else if (startFlag == 7) { + if (endFlag == 0) { + if (buff[i] == 'x'.toByte()) { + endFlag = 1 + } + } else if (endFlag == 1) { + endFlag = if (buff[i] == 'i'.toByte()) { + 2 + } else { + 0 + } + } else if (endFlag == 2) { + endFlag = if (buff[i] == 'x'.toByte()) { + 3 + } else { + 0 + } + } else if (endFlag == 3) { + endFlag = if (buff[i] == 'u'.toByte()) { + 4 + } else { + 0 + } + } else if (endFlag == 4) { + endFlag = if (buff[i] == 'n'.toByte()) { + 5 + } else { + 0 + } + } else if (endFlag == 5) { + endFlag = if (buff[i] == '1'.toByte()) { + 6 //jsonObject结束 + } else { + 0 + } + } else if (endFlag == 6) { + endFlag = if (buff[i] == '"'.toByte()) { + 7 //jsonObject结束 + } else { + 0 + } + } else if (endFlag == 7) { + endFlag = if (buff[i] == '}'.toByte()) { + 8 //jsonObject结束 + } else { + 0 + } + } + jsonBuff.append(buff[i]) + if (endFlag == 8) { + val json = String(jsonBuff.buff, 0, jsonBuff.len()) + processPackage(json) + endFlag = 0 + startFlag = endFlag + jsonBuff.clear() + } + } + i++ + } + } + + fun processPackage(json: String?) { + if (json != null) { + try { + val gson = GsonBuilder().serializeNulls().create() + val cmd = gson.fromJson(json, JsonCommand::class.java) + if (cmd._type == "consult") { + Log.d(TAG, "processPackage([json]): consult: $json") + idList1 = cmd.idList + ackList(cmd.idList) + } else if (cmd._type == "proStart") { + Log.d(TAG, "processPackage([json]): proStart: $json") + } else if (cmd._type == "proEnd") { + Log.d(TAG, "processPackage([json]): proEnd: $json") + val ack = "{\"_type\":\"AckSuccess\"}" + sendDataToClient(ack) + client?.close() + Log.d(TAG, "processPackage([json]): ack: $ack") + //文件接收完成,可以开始播放 + LedOkCommands.startLedOkActivity() + } else if (cmd._type == "fileStart") { + Log.d(TAG, "processPackage([json]): fileStart: $json") + m_iCurFileSize = cmd.size + m_iCurFileRecvLength = 0 + if (!cmd.id!!.isEmpty() && file == null) { + if (!downloadDir?.exists()!!) { + downloadDir?.mkdirs(); + } + var path = "${downloadDir?.absolutePath}/${cmd.id}" + file = File(path); + if (!file!!.exists()) { + Log.i(TAG, "create file :" + path); + file!!.createNewFile(); + } + file!!.setWritable(true, true); + } else if (!cmd.id!!.isEmpty() && file != null) { + if (!file!!.canWrite()) { + file!!.setWritable(true, true) + } + } + } else if (cmd._type == "fileEnd") { + Log.d(TAG, "processPackage([json]): fileEnd: $json") + if (dos != null) { + dos!!.flush() + //将数据同步到达物理存储设备 + val fd = fos!!.fd + fd.sync() + dos!!.close() + } + if (fos != null) fos!!.close() + file!!.setWritable(false, true); + fos = null + dos = null + file = null + //TaskProcessor.getInstance(context).updateSourceFile(new SourceFile(cmd.id, servant.getCanUsedPath(context), FileState.Is_Downloaded)); + } else if (cmd._type == "BindAccount") { + Log.d(TAG, "processPackage: BindAccount") +// val bindModel = cmd.bindModel +// if (bindModel?.server != null && bindModel?.server!=""){ +// bindModel?.server = bindModel?.server+"/" +// } +// if (bindModel?.server != null && bindModel.server!=""){ +// bindModel.tlsServer = bindModel.tlsServer+"/" +// } +// val mbindAccount = bindModel?.let { ConnManger.mbindAccount(it) } +// if (mbindAccount == true) { +// val ack = "{\"_type\":\"AckSuccess\"}" +// sendDataToClient(ack) +// } else { +// val ack = "{\"_type\":\"AckFailed\"}" +// sendDataToClient(ack) +// } +// client?.close() + } + } catch (e: Exception) { + Log.i(TAG, "error:" + e.message) + e.printStackTrace() + } + } + } + + fun ackList(list: List?) { + if (list.isNullOrEmpty()) { + Log.i(TAG, "consult is empty") + return + } + val downloadList: MutableList = ArrayList() + for (id in list) { + val file = File("${downloadDir?.absolutePath}/${id}") + if (id == "program" || !file.exists()) { + downloadList.add(id) + + } + } + var sl = "" + for (i in downloadList.indices) { + sl = if (i == 0) { + sl + "\"" + downloadList[i] + "\"" + } else { + sl + ",\"" + downloadList[i] + "\"" + } + } + val ack = "{\"_type\":\"consult\",\"idList\":[$sl]}" + Log.d(TAG, "processPackage([json]): ack: $ack") + sendDataToClient(ack) + //发送出去 + } + + inner class ByteBuffer { + var buff: ByteArray + private val unit = 3000 + private var size: Int + private var index: Int + + init { + buff = ByteArray(unit) + size = unit + index = 0 + } + + fun append(b: Byte) { + if (index >= size) { + Log.i(TAG, "================ index of ByteBuffer > size===============") + size = size + unit + val temp = ByteArray(size) + System.arraycopy(buff, 0, temp, 0, index) + buff = temp + } + buff[index] = b + index++ + } + + fun clear() { + buff = ByteArray(unit) + size = unit + index = 0 + } + + fun len(): Int { + return index + } + } + + inner class JsonCommand { + var _type: String? = null + var proName: String? = null + var proSize: Int = 0 + var zVer: String? = null + var id: String? = null + var relative_path: String? = null + var size: Int = 0 + var data: String? = null + var _id: String? = null + var idList: List? = null + var task: Task? = null + var bindModel: BindModel? = null + } + + var idList1: List? = null + + init { + downloadDir = + File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program)) + Log.d(TAG, "downloadDir: $downloadDir") + + while (recreate) { + try { +// if (soc == null) { +// destroy() + soc = ServerSocket(port) + recreate = false +// } + Log.i(TAG, "create...... ") + } catch (e: Exception) { + Log.i(TAG, e.message + "...............") + try { + TimeUnit.SECONDS.sleep(1) + } catch (interruptedException: InterruptedException) { + interruptedException.printStackTrace() + } + } + } + } + + fun readFileContent(fileName: String?): String? { + val file = File(fileName) + if (!file.exists()) { + return null + } + var reader: BufferedReader? = null + val sbf = StringBuffer() + try { + reader = BufferedReader(FileReader(file)) + var tempStr: String? + while ((reader.readLine().also { tempStr = it }) != null) { + sbf.append(tempStr) + } + reader.close() + return sbf.toString() + } catch (e: IOException) { + e.printStackTrace() + } finally { + if (reader != null) { + try { + reader.close() + } catch (e1: IOException) { + e1.printStackTrace() + } + } + } + return sbf.toString() + } + +} diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ledok/ThreadProcessor.java b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/ThreadProcessor.java new file mode 100644 index 0000000..ef8a276 --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ledok/ThreadProcessor.java @@ -0,0 +1,51 @@ +package cn.trans88.taxiappkotlin.ledok; + + +import android.util.Log; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import cn.trans88.taxiappkotlin.TaxiApp; + +public class ThreadProcessor { + public static final String TAG = ThreadProcessor.class.getSimpleName(); + + private static volatile ThreadProcessor processor; + private volatile static ExecutorService executor, + liveExecutor = Executors.newCachedThreadPool(); + + public static ThreadProcessor getInstance(){ + if(processor==null){ + synchronized (TaxiApp.Companion.instance()) { + if (processor == null) { + processor = new ThreadProcessor(); + } + } + } + return processor; + } + + private ThreadProcessor(){ + if(executor==null){ + executor = Executors.newCachedThreadPool(); + } + } + public void addThread(Runnable runnable){ + Log.d(TAG, "addThread([runnable]): 添加新的线程任务"); + executor.execute(runnable); + } + + public void addLiveThread(Runnable runnable){ + Log.d(TAG, "addLiveThread([runnable]): 添加新的线程任务"); + liveExecutor.execute(runnable); + } + public void destroy(){ + if(!executor.isShutdown()){ + executor.shutdownNow(); + executor = null; + } + processor = null; + } + +} \ No newline at end of file diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/Repository.kt b/app/src/main/java/cn/trans88/taxiappkotlin/logic/Repository.kt index b84e761..d3ffb42 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/Repository.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/Repository.kt @@ -3,6 +3,7 @@ package cn.trans88.taxiappkotlin.logic import android.annotation.SuppressLint import android.os.Handler import android.os.Looper +import android.util.Log import androidx.lifecycle.liveData import cn.trans88.kurotool.datastructure.CircularList import cn.trans88.taxiappkotlin.Configurations @@ -46,12 +47,16 @@ import kotlin.collections.ArrayList * 仓库层:判断调用的数据是从本地获取还是网络获取的 */ val myListMap = mutableMapOf>() + object Repository { + private val TAG = "Repository" // private val circularListMap = mapOf(AdvertiseType.NORMAL.ordinal to CircularList(),AdvertiseType.AREA.ordinal to CircularList()) private val circularListMap = mutableMapOf>() - private val changeStatusQueue: LinkedBlockingQueue = LinkedBlockingQueue() //阻塞队列 + private val changeStatusQueue: LinkedBlockingQueue = + LinkedBlockingQueue() //阻塞队列 - private var refreshPlayerLists: BlockQueueTask? = null //利用LinkedBlockingDeque创建异步生产者-消费者任务 //todo 需要停止线程 + private var refreshPlayerLists: BlockQueueTask? = + null //利用LinkedBlockingDeque创建异步生产者-消费者任务 //todo 需要停止线程 private var lastThread: LastThread? = null//执行最后一次 private val handler = Handler(Looper.getMainLooper()) @@ -60,9 +65,9 @@ object Repository { private var playViewModel: PlayViewModel? = null//viewModel private var timer: Timer = Timer() - private var kuroTimer: KuroTimer=KuroTimer() + private var kuroTimer: KuroTimer = KuroTimer() - val taxiApp:TaxiApp = TaxiApp.instance() as TaxiApp + val taxiApp: TaxiApp = TaxiApp.instance() as TaxiApp var currentListOrder: Int = 0 @@ -72,19 +77,20 @@ object Repository { currentSyncTime = syncTime } - fun cancelTimer(){ + fun cancelTimer() { kuroTimer.cancel() kuroTimer.purge() } fun getAdvertiseTEST(): Advertise? { - synchronized(TaxiApp::class.java){ + synchronized(TaxiApp::class.java) { val list = myListMap[getTestPlayLevels()] "广告数量:${list?.size},currentListOrder:$currentListOrder".loge() //#edit by ljh 2023/2/16 - var advertise:Advertise? = null + var advertise: Advertise? = null val isTimedAdvertise = Configurations.config(taxiApp.activity).isTimedAdvertise - advertise = if (isTimedAdvertise){ + "从共享空间里面取出来的定时,${isTimedAdvertise}".loge() + advertise = if (isTimedAdvertise) { getTestPlayAdvertise(taxiApp.timedAds) } else { getTestPlayAdvertise(list) @@ -98,9 +104,9 @@ object Repository { "getTestPlayCircularList".logd() //#edit by ljh @2023/2/23 //如果正在播放的是多时段的定时广告,则返回定时广告的播放列表,否则返回不定时的播放列表 - val taxiApp:TaxiApp = TaxiApp.instance() as TaxiApp + val taxiApp: TaxiApp = TaxiApp.instance() as TaxiApp val isTimedAdNow = Configurations.config(taxiApp.activity).isTimedAdvertise - val list = if (!isTimedAdNow){ + val list = if (!isTimedAdNow) { myListMap[getTestPlayLevels()] } else { taxiApp.timedAds @@ -109,7 +115,6 @@ object Repository { } - /** * 拿到将要播放的广告 */ @@ -194,48 +199,53 @@ object Repository { * @return Int */ fun getTestPlayLevels(): Int { - synchronized(TaxiApp::class.java){ - val levels = AdvertiseType.values() - val isTimedAdvertise = Configurations.config(taxiApp.activity).isTimedAdvertise - "getTestPlayLevels -> isTimedAdvertise:$isTimedAdvertise".loge() - for (index in AdvertiseType.values().size downTo 0) { - //#edit by ljh 2023/2/27 - //先判断当前的播放列表是否是分时段播放列表,还是正常的播放列表 - val list = if (!isTimedAdvertise){ - myListMap[index] - } else { - "分时段播放列表".loge() - taxiApp.timedAds - return AdvertiseType.GROUP.ordinal - } - list?.let { - if (it.size > 0) { - val level = when(index){ - AdvertiseType.AREA.ordinal -> "定点广告" - AdvertiseType.IDLE.ordinal -> "闲置广告" - AdvertiseType.GROUP.ordinal -> "分组广告" - AdvertiseType.COUNT.ordinal -> "计数广告" - else -> "其他广告" - } - YoungUtil.YoungLog("当前播放广告的等级:$level,播放列表不为空") - return index - } - } - } - YoungUtil.YoungLog("当前播放广告的等级:闲置广告") - return AdvertiseType.IDLE.ordinal - } + synchronized(TaxiApp::class.java) { + val levels = AdvertiseType.values() + val isTimedAdvertise = Configurations.config(taxiApp.activity).isTimedAdvertise + "getTestPlayLevels -> isTimedAdvertise:$isTimedAdvertise".loge() + for (index in AdvertiseType.values().size downTo 0) { + //#edit by ljh 2023/2/27 + //先判断当前的播放列表是否是分时段播放列表,还是正常的播放列表 + val list = if (!isTimedAdvertise) { + myListMap[index] + } else { + "分时段播放列表".loge() + "分时段播放列表,${index}的广告值".loge() + taxiApp.timedAds + return AdvertiseType.GROUP.ordinal + } + list?.let { + if (it.size > 0) { + val level = when (index) { + AdvertiseType.AREA.ordinal -> "定点广告" + AdvertiseType.IDLE.ordinal -> "闲置广告" + AdvertiseType.GROUP.ordinal -> "分组广告" + AdvertiseType.COUNT.ordinal -> "计数广告" + else -> "其他广告" + } + YoungUtil.YoungLog("当前播放广告的等级:$level,播放列表不为空") + return index + } + } + } + YoungUtil.YoungLog("当前播放广告的等级:闲置广告") + return AdvertiseType.IDLE.ordinal + } } /** * 刷新循环列表 */ fun refreshMyList() { - synchronized(TaxiApp::class.java){ - var lazyList:LazyList? = null + synchronized(TaxiApp::class.java) { + var lazyList: LazyList? = null try { val currentTimeMillis = System.currentTimeMillis() - YoungUtil.YoungLog("refreshMyList 是否在主线程: ${Thread.currentThread().isMainThread()}") + YoungUtil.YoungLog( + "refreshMyList 是否在主线程: ${ + Thread.currentThread().isMainThread() + }" + ) //#edit by ljh @2023/6/29 for (index in AdvertiseType.values().size downTo 0) { @@ -248,10 +258,12 @@ object Repository { val isTimedAdNow = Configurations.config(taxiApp.activity).isTimedAdvertise "现在是否正在播定时广告:$isTimedAdNow".loge() var tempList: ArrayList? = null - if (isTimedAdNow){ + if (isTimedAdNow) { val timedListJsonStr = Configurations.config(taxiApp.activity).timedAdList() - if (taxiApp.timedAds.isEmpty()){ - tempList = ProcessingCommands.gson.fromJson(timedListJsonStr,object :TypeToken>(){}.type) as ArrayList + if (taxiApp.timedAds.isEmpty()) { + tempList = ProcessingCommands.gson.fromJson(timedListJsonStr, + object : + TypeToken>() {}.type) as ArrayList taxiApp.timedAds.addAll(tempList) } // taxiApp.timedAds.clear() @@ -263,7 +275,7 @@ object Repository { // val daoAdvertises = DaoUtil.getAdvertise().queryBuilder().orderDesc(AdvertiseDao.Properties.CreateAt).list() //#edit by ljh @2023/8/7 - val daoAdvertises:List = if (taxiApp.daoAds.isNotEmpty()){ + val daoAdvertises: List = if (taxiApp.daoAds.isNotEmpty()) { "从缓存获取广告列表.数量:${taxiApp.daoAds.size}".logd() // taxiApp.daoAds.sortByDescending { // it.createAt @@ -279,7 +291,8 @@ object Repository { taxiApp.cacheDaoAds } else { // val currentAds = DaoUtil.getAdvertise().queryBuilder().orderDesc(AdvertiseDao.Properties.CreateAt).list() - lazyList = DaoUtil.getAdvertise().queryBuilder().orderDesc(AdvertiseDao.Properties.CreateAt).listLazyUncached() + lazyList = DaoUtil.getAdvertise().queryBuilder() + .orderDesc(AdvertiseDao.Properties.CreateAt).listLazyUncached() for (currentAd in lazyList) { taxiApp.daoAds.add(currentAd) } @@ -294,12 +307,15 @@ object Repository { val advertises = mutableListOf() //定点广告list //#edit by ljh @2023/8/11 - val areaCount = DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.BelongTo.eq(AdvertiseType.AREA.ordinal)).count() + val areaCount = DaoUtil.getAdvertise().queryBuilder() + .where(AdvertiseDao.Properties.BelongTo.eq(AdvertiseType.AREA.ordinal)).count() YoungUtil.YoungLog("定点广告数量:${areaCount}") val order = Configurations.config(TaxiApp.instance()).advertiseOrder() "orderJson:$order".logd() if (order != "" && areaCount == 0L) { - val orderList = Gson().fromJson(Configurations.config(TaxiApp.instance()).advertiseOrder()).advertise_order + val orderList = Gson().fromJson( + Configurations.config(TaxiApp.instance()).advertiseOrder() + ).advertise_order YoungUtil.YoungLog("当前的播放顺序策略:${orderList.toString()}") orderList.forEach { orderListAdid -> @@ -334,6 +350,7 @@ object Repository { for (index in 0 until advertises.size) { YoungUtil.YoungLog("列表序号:${advertises[index].ad_id} 创建时间 ${advertises[index].createAt}") + Log.d(TAG, "refreshMyList:列表序号:${advertises[index].ad_id} 创建时间 ${advertises[index].createAt}") // sb.append("\n广告id:${advertise.ad_id}") val advertise = advertises[index] @@ -347,16 +364,19 @@ object Repository { //#edit by ljh 2023/2/17 //重启时如果是分时段广告,则重新开启它的分时段播放任务 - newAdvertise.isTimedAd?.let { + newAdvertise.isTimedAd.let { var tasks = taxiApp.timerTaskMap[newAdvertise.ad_id] - if (tasks.isNullOrEmpty()){ + if (tasks.isNullOrEmpty()) { val schedules = DaoUtil.getSchedule().queryBuilder() - .where(ScheduleDao.Properties.AdvertiseId.eq(newAdvertise.ad_id)).list() -// "schedules数量:${schedules.size}".loge() - if (!schedules.isNullOrEmpty()){ + .where(ScheduleDao.Properties.AdvertiseId.eq(newAdvertise.ad_id)) + .list() + // "schedules数量:${schedules.size}".loge() + if (!schedules.isNullOrEmpty()) { newAdvertise.isTimedAd = true 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 //edit by ljh @2023/8/14 taxiApp.daoAds.clear() @@ -377,12 +397,12 @@ object Repository { if (newAdvertise.isAllowPlay()) { //#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() myListMap[newAdvertise.belongTo]?.add(newAdvertise) - } else if(isTimedAdNow && newAdvertise.isTimedAd && newAdvertise.is_exclusive) { + } else if (isTimedAdNow && newAdvertise.isTimedAd && newAdvertise.is_exclusive) { taxiApp.timedAds.forEach { - if (it.ad_id == newAdvertise.ad_id){ + if (it.ad_id == newAdvertise.ad_id) { taxiApp.timedAds.remove(it) taxiApp.timedAds.add(newAdvertise) } @@ -396,13 +416,13 @@ object Repository { taxiApp.daoAds.clear() } } - } catch (e:Exception){ + } catch (e: Exception) { e.printStackTrace() e.message?.loge() refreshMyList() } finally { lazyList?.let { - if (!it.isClosed){ + if (!it.isClosed) { it.close() } } @@ -429,8 +449,8 @@ object Repository { region_id = oldAdvertise.region_id longitude = oldAdvertise.longitude latitude = oldAdvertise.latitude - isDownloaded =oldAdvertise.isDownloaded - isDownloading =oldAdvertise.isDownloading + isDownloaded = oldAdvertise.isDownloaded + isDownloading = oldAdvertise.isDownloading //#edit by ljh 2023/2/6 isCount = oldAdvertise.isCount @@ -501,27 +521,37 @@ object Repository { refreshMyList() // "sync:${Configurations.config(TaxiApp.instance()).sync()}".loge() //#edit by ljh @2023/12/12 定点刷新 - if (taxiApp.isPositionRefresh){ + if (taxiApp.isPositionRefresh) { //非同步播放或者定点播放 YoungUtil.YoungLog("非同步刷新") playViewModel!!.refreshAdvertise() taxiApp.isPositionRefresh = false - } else if (Configurations.config(TaxiApp.instance()).sync() && getTestPlayLevels() == AdvertiseType.GROUP.ordinal) { + } else if (Configurations.config(TaxiApp.instance()) + .sync() && getTestPlayLevels() == AdvertiseType.GROUP.ordinal + ) { //设置同步播放并且是分组广告 // if (Settings.sync) { - val syncTimeModel = getSyncSingleTime(currentSyncTime, getTestPlayCircularList()) + val syncTimeModel = + getSyncSingleTime(currentSyncTime, getTestPlayCircularList()) YoungUtil.YoungLog("播放方式为同步播放,同步时间:${syncTimeModel.delay}=============================================") val currentTimeMillis = System.currentTimeMillis() // val advertise = getAdvertiseTEST() - val getAdvertiseSyncTime = syncTimeModel.delay-(System.currentTimeMillis()-currentTimeMillis) + val getAdvertiseSyncTime = + syncTimeModel.delay - (System.currentTimeMillis() - currentTimeMillis) YoungUtil.YoungLog("获取到广告的时间 校准同步时间:$getAdvertiseSyncTime") // handler.postDelayed(SyncTimerTask(playViewModel!!, advertise, syncTimeModel.currentPosition), syncTimeModel.delay) - "即将播放的视频索引:${syncTimeModel.currentPosition}".logd() + "即将播放的视频索引:${syncTimeModel.currentPosition}".logd(TAG) kuroTimer.cancel() kuroTimer.purge() kuroTimer = KuroTimer() // kuroTimer.schedule(SyncTimerTask(playViewModel!!, advertise, syncTimeModel.currentPosition), syncTimeModel.delay) - kuroTimer.schedule(SyncTimerTask(playViewModel!!, null, syncTimeModel.currentPosition), syncTimeModel.delay) + kuroTimer.schedule( + SyncTimerTask( + playViewModel!!, + null, + syncTimeModel.currentPosition + ), syncTimeModel.delay + ) } else { //非同步播放或者定点播放 YoungUtil.YoungLog("播放方式为非同步播放") diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoMaster.java b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoMaster.java index 4454b9c..fb130c8 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoMaster.java +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoMaster.java @@ -23,6 +23,7 @@ public class DaoMaster extends AbstractDaoMaster { public static void createAllTables(Database db, boolean ifNotExists) { AdvertiseDao.createTable(db, ifNotExists); ContainerDao.createTable(db, ifNotExists); + FirstPlayModelDao.createTable(db, ifNotExists); LocationDao.createTable(db, ifNotExists); NotNetAdvertiseDao.createTable(db, ifNotExists); OrderDao.createTable(db, ifNotExists); @@ -41,6 +42,7 @@ public class DaoMaster extends AbstractDaoMaster { public static void dropAllTables(Database db, boolean ifExists) { AdvertiseDao.dropTable(db, ifExists); ContainerDao.dropTable(db, ifExists); + FirstPlayModelDao.dropTable(db, ifExists); LocationDao.dropTable(db, ifExists); NotNetAdvertiseDao.dropTable(db, ifExists); OrderDao.dropTable(db, ifExists); @@ -73,6 +75,7 @@ public class DaoMaster extends AbstractDaoMaster { super(db, SCHEMA_VERSION); registerDaoClass(AdvertiseDao.class); registerDaoClass(ContainerDao.class); + registerDaoClass(FirstPlayModelDao.class); registerDaoClass(LocationDao.class); registerDaoClass(NotNetAdvertiseDao.class); registerDaoClass(OrderDao.class); diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoSession.java b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoSession.java index 6a707ee..87f02b9 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoSession.java +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoSession.java @@ -10,6 +10,7 @@ import org.greenrobot.greendao.internal.DaoConfig; import cn.trans88.taxiappkotlin.logic.model.Advertise; import cn.trans88.taxiappkotlin.logic.model.Container; +import cn.trans88.taxiappkotlin.logic.model.FirstPlayModel; import cn.trans88.taxiappkotlin.logic.model.Location; import cn.trans88.taxiappkotlin.logic.model.NotNetAdvertise; import cn.trans88.taxiappkotlin.logic.model.Order; @@ -25,6 +26,7 @@ import cn.trans88.taxiappkotlin.logic.model.TimeSpan; import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao; import cn.trans88.taxiappkotlin.logic.dao.ContainerDao; +import cn.trans88.taxiappkotlin.logic.dao.FirstPlayModelDao; import cn.trans88.taxiappkotlin.logic.dao.LocationDao; import cn.trans88.taxiappkotlin.logic.dao.NotNetAdvertiseDao; import cn.trans88.taxiappkotlin.logic.dao.OrderDao; @@ -49,6 +51,7 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig advertiseDaoConfig; private final DaoConfig containerDaoConfig; + private final DaoConfig firstPlayModelDaoConfig; private final DaoConfig locationDaoConfig; private final DaoConfig notNetAdvertiseDaoConfig; private final DaoConfig orderDaoConfig; @@ -64,6 +67,7 @@ public class DaoSession extends AbstractDaoSession { private final AdvertiseDao advertiseDao; private final ContainerDao containerDao; + private final FirstPlayModelDao firstPlayModelDao; private final LocationDao locationDao; private final NotNetAdvertiseDao notNetAdvertiseDao; private final OrderDao orderDao; @@ -87,6 +91,9 @@ public class DaoSession extends AbstractDaoSession { containerDaoConfig = daoConfigMap.get(ContainerDao.class).clone(); containerDaoConfig.initIdentityScope(type); + firstPlayModelDaoConfig = daoConfigMap.get(FirstPlayModelDao.class).clone(); + firstPlayModelDaoConfig.initIdentityScope(type); + locationDaoConfig = daoConfigMap.get(LocationDao.class).clone(); locationDaoConfig.initIdentityScope(type); @@ -125,6 +132,7 @@ public class DaoSession extends AbstractDaoSession { advertiseDao = new AdvertiseDao(advertiseDaoConfig, this); containerDao = new ContainerDao(containerDaoConfig, this); + firstPlayModelDao = new FirstPlayModelDao(firstPlayModelDaoConfig, this); locationDao = new LocationDao(locationDaoConfig, this); notNetAdvertiseDao = new NotNetAdvertiseDao(notNetAdvertiseDaoConfig, this); orderDao = new OrderDao(orderDaoConfig, this); @@ -140,6 +148,7 @@ public class DaoSession extends AbstractDaoSession { registerDao(Advertise.class, advertiseDao); registerDao(Container.class, containerDao); + registerDao(FirstPlayModel.class, firstPlayModelDao); registerDao(Location.class, locationDao); registerDao(NotNetAdvertise.class, notNetAdvertiseDao); registerDao(Order.class, orderDao); @@ -157,6 +166,7 @@ public class DaoSession extends AbstractDaoSession { public void clear() { advertiseDaoConfig.clearIdentityScope(); containerDaoConfig.clearIdentityScope(); + firstPlayModelDaoConfig.clearIdentityScope(); locationDaoConfig.clearIdentityScope(); notNetAdvertiseDaoConfig.clearIdentityScope(); orderDaoConfig.clearIdentityScope(); @@ -179,6 +189,10 @@ public class DaoSession extends AbstractDaoSession { return containerDao; } + public FirstPlayModelDao getFirstPlayModelDao() { + return firstPlayModelDao; + } + public LocationDao getLocationDao() { return locationDao; } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoUtil.kt b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoUtil.kt index d25790b..fc05fa8 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoUtil.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/DaoUtil.kt @@ -2,7 +2,6 @@ package cn.trans88.taxiappkotlin.logic.dao import cn.trans88.taxiappkotlin.TaxiApp import cn.trans88.taxiappkotlin.ext.logd -import cn.trans88.taxiappkotlin.logic.Repository import cn.trans88.taxiappkotlin.logic.model.* import cn.trans88.taxiappkotlin.ui.advertise.AdvertiseType import java.io.File @@ -24,6 +23,8 @@ object DaoUtil { private var mRegionsDao:RegionsDao private var mContainerDao:ContainerDao private var mRunTimeDataDao:RunTimeDataDao + private var mFirstPlayModelDao:FirstPlayModelDao +// private var mledOkAdvertiseDao: LedOkAdvertiseDao init { // helperDaoDB = HelperDaoDB(TaxiApp.instance(), DB_NAME, null) @@ -41,6 +42,8 @@ object DaoUtil { mRegionsDao = daoSession.regionsDao mContainerDao = daoSession.containerDao mRunTimeDataDao = daoSession.runTimeDataDao + mFirstPlayModelDao= daoSession.firstPlayModelDao +// mledOkAdvertiseDao = daoSession. } @Synchronized @@ -79,6 +82,11 @@ object DaoUtil { return mSanleAdvertiseDao.loadAll() } +// @Synchronized +// fun getLedOkAdvertises(): List { +// return mSanleAdvertiseDao.loadAll() +// } + @Synchronized fun getSanleAdvertise(): SanleAdvertiseDao { return mSanleAdvertiseDao @@ -88,6 +96,10 @@ object DaoUtil { fun getRunTimeDao(): RunTimeDataDao { return mRunTimeDataDao } + @Synchronized + fun getFirstPlayDao(): FirstPlayModelDao{ + return mFirstPlayModelDao + } @Synchronized fun getPositionAdvertise(): PositionAdvertiseDao = mPositionAdvertiseDao diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/FirstPlayModelDao.java b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/FirstPlayModelDao.java new file mode 100644 index 0000000..7cb24d0 --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/FirstPlayModelDao.java @@ -0,0 +1,126 @@ +package cn.trans88.taxiappkotlin.logic.dao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import cn.trans88.taxiappkotlin.logic.model.FirstPlayModel; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "FIRST_PLAY_MODEL". +*/ +public class FirstPlayModelDao extends AbstractDao { + + public static final String TABLENAME = "FIRST_PLAY_MODEL"; + + /** + * Properties of entity FirstPlayModel.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, String.class, "id", true, "ID"); + public final static Property Play_numbers = new Property(1, int.class, "play_numbers", false, "PLAY_NUMBERS"); + public final static Property IsTimedAd = new Property(2, boolean.class, "isTimedAd", false, "IS_TIMED_AD"); + } + + + public FirstPlayModelDao(DaoConfig config) { + super(config); + } + + public FirstPlayModelDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"FIRST_PLAY_MODEL\" (" + // + "\"ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: id + "\"PLAY_NUMBERS\" INTEGER NOT NULL ," + // 1: play_numbers + "\"IS_TIMED_AD\" INTEGER NOT NULL );"); // 2: isTimedAd + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"FIRST_PLAY_MODEL\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, FirstPlayModel entity) { + stmt.clearBindings(); + + String id = entity.getId(); + if (id != null) { + stmt.bindString(1, id); + } + stmt.bindLong(2, entity.getPlay_numbers()); + stmt.bindLong(3, entity.getIsTimedAd() ? 1L: 0L); + } + + @Override + protected final void bindValues(SQLiteStatement stmt, FirstPlayModel entity) { + stmt.clearBindings(); + + String id = entity.getId(); + if (id != null) { + stmt.bindString(1, id); + } + stmt.bindLong(2, entity.getPlay_numbers()); + stmt.bindLong(3, entity.getIsTimedAd() ? 1L: 0L); + } + + @Override + public String readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0); + } + + @Override + public FirstPlayModel readEntity(Cursor cursor, int offset) { + FirstPlayModel entity = new FirstPlayModel( // + cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // id + cursor.getInt(offset + 1), // play_numbers + cursor.getShort(offset + 2) != 0 // isTimedAd + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, FirstPlayModel entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0)); + entity.setPlay_numbers(cursor.getInt(offset + 1)); + entity.setIsTimedAd(cursor.getShort(offset + 2) != 0); + } + + @Override + protected final String updateKeyAfterInsert(FirstPlayModel entity, long rowId) { + return entity.getId(); + } + + @Override + public String getKey(FirstPlayModel entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(FirstPlayModel entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/HelperDaoDB.kt b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/HelperDaoDB.kt index 2313130..45d3de7 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/HelperDaoDB.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/dao/HelperDaoDB.kt @@ -34,7 +34,8 @@ class HelperDaoDB( TimeSpanDao::class.java, RegionsDao::class.java, PositionAdvertiseDao::class.java, - TextInfoDao::class.java + TextInfoDao::class.java, + FirstPlayModelDao::class.java ) } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/model/FirstPlayModel.java b/app/src/main/java/cn/trans88/taxiappkotlin/logic/model/FirstPlayModel.java new file mode 100644 index 0000000..b589049 --- /dev/null +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/model/FirstPlayModel.java @@ -0,0 +1,67 @@ +package cn.trans88.taxiappkotlin.logic.model; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Generated; + +/** + * @Author: LJH + * @Time: 2024/10/22 + * @description: + */ +@Entity +public class FirstPlayModel { + @Id + public String id; //跟ConnManger里面的advertise.ad_id对应 + public int play_numbers; + public boolean isTimedAd; + + + +@Generated(hash = 1896081626) +public FirstPlayModel(String id, int play_numbers, boolean isTimedAd) { + this.id = id; + this.play_numbers = play_numbers; + this.isTimedAd = isTimedAd; +} + +@Generated(hash = 1394559698) +public FirstPlayModel() { +} + + + + public boolean isTimedAd() { + return isTimedAd; + } + + public void setTimedAd(boolean timedAd) { + isTimedAd = timedAd; + } + + + public int getPlay_numbers() { + return play_numbers; + } + + public void setPlay_numbers(int play_numbers) { + this.play_numbers = play_numbers; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public boolean getIsTimedAd() { + return this.isTimedAd; + } + + public void setIsTimedAd(boolean isTimedAd) { + this.isTimedAd = isTimedAd; + } +} diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/ConnManger.kt b/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/ConnManger.kt index 861da85..3309330 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/ConnManger.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/ConnManger.kt @@ -1,35 +1,38 @@ package cn.trans88.taxiappkotlin.logic.network import android.annotation.SuppressLint +import android.os.Handler import android.os.Looper import android.os.RemoteException -import androidx.constraintlayout.solver.GoalRow +import android.util.Log import cn.trans88.kurotool.net.rx.BaseObserver import cn.trans88.kurotool.net.rx.RxRestClient import cn.trans88.kurotool.util.ThreadUtil import cn.trans88.taxiappkotlin.Configurations import cn.trans88.taxiappkotlin.TaxiApp -import cn.trans88.taxiappkotlin.ext.fromJson import cn.trans88.taxiappkotlin.ext.logd import cn.trans88.taxiappkotlin.ext.loge +//import cn.trans88.taxiappkotlin.ledok.WsManagerLedOk import cn.trans88.taxiappkotlin.logic.Repository import cn.trans88.taxiappkotlin.logic.Repository.taxiApp +import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao import cn.trans88.taxiappkotlin.logic.dao.DaoUtil +import cn.trans88.taxiappkotlin.logic.dao.DaoUtil.getAdvertise +import cn.trans88.taxiappkotlin.logic.dao.DaoUtil.getFirstPlayDao +import cn.trans88.taxiappkotlin.logic.dao.FirstPlayModelDao import cn.trans88.taxiappkotlin.logic.model.* import cn.trans88.taxiappkotlin.net.EasyHttpTool import cn.trans88.taxiappkotlin.net.OkHttpTool import cn.trans88.taxiappkotlin.play.RefreshPlayer import cn.trans88.taxiappkotlin.ui.play.PlayActivity -import cn.trans88.taxiappkotlin.ui.play.isSendedLog +import cn.trans88.taxiappkotlin.ui.play.PlayViewModel +import cn.trans88.taxiappkotlin.util.DateUtil.daysBetweenTimestamps import cn.trans88.taxiappkotlin.util.KuroTimer -import cn.trans88.taxiappkotlin.util.KuroTimerTask import cn.trans88.taxiappkotlin.util.YoungUtil import cn.trans88.taxiappkotlin.util.checkAppToken import cn.trans88.taxiappkotlin.xixunUtil.Xixun -import com.alibaba.fastjson.JSON import com.amused.joey.DelayTimer import com.google.gson.Gson -import com.google.gson.JsonObject import com.google.gson.JsonParser import com.trs88.kurolibrary.execute.KuroExecutor import com.trs88.kurolibrary.file.KuroFileUtil @@ -41,16 +44,14 @@ import com.zhouyou.http.exception.ApiException import net.sysolution.taxiapp.ITaxiListener import okhttp3.* import okhttp3.MediaType.Companion.toMediaTypeOrNull -import okhttp3.RequestBody.Companion.asRequestBody import java.io.File import java.io.IOException +import java.lang.ref.WeakReference import java.util.* -import java.util.concurrent.Executors -import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit -import java.util.stream.Collectors import kotlin.concurrent.thread + /** * @author TRS * @deprecated 处理各种网络请求连接 @@ -58,6 +59,11 @@ import kotlin.concurrent.thread object ConnManger { + private lateinit var playViewModel: PlayViewModel + + fun setPlayViewModel(viewModel: PlayViewModel) { + playViewModel = viewModel + } //如果是绑定账号或者转移账号,就不对比conn var isBindOrTransfer = false //保存到conn的实体类信息 @@ -684,6 +690,7 @@ object ConnManger { }) } + /** * 获取播放的总次数 */ @@ -720,13 +727,80 @@ object ConnManger { if (response.code == 200){ val realCount = countStr?.toInt() "responseBody.string:${realCount.toString()}".loge() - if (advertise.play_numbers < realCount!!){ + "广告[${advertise.ad_id}]已请求次数【${realCount}】,总播放次数:${advertise.play_numbers}".loge() + //根据id获取count次数,如果是第一次就存到数据库中,记录id advertise.ad_id + if (realCount==1) + { + var firstPlayModel=FirstPlayModel() + firstPlayModel.apply { + id=advertise.ad_id + play_numbers=advertise.play_numbers + isTimedAd=false + } + Log.d("ConnManger", "广告timeSection的数量:"+advertise.time_section.size.toString()) + if (advertise.time_section!=null && advertise.time_section.size>0) + firstPlayModel.isTimedAd=true + "id:${firstPlayModel.id},次数:${firstPlayModel.play_numbers},分时段?${firstPlayModel.isTimedAd}".loge() + DaoUtil.getFirstPlayDao().insert(firstPlayModel) + } + val firstPlay = getFirstPlayDao() + .queryBuilder() + .where(FirstPlayModelDao.Properties.Id.eq(advertise.ad_id)) + .unique() +// if (advertise.play_numbers < realCount!! % (firstPlay.play_numbers+1) || realCount % (firstPlay.play_numbers+1)==0) + if (realCount!! % (firstPlay.play_numbers+1)==0) + { if (advertise.play_numbers != -1 ){ advertise.play_numbers = -1 //edit by ljh @2023/8/14 taxiApp.daoAds.clear() - DaoUtil.updatePlayNumbers(advertise) + if (advertise.play_numbers < 0){ + Log.d("PlayViewModel", "广告具体内容:$advertise"); + var firstPlay= getFirstPlayDao() + .queryBuilder() + .where(FirstPlayModelDao.Properties.Id.eq(advertise.ad_id)) + .unique() + Log.d("PlayViewModel", "从数据库中拿到的广告内容:${firstPlay}"); + if (firstPlay.isTimedAd) + { + advertise.isTimedAd=true + //从数据库中获取到的节目播放次数,然后在这里重新给advertise.play_numbers赋值,然后持久化到数据库 + advertise.play_numbers=firstPlay.play_numbers + getAdvertise().insertOrReplace(advertise) + } + Log.d("PlayViewModel","是分时段广告?"+advertise.isTimedAd); + if (advertise.isTimedAd){ + Handler(Looper.getMainLooper()).post { + "是定时广告,进来了要先删除后添加,广告内容是:${advertise},广告id是:${advertise.ad_id}".loge() + //删除是为了停止播放定时节目后能继续播放普通广告 + DaoUtil.deleteAdvertise(advertise) + //添加是为了定时广告在后面能继续播放 + getAdvertise().insert(advertise) + playViewModel.refreshAdvertise() + } + return + } + "删除次数已到达的广告".loge() + //删除次数已到达的广告 + DaoUtil.deleteAdvertise(advertise) + //如果是分时段广告 + if (advertise.isTimedAd){ + //移除广告的定时任务 + val tasks = taxiApp.timerTaskMap[advertise.ad_id] + tasks?.let { + if (tasks.isNotEmpty()){ + tasks.forEach { timeTask -> + timeTask.cancel() + } + } + } + } + ConnManger.sendOfflineAd(advertise.ad_id) + Repository.currentListOrder += 1 + playViewModel.refreshAdvertise() + return + } } try { @@ -736,8 +810,7 @@ object ConnManger { } } - "广告[${advertise.ad_id}]已请求次数【${realCount}】,总播放次数:${advertise.play_numbers}".loge() - if(advertise.play_numbers != -1){ + else{ val activity = taxiApp.activity as PlayActivity activity.getViewModel().saveCountAdLog(advertise) } @@ -1055,7 +1128,7 @@ object ConnManger { override fun onFailure(call: Call, e: IOException) { YoungUtil.YoungLog("上传log失败:${e.message}") if (file.exists()) { - file.delete() +// file.delete() } } @@ -1149,10 +1222,56 @@ object ConnManger { //Settings.registerToken = bindModel.accountIdToken Configurations.config(TaxiApp.instance()).registerTokenSave(bindModel.accountIdToken) } - listener.onSuccess("true") + listener?.onSuccess("true") } catch (e: RemoteException) { e.printStackTrace() - listener.onError(e.message) + listener?.onError(e.message) + } + } + + /** + * 绑定账号 + */ + @SuppressLint("SuspiciousIndentation") + @Synchronized + fun mbindAccount(bindModel: BindModel): Boolean { + try { + YoungUtil.YoungLog("准备绑定账号") + //edit by yzd @20211201 + val accountId = checkAppToken(bindModel.accountIdToken) + //2022-0620by yzd修复一个bug:下面这行如果不注释,导致切换凭证的时候如果taxibaseUrl没变,setConnServiceUrl就不会被调用,使得conn不会切换服务地址 + //if (accountId != Configurations.config(TaxiApp.instance()).accountId() || bindModel.server != Configurations.config(TaxiApp.instance()).taxiBaseUrl()) { + //Settings.accountId = accountId + val currentRegisterToken = Configurations.config(TaxiApp.instance()).registerToken() + val connServiceUrl = Configurations.config(TaxiApp.instance()).connServiceUrl() + //#edit by ljh @2023/7/20 + //token不一样再去重新注册,连接 + if (!currentRegisterToken.equals(bindModel.accountIdToken) || !(bindModel.server.equals(connServiceUrl))){ + Configurations.config(TaxiApp.instance()).accountIdSave(accountId) + //不等说明账户更换,重新连接 + resetAccountCleanDao() + Configurations.config(TaxiApp.instance()).registerTokenSave(bindModel.accountIdToken) + + if (bindModel.server != null && bindModel.server != "") { + //Settings.taxiBaseUrl = bindModel.server + Configurations.config(TaxiApp.instance()).taxiBaseUrlSave(bindModel.server); + setConnServiceUrl(bindModel.server) + } + //不验证conn的信息 + isBindOrTransfer = true + + reconnect(1003,"切换账户关闭连接") + + YoungUtil.YoungLog("用户不同,账号重新绑定") + //} + YoungUtil.YoungLog("账号绑定完成") + //Settings.registerToken = bindModel.accountIdToken + Configurations.config(TaxiApp.instance()).registerTokenSave(bindModel.accountIdToken) + } + return true + } catch (e: RemoteException) { + e.printStackTrace() + return false } } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/ProcessingCommands.kt b/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/ProcessingCommands.kt index 2dc8bd0..3427ed9 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/ProcessingCommands.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/ProcessingCommands.kt @@ -1,5 +1,6 @@ package cn.trans88.taxiappkotlin.logic.network +import android.util.Log import cn.trans88.kurotool.util.LogUtil import cn.trans88.taxiappkotlin.Configurations import cn.trans88.taxiappkotlin.R @@ -10,6 +11,7 @@ import cn.trans88.taxiappkotlin.TaxiApp.Companion.XIXUN import cn.trans88.taxiappkotlin.ext.fromJson import cn.trans88.taxiappkotlin.ext.logd import cn.trans88.taxiappkotlin.ext.loge +import cn.trans88.taxiappkotlin.ledok.LedOkActivity import cn.trans88.taxiappkotlin.logic.Repository import cn.trans88.taxiappkotlin.logic.Repository.taxiApp import cn.trans88.taxiappkotlin.logic.dao.* @@ -28,22 +30,55 @@ import com.trs88.kurolibrary.file.KuroFileUtil import java.io.* import java.util.* + object ProcessingCommands { + const val TAG = "ProcessingCommands" val gson = Gson() - var beatTimer:Timer? = null + var beatTimer: Timer? = null var areaIndex = 0 + + /** + * 三乐平台的命令 + */ + fun executeByLedOk(command: String) { + Log.d(TAG, "executeByLedOk: command: $command") + try { + val baseTask = gson.fromJson(command, BaseTask::class.java) + Log.d(TAG, "executeByLedOk: baskTask: $baseTask") + if (baseTask.type != null) { + //日志存卡里 + val task = baseTask.task.toString() + when (baseTask.type) { + //添加普通广告 + "place_task_ad" -> addLedOkAdvertise(task, baseTask.type) + else -> YoungUtil.YoungLog("三乐 未知命令") + } + } + } catch (e: Exception) { + val sb = logException(e) + YoungUtil.YoungLog("三乐长连接执行命令出现异常: $sb") + } + } + /** * 三乐平台的命令 */ fun executeBySanle(command: String) { YoungUtil.YoungLog("executeBySanle") + Log.d(TAG, "executeBySanle: command: $command") try { +// val applicationContext = TaxiApp.instance().applicationContext +// val intent = Intent(applicationContext, LedOkActivity::class.java) +// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) +// applicationContext.startActivity(intent) + val baseTask = gson.fromJson(command, BaseTask::class.java) YoungUtil.YoungLog("baskTask :${baseTask.toString()}") + Log.d(TAG, "executeBySanle: baskTask: $baseTask") if (baseTask.type != null) { @@ -64,38 +99,38 @@ object ProcessingCommands { //设置taxi各种背景 "set_taxi_background" -> setBusInfo(task, baseTask.type) //设置debug模式 - "set_debug_mode" -> setLogWriteEnable(task,baseTask.type) + "set_debug_mode" -> setLogWriteEnable(task, baseTask.type) //设置排序 - "set_advertise_order" -> setAdvertiseOrder(task,baseTask.type) - "clear_advertise_order" -> clearAdvertiseOrder(task,baseTask.type) + "set_advertise_order" -> setAdvertiseOrder(task, baseTask.type) + "clear_advertise_order" -> clearAdvertiseOrder(task, baseTask.type) //添加定点广告 - "place_region_ad" -> addPositionAdvertise(task,baseTask.type) - "delete_region_ad" -> deletePositionAdvertise(task,baseTask.type) - "add_regions_in_region_ad" -> putPositionResponse(task,baseTask.type) + "place_region_ad" -> addPositionAdvertise(task, baseTask.type) + "delete_region_ad" -> deletePositionAdvertise(task, baseTask.type) + "add_regions_in_region_ad" -> putPositionResponse(task, baseTask.type) //设置调试信息 - "uploadDebugFile" -> sendLogService(task,baseTask.type) + "uploadDebugFile" -> sendLogService(task, baseTask.type) // //发送真正播放的广告列表 // "get_play_ad_list"->sendPlayAdvertiseInfo(task,baseTask.type) //发送收到所有广告的adid - "get_ad_list" -> sendAllAdvertiseInfo(task,baseTask.type) + "get_ad_list" -> sendAllAdvertiseInfo(task, baseTask.type) //发送广告排序给服务器 - "get_advertise_order" -> sendOrderInfo(task,baseTask.type) - "update_player_log_switch" -> playLoggerSwitch(task,baseTask.type) - "update_gps_log_switch" -> gpsSwitch(task,baseTask.type) - "soft_decode_switch" -> isSoftDecodeSwitch(task,baseTask.type) + "get_advertise_order" -> sendOrderInfo(task, baseTask.type) + "update_player_log_switch" -> playLoggerSwitch(task, baseTask.type) + "update_gps_log_switch" -> gpsSwitch(task, baseTask.type) + "soft_decode_switch" -> isSoftDecodeSwitch(task, baseTask.type) //获取播放日志开关状态 - "get_player_log_state" -> getLoggerSwitch(task,baseTask.type) - "get_soft_decode" -> getSoftDecodeState(task,baseTask.type) + "get_player_log_state" -> getLoggerSwitch(task, baseTask.type) + "get_soft_decode" -> getSoftDecodeState(task, baseTask.type) //设置日志上传间隔 - "set_log_interval" -> setLogInterval(task,baseTask.type) - "get_log_interval" -> getLogInterval(task,baseTask.type) + "set_log_interval" -> setLogInterval(task, baseTask.type) + "get_log_interval" -> getLogInterval(task, baseTask.type) //获取gps日志开关状态 - "get_gps_state" -> getGpsSwitch(task,baseTask.type) - "get_today_runtime" -> getTodayRuntime(task,baseTask.type) + "get_gps_state" -> getGpsSwitch(task, baseTask.type) + "get_today_runtime" -> getTodayRuntime(task, baseTask.type) //直接清空所有广告 - "clear_ads" -> clearAdvertises(task,baseTask.type) - "get_log_file_list" -> getLogFilesAllName(task,baseTask.type) - "beat_reply" -> beatCheck(task,baseTask.type) + "clear_ads" -> clearAdvertises(task, baseTask.type) + "get_log_file_list" -> getLogFilesAllName(task, baseTask.type) + "beat_reply" -> beatCheck(task, baseTask.type) else -> YoungUtil.YoungLog("三乐 未知命令") } } else { @@ -107,6 +142,9 @@ object ProcessingCommands { } } + + + private fun gpsSwitch(task: String, type: String) { val baseResponse = gson.fromJson(task) val gpsSwitch = gson.fromJson(task) @@ -145,7 +183,7 @@ object ProcessingCommands { "delete_position_ad" -> deleteNormalAdvertise(task) //添加定点广告 "place_region_ad" -> addPositionAdvertise(task, baseTask.type) - "delete_region_ad" -> deletePositionAdvertise(task,baseTask.type) + "delete_region_ad" -> deletePositionAdvertise(task, baseTask.type) "add_regions_in_region_ad" -> putPositionResponse(task, baseTask.type) "switch_taxi_account" -> switchAccount(task, baseTask.type) else -> YoungUtil.YoungLog("熙讯 未知命令") @@ -277,7 +315,7 @@ object ProcessingCommands { //edit by yzd @20211201 //Settings.loggerSwitch =loggerSwitch.isTurn_on Configurations.config(TaxiApp.instance()).loggerSwitchSave(loggerSwitch.isTurn_on) - if (loggerSwitch.isTurn_on){ + if (loggerSwitch.isTurn_on) { // ConnManger.loggerTimer?.cancel() // ConnManger.loggerTimer?.purge() @@ -336,7 +374,7 @@ object ProcessingCommands { //edit by yzd @20211201 //Settings.loggerSwitch = loggerSwitch.isTurn_on Configurations.config(TaxiApp.instance()).loggerSwitchSave(true) - if (loggerInterval.interval > -1){ + if (loggerInterval.interval > -1) { Configurations.config(TaxiApp.instance()).logIntervalSave(loggerInterval.interval) // ConnManger.sendLogSummaryByInterval(loggerInterval.interval) } @@ -355,7 +393,7 @@ object ProcessingCommands { WsManager.isReceivePong = true WsManager.isConnected = true - if(beatTimer!=null){ + if (beatTimer != null) { YoungUtil.YoungLog("received heart response,收到新的心跳应答,取消之前定时") beatTimer!!.cancel() beatTimer!!.purge() @@ -364,7 +402,7 @@ object ProcessingCommands { } beatTimer = Timer() - beatTimer!!.schedule(object :TimerTask(){ + beatTimer!!.schedule(object : TimerTask() { override fun run() { YoungUtil.YoungLog("长时间没新的心跳应答,断开连接重新连接") WsManager.isRegister = true @@ -372,7 +410,7 @@ object ProcessingCommands { ConnManger.isBindOrTransfer = false reconnect(1000, "长时间未收到心跳断开连接并重新注册") } - },36*1000) //#edit by ljh @2023/8/18 改成36s后没收到心跳回复重新注册 + }, 36 * 1000) //#edit by ljh @2023/8/18 改成36s后没收到心跳回复重新注册 // },4*60*1000) } @@ -383,7 +421,7 @@ object ProcessingCommands { val baseResponse = gson.fromJson(task) var orderList = mutableListOf() var ao = Configurations.config(TaxiApp.instance()).advertiseOrder() - if(ao.isNotEmpty()){ + if (ao.isNotEmpty()) { val advertiseOrder = Gson().fromJson(ao) orderList = advertiseOrder.advertise_order } @@ -406,11 +444,13 @@ object ProcessingCommands { //提交未上传成功的下载进度 try { val progressListJson = Configurations.config(taxiApp).progressList() - if (!progressListJson.isNullOrEmpty()){ + if (!progressListJson.isNullOrEmpty()) { "progressListJson:$progressListJson".logd() - val progressList = gson.fromJson(progressListJson,object : TypeToken>(){}.type) as HashSet + val progressList = gson.fromJson(progressListJson, + object : + TypeToken>() {}.type) as HashSet for (advertiseProcess in progressList) { - send(gson.toJson(advertiseProcess)) + send(gson.toJson(advertiseProcess)) } Configurations.config(taxiApp).progressListSave("") taxiApp.processList.clear() @@ -428,12 +468,12 @@ object ProcessingCommands { it.createAt } val allAdIds = mutableListOf() - if (positionAdvertises.size > 0){ + if (positionAdvertises.size > 0) { var isOverdue = true for (positionAdvertise in positionAdvertises) { isOverdue = positionAdvertise.isOverdue() } - val positionAds = if (!isOverdue){ + val positionAds = if (!isOverdue) { positionAdvertises } else { DaoUtil.getPositionAdvertise().loadAll() @@ -449,7 +489,7 @@ object ProcessingCommands { val playList = Repository.getTestPlayCircularList() // val advertises = DaoUtil.getAdvertises() - var currentPlayList = playList?.map { + var currentPlayList = playList?.map { it.ad_id } @@ -515,7 +555,7 @@ object ProcessingCommands { val busInfo = gson.fromJson(task) //#edit by ljh @2023/3/28 //如果传的media_id为空,则取消屏幕的自定义显示 - if (busInfo.media_id.isNullOrEmpty()){ + if (busInfo.media_id.isNullOrEmpty()) { Configurations.config(TaxiApp.instance()).isCustomLogoSave(false) taxiApp.activity?.cancelCustomView() saveBackgroundType(false) @@ -525,39 +565,48 @@ object ProcessingCommands { saveBackgroundType("route") downloadBusInfo(busInfo.media_id, "busLicence", HAOSHENG) } + "brake" -> { saveBackgroundType("brake") downloadBusInfo(busInfo.media_id, "turnStop", HAOSHENG) } + "turn_left" -> { saveBackgroundType("turn_left") downloadBusInfo(busInfo.media_id, "turnLeft", HAOSHENG) } + "turn_right" -> { saveBackgroundType("turn_right") downloadBusInfo(busInfo.media_id, "turnRight", HAOSHENG) } + "vacant" -> { saveBackgroundType("vacant") downloadBusInfo(busInfo.media_id, "vacant", MAIDIER) } + "hired" -> { saveBackgroundType("hired") downloadBusInfo(busInfo.media_id, "hired", MAIDIER) } + "no_service" -> { saveBackgroundType("no_service") downloadBusInfo(busInfo.media_id, "no_service", MAIDIER) } + "booked" -> { saveBackgroundType("booked") downloadBusInfo(busInfo.media_id, "booked", MAIDIER) } + "logo" -> { Configurations.config(TaxiApp.instance()).isCustomLogoSave(true) saveBackgroundType(true) downloadBusInfo(busInfo.media_id, "logo", XIXUN) } + else -> YoungUtil.YoungLog("设置车辆信息 未知type") } } @@ -574,10 +623,10 @@ object ProcessingCommands { * 保存自定义视图类型 * @param type String */ - fun saveBackgroundType(type:String){ + fun saveBackgroundType(type: String) { val gson = Gson() val backgroundTypeJson = Configurations.config(TaxiApp.instance()).backgroundType() - val backgroundType = if (backgroundTypeJson.isNotEmpty()){ + val backgroundType = if (backgroundTypeJson.isNotEmpty()) { gson.fromJson(backgroundTypeJson) } else { BackgroundType() @@ -590,11 +639,11 @@ object ProcessingCommands { * 保存自定义视图类型 * @param type String */ - fun saveBackgroundType(isLogo: Boolean){ + fun saveBackgroundType(isLogo: Boolean) { val taxiApp = TaxiApp.instance() as TaxiApp val gson = taxiApp.gson val backgroundTypeJson = Configurations.config(TaxiApp.instance()).backgroundType() - val backgroundType = if (backgroundTypeJson.isNotEmpty()){ + val backgroundType = if (backgroundTypeJson.isNotEmpty()) { gson.fromJson(backgroundTypeJson) } else { BackgroundType() @@ -603,7 +652,7 @@ object ProcessingCommands { Configurations.config(TaxiApp.instance()).backgroundTypeSave(gson.toJson(backgroundType)) } - private fun setLogWriteEnable(task: String, type: String){ + private fun setLogWriteEnable(task: String, type: String) { val b = JsonParser().parse(task).asJsonObject.get("turn_on").asBoolean val taskId = JsonParser().parse(task).asJsonObject.get("task_id").asString val id = JsonParser().parse(task).asJsonObject.get("id").asString @@ -630,10 +679,10 @@ object ProcessingCommands { val copyfile = File(TaxiApp.instance().filesDir, "/log/${sendLogModel.name}©") - KuroFileUtil.copyFile(file,copyfile) + KuroFileUtil.copyFile(file, copyfile) - if (copyfile.exists()){ - ConnManger.sendLogToService(copyfile,sendLogModel.task_id) + if (copyfile.exists()) { + ConnManger.sendLogToService(copyfile, sendLogModel.task_id) } else { YoungUtil.YoungLog("log文件不存在") } @@ -646,7 +695,8 @@ object ProcessingCommands { private fun downloadBusInfo(url: String, pathName: String, companyName: String) { YoungUtil.YoungLog("bus车辆信息下载 地址: $url, 地址$pathName") - val program = File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program)) + val program = + File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program)) val dest = File(program, pathName) if (dest.exists()) { @@ -658,7 +708,7 @@ object ProcessingCommands { } - private fun logException(e: Exception): StringBuffer { + private fun logException(e: Exception): StringBuffer { val sb = StringBuffer() sb.append("异常类: ${e.javaClass}\n") sb.append("异常信息: ${e.message}\n\n") @@ -750,15 +800,20 @@ object ProcessingCommands { /** * 删除定点广告会同时删除和定点相关的区域、广告、时间、定点数据 */ - private fun deletePositionAdvertise(task: String,type: String) { + private fun deletePositionAdvertise(task: String, type: String) { val advertises = DaoUtil.getPositionAdvertises() - val deletePositionAdvertiseBean = gson.fromJson(task, DeletePositionAdvertiseBean::class.java) + val deletePositionAdvertiseBean = gson.fromJson( + task, + DeletePositionAdvertiseBean::class.java + ) for (advertise in advertises) { if (advertise.task_id == deletePositionAdvertiseBean.task_id) { deletePositionAdvertise(advertise) deleteRegions(advertise.task_id) deleteTimeSpan(advertise.task_id) - DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.Ad_id.eq(deletePositionAdvertiseBean.task_id)).buildDelete() + DaoUtil.getAdvertise().queryBuilder() + .where(AdvertiseDao.Properties.Ad_id.eq(deletePositionAdvertiseBean.task_id)) + .buildDelete() .executeDeleteWithoutDetachingEntities() //edit by ljh @2023/8/16 taxiApp.daoAds.clear() @@ -766,14 +821,19 @@ object ProcessingCommands { break } } - sendResponseToServer(deletePositionAdvertiseBean.task_id,deletePositionAdvertiseBean.id,type) + sendResponseToServer( + deletePositionAdvertiseBean.task_id, + deletePositionAdvertiseBean.id, + type + ) } /** * 删除广告对应的时间任务 */ private fun deleteTimeSpan(id: String?) { - DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(id)).buildDelete().executeDeleteWithoutDetachingEntities() + DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(id)) + .buildDelete().executeDeleteWithoutDetachingEntities() } /** @@ -782,7 +842,8 @@ object ProcessingCommands { private fun deleteRegions(region_ad_id: String) { //edit by ljh @2023/8/15 taxiApp.regionsList.clear() - DaoUtil.getRegion().queryBuilder().where(RegionsDao.Properties.RegionAdId.eq(region_ad_id)).buildDelete().executeDeleteWithoutDetachingEntities() + DaoUtil.getRegion().queryBuilder().where(RegionsDao.Properties.RegionAdId.eq(region_ad_id)) + .buildDelete().executeDeleteWithoutDetachingEntities() } /** @@ -791,14 +852,18 @@ object ProcessingCommands { private fun addPositionAdvertise(task: String, type: String) { //edit by ljh @2023/8/22 // taxiApp.saveLog("添加定点广告 task :${task}") - val positionAdvertise = gson.fromJson(task, PositionAdvertise::class.java) + val positionAdvertise = + gson.fromJson(task, PositionAdvertise::class.java) 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); } positionAdvertise.apply { - val program = File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program)) + val program = File( + TaxiApp.instance().filesDir, + TaxiApp.instance().getString(R.string.dir_program) + ) val dest = File(program, this.task_id) belongTo = AdvertiseType.AREA.ordinal pathName = dest.path @@ -830,7 +895,11 @@ object ProcessingCommands { // DaoUtil.getAdvertise().insert(advertise) // RefreshPlayer.refresh() - downloadFile(positionAdvertise.media_url, positionAdvertise.pathName, positionAdvertise.task_id) + downloadFile( + positionAdvertise.media_url, + positionAdvertise.pathName, + positionAdvertise.task_id + ) val regions = positionAdvertise.regions for (region in regions) { @@ -858,7 +927,7 @@ object ProcessingCommands { /** * 给服务器回复 */ - private fun sendResponseToServer(taskId:String, id:String, type:String){ + private fun sendResponseToServer(taskId: String, id: String, type: String) { val sanleResponse = SanleResponse() sanleResponse.task_id = taskId sanleResponse.id = id @@ -872,7 +941,8 @@ object ProcessingCommands { */ public fun deleteNormalAdvertise(task: String) { val advertises = DaoUtil.getAdvertises() - val deleteAdvertiseBean = gson.fromJson(task, DeleteAdvertiseBean::class.java) + val deleteAdvertiseBean = + gson.fromJson(task, DeleteAdvertiseBean::class.java) for (advertise in advertises) { if (advertise.ad_id == deleteAdvertiseBean.ad_id) { deleteAdvertise(advertise) @@ -934,7 +1004,10 @@ object ProcessingCommands { private fun addNormalAdvertise(task: String) { val advertise = gson.fromJson(task, Advertise::class.java) advertise.apply { - val program = File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program)) + val program = File( + TaxiApp.instance().filesDir, + TaxiApp.instance().getString(R.string.dir_program) + ) val dest = File(program, this.ad_id) belongTo = AdvertiseType.NORMAL.ordinal pathName = dest.path @@ -960,12 +1033,12 @@ object ProcessingCommands { 这里不再判断isDownloading,只要isDownloaded为0就下载 */ //if(!advertise.isDownloading&&!advertise.isDownloaded){ - if(!advertise.isDownloaded){ + if (!advertise.isDownloaded) { //edit by ljh @2023/2/7 - if (advertise.mxkl_url != null && advertise.mxkl_url.isNotEmpty()){ - downloadFileSx(advertise.mxkl_url, advertise.pathName,advertise.ad_id) - }else{ - downloadFile(advertise.media_url, advertise.pathName,advertise.ad_id) + if (advertise.mxkl_url != null && advertise.mxkl_url.isNotEmpty()) { + downloadFileSx(advertise.mxkl_url, advertise.pathName, advertise.ad_id) + } else { + downloadFile(advertise.media_url, advertise.pathName, advertise.ad_id) } } else { YoungUtil.YoungLog("adid:${advertise.ad_id},正在下载或者已经下载完成,不再添加下载任务") @@ -975,23 +1048,27 @@ object ProcessingCommands { } if (insert) { - "insert advertise:$advertise".loge() + "insert advertise:$advertise".loge(TAG) DaoUtil.getAdvertise().insert(advertise) //edit by ljh @2023/8/16 taxiApp.daoAds.clear() +// for (item in advertise.time_Span) { +// item.advertiseId = advertise.ad_id +// getTimeSpan().insert(item) +// } advertise.time_Span.forEach { it.advertiseId = advertise.ad_id DaoUtil.getTimeSpan().insert(it) } //eidt by ljh @2023/2/17 //封装定时广告信息 - if (advertise.isTimedAd){ + if (advertise.isTimedAd) { advertise.time_section.forEach { it.advertiseId = advertise.ad_id val stringBuilder = java.lang.StringBuilder() it.week_day.forEach { weekDay -> - if (it.week_day.last() != weekDay){ + if (it.week_day.last() != weekDay) { stringBuilder.append("$weekDay,") } else { stringBuilder.append("$weekDay") @@ -1006,10 +1083,10 @@ object ProcessingCommands { } //edit by ljh @2023/2/7 - if (advertise.mxkl_url != null && advertise.mxkl_url.isNotEmpty()){ - downloadFileSx(advertise.mxkl_url, advertise.pathName,advertise.ad_id) - }else{ - downloadFile(advertise.media_url, advertise.pathName,advertise.ad_id) + if (advertise.mxkl_url != null && advertise.mxkl_url.isNotEmpty()) { + downloadFileSx(advertise.mxkl_url, advertise.pathName, advertise.ad_id) + } else { + downloadFile(advertise.media_url, advertise.pathName, advertise.ad_id) } } @@ -1018,30 +1095,131 @@ object ProcessingCommands { /** * 添加三乐广告 */ - private fun addSanleAdvertise(task: String, type: String) { + private fun addLedOkAdvertise(task: String, type: String) { //edit by ljh @2023/8/22 // taxiApp.saveLog("添加三乐广告 task :${task}") val sanleAdvertises = DaoUtil.getSanleAdvertises() val sanleAdvertise = gson.fromJson(task, SanleAdvertise::class.java) // send("服务器日志 三乐广告内容 :${sanleAdvertise.toString()}") + "刚收到的添加三乐广告命令,还没有做处理的${sanleAdvertise}".loge(TAG) sanleAdvertise.apply { - val program = File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program)) + val program = File( + TaxiApp.instance().filesDir, + TaxiApp.instance().getString(R.string.dir_program) + ) val dest = File(program, this.task_id) belongTo = AdvertiseType.GROUP.ordinal pathName = dest.path //#edit by ljh 2023/2/6 isCount = false isTimedAd = false - if(play_numbers > 0){ +// if(play_numbers > 0){ +// isCount = true +// "${task_id}计次播放,该广告播放次数为${sanleAdvertise.play_numbers}".logd() +// } +// +// //分时段 +// if (time_section != null && time_section.size>0 && !isCount){ +// isTimedAd = true +// "${task_id}是分时段播放广告".loge() +// } + if (time_section != null && time_section.size > 0) { + isTimedAd = true + "${task_id}是分时段播放广告,后面再判断是否计次".loge() + } +// else if (time_section != null && time_section.size>0 && play_numbers>0) +// { +// isTimedAd = true +// isCount=true +// } + else if (play_numbers > 0) { isCount = true "${task_id}计次播放,该广告播放次数为${sanleAdvertise.play_numbers}".logd() } - if (time_section != null && time_section.size>0 && !isCount){ - isTimedAd = true - "${task_id}是分时段播放广告".loge() + + "mxkl_url:$mxkl_url".loge() + } + + var insert = true + + for (item in sanleAdvertises) { + if (sanleAdvertise.task_id == item.task_id) { + insert = false +// val updateSanleAdvertise = updateSanleAdvertise(item, sanleAdvertise) +// downloadFile(updateSanleAdvertise.media_url,updateSanleAdvertise.pathName) + sanleAdvertiseToAdvertise(sanleAdvertise) + break } + } + + if (insert) { + DaoUtil.getSanleAdvertise().insert(sanleAdvertise) + sanleAdvertiseToAdvertise(sanleAdvertise) + } + + val sanleResponse = SanleResponse() + sanleResponse.task_id = sanleAdvertise.task_id + sanleResponse.id = sanleAdvertise.id + 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}") + } + /** + * 添加三乐广告 + */ + private fun addSanleAdvertise(task: String, type: String) { + LedOkActivity.cancelPersistPlay() + //edit by ljh @2023/8/22 +// taxiApp.saveLog("添加三乐广告 task :${task}") + val sanleAdvertises = DaoUtil.getSanleAdvertises() + val sanleAdvertise = gson.fromJson(task, SanleAdvertise::class.java) + +// send("服务器日志 三乐广告内容 :${sanleAdvertise.toString()}") + "刚收到的添加三乐广告命令,还没有做处理的${sanleAdvertise}".loge() + sanleAdvertise.apply { + val program = File( + TaxiApp.instance().filesDir, + TaxiApp.instance().getString(R.string.dir_program) + ) + val dest = File(program, this.task_id) + belongTo = AdvertiseType.GROUP.ordinal + pathName = dest.path + //#edit by ljh 2023/2/6 + isCount = false + isTimedAd = false +// if(play_numbers > 0){ +// isCount = true +// "${task_id}计次播放,该广告播放次数为${sanleAdvertise.play_numbers}".logd() +// } +// +// //分时段 +// if (time_section != null && time_section.size>0 && !isCount){ +// isTimedAd = true +// "${task_id}是分时段播放广告".loge() +// } + if (time_section != null && time_section.size > 0) { + isTimedAd = true + "${task_id}是分时段播放广告,后面再判断是否计次".loge() + } +// else if (time_section != null && time_section.size>0 && play_numbers>0) +// { +// isTimedAd = true +// isCount=true +// } + else if (play_numbers > 0) { + isCount = true + "${task_id}计次播放,该广告播放次数为${sanleAdvertise.play_numbers}".logd() + } + "mxkl_url:$mxkl_url".loge() } @@ -1109,10 +1287,16 @@ object ProcessingCommands { addAdvertise(advertise) //#edit by ljh 2023/2/17 - if(advertise.isTimedAd){ - val taxiApp:TaxiApp = TaxiApp.instance() as TaxiApp + if (advertise.isTimedAd) { + //是分时段广告,判断有没有次数,如果有次数就在里面判断 + if (advertise.play_numbers > 0) + advertise.isCount = true + "是分时段广告,看是否计次?:${advertise.isCount}".loge() + + val taxiApp: TaxiApp = TaxiApp.instance() as TaxiApp "activity为空吗:${taxiApp.activity == null}".loge() taxiApp.activity?.let { + Log.d(TAG, "进来添加时段活动了!") it.getViewModel().addTimer(advertise) } } @@ -1128,18 +1312,27 @@ object ProcessingCommands { YoungUtil.YoungLog("准备下架三乐广告") //edit by ljh @2023/8/22 // taxiApp.saveLog("准备下架三乐广告 task :${task}") - val deleteBean = gson.fromJson(task, DeleteSanleAdvertiseBean::class.java) + val deleteBean = + gson.fromJson(task, DeleteSanleAdvertiseBean::class.java) //edit by ljh @2023/8/11 taxiApp.daoAds.clear() //删除在播放的广告 - DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.Ad_id.eq(deleteBean.task_id)).buildDelete().executeDeleteWithoutDetachingEntities() + DaoUtil.getAdvertise().queryBuilder() + .where(AdvertiseDao.Properties.Ad_id.eq(deleteBean.task_id)).buildDelete() + .executeDeleteWithoutDetachingEntities() YoungUtil.YoungLog("删除对应的广告:${deleteBean.task_id}") //查找对应需要删除的广告 - val deleteAdvertise = DaoUtil.getSanleAdvertise().queryBuilder().where(SanleAdvertiseDao.Properties.Task_id.eq(deleteBean.task_id)).build().unique() + val deleteAdvertise = DaoUtil.getSanleAdvertise().queryBuilder() + .where(SanleAdvertiseDao.Properties.Task_id.eq(deleteBean.task_id)).build().unique() + + //删除firstPlay里面对应的三乐广告里面的task_id数据 + DaoUtil.getFirstPlayDao().queryBuilder() + .where(FirstPlayModelDao.Properties.Id.eq(deleteBean.task_id)).buildDelete() + .executeDeleteWithoutDetachingEntities() //删除保留的三乐的广告 if (deleteAdvertise != null) { @@ -1153,7 +1346,7 @@ object ProcessingCommands { //移除广告的定时任务 val tasks = taxiApp.timerTaskMap.get(deleteAdvertise.task_id) tasks?.let { - if (tasks.isNotEmpty()){ + if (tasks.isNotEmpty()) { tasks.forEach { timeTask -> timeTask.cancel() } @@ -1163,14 +1356,16 @@ object ProcessingCommands { //从定时广告列表种移除该广告 if (taxiApp.timedAds.isNotEmpty()) { taxiApp.timedAds.forEach { - if (it.ad_id.equals(deleteAdvertise.task_id)){ + if (it.ad_id.equals(deleteAdvertise.task_id)) { taxiApp.timedAds.remove(it) } } } //删除对应广告分时段Schedule - DaoUtil.getSchedule().queryBuilder().where(ScheduleDao.Properties.AdvertiseId.eq(deleteBean.task_id)).buildDelete().executeDeleteWithoutDetachingEntities() - if (taxiApp.timedAds.size == 0){ + DaoUtil.getSchedule().queryBuilder() + .where(ScheduleDao.Properties.AdvertiseId.eq(deleteBean.task_id)).buildDelete() + .executeDeleteWithoutDetachingEntities() + if (taxiApp.timedAds.size == 0) { Configurations.config(taxiApp.activity).isTimedAdvertiseSave(false) } } @@ -1181,7 +1376,9 @@ object ProcessingCommands { } //删除对应广告的timespan - DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(deleteBean.task_id)).buildDelete().executeDeleteWithoutDetachingEntities() + DaoUtil.getTimeSpan().queryBuilder() + .where(TimeSpanDao.Properties.AdvertiseId.eq(deleteBean.task_id)).buildDelete() + .executeDeleteWithoutDetachingEntities() try { @@ -1207,7 +1404,8 @@ object ProcessingCommands { } //删除旧的Time - DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(old.task_id)).list().forEach { + DaoUtil.getTimeSpan().queryBuilder() + .where(TimeSpanDao.Properties.AdvertiseId.eq(old.task_id)).list().forEach { DaoUtil.getTimeSpan().delete(it) } //添加新的Time @@ -1242,7 +1440,7 @@ object ProcessingCommands { YoungUtil.YoungLog("测试文件是否存在:$pathName ,是否存在 ${File(pathName).exists()}") val file = File(pathName) if (file.exists()) { - YoungUtil.YoungLog("本地存在,停止下载") + YoungUtil.YoungLog("本地存在,停止下载") //todo 如果taskid相同 RefreshPlayer.refresh() } else { @@ -1252,7 +1450,7 @@ object ProcessingCommands { JoeyDownloadManager.getInstance() .setHoldSpace(50 * 1024 * 1024) - .downloadSingle(url, pathName,adId) + .downloadSingle(url, pathName, adId) } } @@ -1275,7 +1473,7 @@ object ProcessingCommands { // KuroDownManager.addDownloadTask(sanleDownloadFactory.getDownloadTask()).addDownloadListener(sanleDownloadFactory) JoeyDownloadManager.getInstance() .setHoldSpace(50 * 1024 * 1024) - .downloadSingleSx(url, pathName,adId) + .downloadSingleSx(url, pathName, adId) } } @@ -1302,7 +1500,7 @@ object ProcessingCommands { if (oldFile.exists()) { oldFile.delete() } - } else if(advertise.mxkl_url != null && newAdvertiseWeb.mxkl_url.isNotEmpty() && newAdvertiseWeb.mxkl_url != oldAdvertiseWeb.mxkl_url){ + } else if (advertise.mxkl_url != null && newAdvertiseWeb.mxkl_url.isNotEmpty() && newAdvertiseWeb.mxkl_url != oldAdvertiseWeb.mxkl_url) { YoungUtil.YoungLog("素材更新,url变化,删除旧文件") val oldFile = File(advertise.pathName) if (oldFile.exists()) { @@ -1313,7 +1511,8 @@ object ProcessingCommands { } //删除旧的Time - DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(advertise.ad_id)).list().forEach { + DaoUtil.getTimeSpan().queryBuilder() + .where(TimeSpanDao.Properties.AdvertiseId.eq(advertise.ad_id)).list().forEach { DaoUtil.getTimeSpan().delete(it) } //添加新的Time @@ -1325,7 +1524,7 @@ object ProcessingCommands { //#edit by ljh 2023/2/7 val tasks = taxiApp.timerTaskMap.get(advertise.ad_id) tasks?.let { - if (tasks.isNotEmpty()){ + if (tasks.isNotEmpty()) { tasks.forEach { timeTask -> timeTask.cancel() } @@ -1335,25 +1534,27 @@ object ProcessingCommands { //从定时广告列表种移除该广告 if (taxiApp.timedAds.isNotEmpty()) { taxiApp.timedAds.forEach { - if (it.ad_id.equals(advertise.ad_id)){ + if (it.ad_id.equals(advertise.ad_id)) { taxiApp.timedAds.remove(it) } } } //删除对应广告分时段Schedule - DaoUtil.getSchedule().queryBuilder().where(ScheduleDao.Properties.AdvertiseId.eq(advertise.ad_id)).buildDelete().executeDeleteWithoutDetachingEntities() - if (taxiApp.timedAds.size == 0){ + DaoUtil.getSchedule().queryBuilder() + .where(ScheduleDao.Properties.AdvertiseId.eq(advertise.ad_id)).buildDelete() + .executeDeleteWithoutDetachingEntities() + if (taxiApp.timedAds.size == 0) { Configurations.config(taxiApp.activity).isTimedAdvertiseSave(false) } } - if (advertise.isTimedAd){ + if (advertise.isTimedAd) { //添加新的Schedule val stringBuilder = java.lang.StringBuilder() newAdvertiseWeb.time_section.forEach { it.advertiseId = newAdvertiseWeb.ad_id it.week_day.forEach { weekDay -> - if (it.week_day.last() != weekDay){ + if (it.week_day.last() != weekDay) { stringBuilder.append("$weekDay,") } else { stringBuilder.append("$weekDay") @@ -1386,8 +1587,13 @@ object ProcessingCommands { /** * 更新定点广告数据 */ - private fun updatePositionAdvertise(oldAdvertiseWeb: PositionAdvertise, newAdvertiseWeb: PositionAdvertise) { - DaoUtil.getRegion().queryBuilder().where(RegionsDao.Properties.RegionAdId.eq(oldAdvertiseWeb.task_id)).buildDelete().executeDeleteWithoutDetachingEntities() + private fun updatePositionAdvertise( + oldAdvertiseWeb: PositionAdvertise, + newAdvertiseWeb: PositionAdvertise + ) { + DaoUtil.getRegion().queryBuilder() + .where(RegionsDao.Properties.RegionAdId.eq(oldAdvertiseWeb.task_id)).buildDelete() + .executeDeleteWithoutDetachingEntities() val advertise: PositionAdvertise? = DaoUtil.getPositionAdvertise().queryBuilder() .where(PositionAdvertiseDao.Properties.Task_id.eq(oldAdvertiseWeb.task_id)).build() .unique() @@ -1397,7 +1603,8 @@ object ProcessingCommands { oldFile.delete() } - DaoUtil.getTimeSpan().queryBuilder().where(TimeSpanDao.Properties.AdvertiseId.eq(advertise.task_id)).list().forEach { + DaoUtil.getTimeSpan().queryBuilder() + .where(TimeSpanDao.Properties.AdvertiseId.eq(advertise.task_id)).list().forEach { DaoUtil.getTimeSpan().delete(it) } @@ -1422,10 +1629,10 @@ object ProcessingCommands { } } - private fun getLogFilesAllName(task: String, type: String):QueryLogFile{ + private fun getLogFilesAllName(task: String, type: String): QueryLogFile { val response = gson.fromJson(task) val file = File(TaxiApp.instance().filesDir, "/log") - if (!file.exists()){ + if (!file.exists()) { file.mkdirs() } val queryLogFile = QueryLogFile() @@ -1434,10 +1641,10 @@ object ProcessingCommands { for (listFile in listFiles) { logFileNames.add(Files(listFile.name)) } - queryLogFile.id =response.id - queryLogFile.task_id =response.task_id - queryLogFile.type =type - queryLogFile.fileList=logFileNames + queryLogFile.id = response.id + queryLogFile.task_id = response.task_id + queryLogFile.type = type + queryLogFile.fileList = logFileNames val queryLogFileJson = Gson().toJson(queryLogFile) YoungUtil.YoungLog("当前存放的log日志:${queryLogFileJson}") diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/WsManager.kt b/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/WsManager.kt index 2ce8365..24b8219 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/WsManager.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/network/WsManager.kt @@ -7,11 +7,13 @@ import android.util.Log import cn.trans88.taxiappkotlin.Configurations import cn.trans88.taxiappkotlin.TaxiApp import cn.trans88.taxiappkotlin.TaxiApp.Companion.HAOSHENG +import cn.trans88.taxiappkotlin.TaxiApp.Companion.LEDOK import cn.trans88.taxiappkotlin.TaxiApp.Companion.MAIDIER import cn.trans88.taxiappkotlin.TaxiApp.Companion.SANLE import cn.trans88.taxiappkotlin.TaxiApp.Companion.XIXUN import cn.trans88.taxiappkotlin.ext.logd import cn.trans88.taxiappkotlin.ext.loge +import cn.trans88.taxiappkotlin.ledok.LedOkActivity import cn.trans88.taxiappkotlin.logic.Repository import cn.trans88.taxiappkotlin.logic.dao.DaoUtil import cn.trans88.taxiappkotlin.logic.model.AdvertiseProcess @@ -35,17 +37,18 @@ object WsManager { private var okHttpClient: OkHttpClient? = null private var mRequest: Request? = null private const val reconnectTime: Long = 3 * 1000 -// private const val reconnectTime: Long = 10 * 1000 + + // private const val reconnectTime: Long = 10 * 1000 // private const val reconnectTime: Long = 30 * 1000 // private const val heartbeatTime: Long = 120 * 1000 private const val heartbeatTime: Long = 30 * 1000 - private const val sendCurrentAdvertiseTime: Long = 10 *60 * 1000 + private const val sendCurrentAdvertiseTime: Long = 10 * 60 * 1000 private val heartbeatContext: String = "beat" - private var beatTimer:KuroTimer?=null - private var wsTimer:KuroTimer?=null - private var tryReconnectTimer:KuroTimer?=null - private var sendCurrentAdvertiseTimer:KuroTimer?=null + private var beatTimer: KuroTimer? = null + private var wsTimer: KuroTimer? = null + private var tryReconnectTimer: KuroTimer? = null + private var sendCurrentAdvertiseTimer: KuroTimer? = null var isReceivePong = false @@ -53,6 +56,7 @@ object WsManager { @Volatile var mWebSocket: WebSocket? = null + @Volatile var isConnected = false @@ -61,13 +65,16 @@ object WsManager { initWebSocket() } + // D 收到了handler msg,what = 10 +// I 回复服务器 beat +// I 发送心跳消息send heartbeat: beat , y08-b23-02080 //edit by ljh @2023/8/16 - val heartHandler = object :Handler(Looper.getMainLooper()){ + val heartHandler = object : Handler(Looper.getMainLooper()) { override fun handleMessage(msg: Message) { if (msg.what != 10) return "收到了handler msg,what = ${msg.what}".logd() - if (isReceivePong){ - val cardId =if (TaxiApp.isTest){ + if (isReceivePong) { + val cardId = if (TaxiApp.isTest) { TaxiApp.testCardid } else { Xixun.getCardId() @@ -91,7 +98,8 @@ object WsManager { fun initWebSocket() { - val testToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiNWY5ZmE0ZTI1NzIzMDkzZGM5MGMwYTA0IiwiZGV2aWNlX2lkIjoieTZjLTMyMi00MDc5NiJ9.j8N1hRwYRq0bKScNe-xB8utsPUAuWEGUJMwCfLcv6D8" + val testToken = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiNWY5ZmE0ZTI1NzIzMDkzZGM5MGMwYTA0IiwiZGV2aWNlX2lkIjoieTZjLTMyMi00MDc5NiJ9.j8N1hRwYRq0bKScNe-xB8utsPUAuWEGUJMwCfLcv6D8" // stopConnect() @@ -99,9 +107,17 @@ object WsManager { .retryOnConnectionFailure(true) //如果没配置,okhttp默认就是true .build() - YoungUtil.YoungLog("长连接进行连接的token:${Configurations.config(TaxiApp.instance()).appToken()}") + YoungUtil.YoungLog( + "长连接进行连接的token:${ + Configurations.config(TaxiApp.instance()).appToken() + }" + ) 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.141:2347/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}") // .url("http://1vf5fnic.beesnat.com/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}") // .url("http://twan718b.beesnat.com/?auth_token=${Configurations.config(TaxiApp.instance()).appToken()}") @@ -193,13 +209,13 @@ object WsManager { // okHttpClient!!.dispatcher.executorService.shutdown() } - private fun startConnect(){ + private fun startConnect() { mRequest?.let { okHttpClient?.newWebSocket(it, getWebSocketListener()) } } - private fun getWebSocketListener():WebSocketListener{ + private fun getWebSocketListener(): WebSocketListener { return object : WebSocketListener() { override fun onClosed(webSocket: WebSocket, code: Int, reason: String) { @@ -275,7 +291,7 @@ object WsManager { } } - private fun stopAllTimer(){ + private fun stopAllTimer() { //停止重连 // tryReconnectTimer?.let { // it.cancel() @@ -321,19 +337,19 @@ object WsManager { mWebSocket?.cancel() val close = mWebSocket!!.close(1000, "连接异常,再次关闭关闭此连接,10s后重连") YoungUtil.YoungLog("webSocket是否正常关闭:$close") - if (!close){ + if (!close) { mWebSocket = null } } wsTimer = KuroTimer() - wsTimer?.schedule(object :KuroTimerTask(){ + wsTimer?.schedule(object : KuroTimerTask() { override fun run() { "wsTimer执行".logd() - if (!isConnected){ + if (!isConnected) { startConnect() } } - },5000) + }, 5000) } catch (e: Throwable) { e.printStackTrace() YoungUtil.YoungLog("重连异常:${e.message}") @@ -354,6 +370,7 @@ object WsManager { fun send(msg: String) { YoungUtil.YoungLog("回复服务器 $msg") + Log.d("WsManager", "回复服务器 $msg") //日志存卡里 // if(!(heartbeatContext.equals(msg))){ // Repository.taxiApp.saveLog("回复服务器 $msg") @@ -369,7 +386,7 @@ object WsManager { Repository.taxiApp.processList.add(process) val json = Repository.taxiApp.gson.toJson(Repository.taxiApp.processList) Configurations.config(Repository.taxiApp).progressListSave(json) - } catch (e:Exception){ + } catch (e: Exception) { "exception:${e?.message}".loge() } } @@ -378,7 +395,7 @@ object WsManager { // mWebSocket?.send(msg) ?: throw IllegalArgumentException("mWebSocket is null not send!") } - fun stopConnect(code:Int,msg:String) { + fun stopConnect(code: Int, msg: String) { // stopAllTimer() wsTimer?.let { it.cancel() @@ -401,9 +418,10 @@ object WsManager { /*定时发送心跳*/ private fun sendBeatData() { - mWebSocket?.send(heartbeatContext) ?: throw IllegalArgumentException("mWebSocket is null not send!") + mWebSocket?.send(heartbeatContext) + ?: throw IllegalArgumentException("mWebSocket is null not send!") - val cardId =if (TaxiApp.isTest){ + val cardId = if (TaxiApp.isTest) { TaxiApp.testCardid } else { Xixun.getCardId() @@ -430,17 +448,17 @@ object WsManager { sendBeatData() } - },heartbeatTime) + }, heartbeatTime) // timer.schedule(heartbeatTask, 0, heartbeatTime) } /** * 定时查询卡内广告发送给服务器 */ - private fun sendCurrentAdvertise(){ + private fun sendCurrentAdvertise() { val order = DaoUtil.getOrderDao().loadAll() // val advertises = DaoUtil.getAdvertises() - var advertiseIdList = mutableListOf() + var advertiseIdList = mutableListOf() order.forEach { advertiseIdList.add(it.ad_id) } @@ -451,8 +469,9 @@ object WsManager { val currentAdvertises = Gson().toJson(currentPlayAdvertise) YoungUtil.YoungLog("当前在播放的广告: $currentAdvertises") - if(isConnected){ - mWebSocket?.send(currentAdvertises) ?: throw IllegalArgumentException("mWebSocket is null not send!") + if (isConnected) { + mWebSocket?.send(currentAdvertises) + ?: throw IllegalArgumentException("mWebSocket is null not send!") } sendCurrentAdvertiseTimer?.let { @@ -472,7 +491,7 @@ object WsManager { sendCurrentAdvertise() } - },sendCurrentAdvertiseTime) + }, sendCurrentAdvertiseTime) } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/logic/task/SyncTimerTask.kt b/app/src/main/java/cn/trans88/taxiappkotlin/logic/task/SyncTimerTask.kt index 12824a5..a21c9ec 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/logic/task/SyncTimerTask.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/logic/task/SyncTimerTask.kt @@ -1,5 +1,9 @@ package cn.trans88.taxiappkotlin.logic.task + +import android.content.Context import cn.trans88.taxiappkotlin.TaxiApp +import cn.trans88.taxiappkotlin.TaxiApp.Companion.instance +import cn.trans88.taxiappkotlin.ledok.LedOkActivity import cn.trans88.taxiappkotlin.logic.Repository import cn.trans88.taxiappkotlin.logic.model.Advertise import cn.trans88.taxiappkotlin.play.RefreshPlayer @@ -9,7 +13,11 @@ import cn.trans88.taxiappkotlin.util.YoungUtil //import com.trs88.kurolibrary.log.KuroLog import java.util.* -class SyncTimerTask(private val playViewModel: PlayViewModel, val advertise:Advertise?,private val currentPosition:Int):KuroTimerTask() { +class SyncTimerTask( + private val playViewModel: PlayViewModel, + val advertise: Advertise?, + private val currentPosition: Int +) : KuroTimerTask() { override fun run() { synchronized(this) { YoungUtil.YoungLog("同步任务开始") @@ -18,7 +26,6 @@ class SyncTimerTask(private val playViewModel: PlayViewModel, val advertise:Adve Repository.currentListOrder = currentPosition //刷新播放广告 playViewModel.refreshAdvertise() - } } } \ No newline at end of file diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/net/EasyHttpTool.kt b/app/src/main/java/cn/trans88/taxiappkotlin/net/EasyHttpTool.kt index 45a1a6d..e869ba2 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/net/EasyHttpTool.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/net/EasyHttpTool.kt @@ -1,26 +1,25 @@ package cn.trans88.taxiappkotlin.net +import android.util.Log import cn.trans88.taxiappkotlin.Configurations +import cn.trans88.taxiappkotlin.NetworkChangeReceiver import cn.trans88.taxiappkotlin.TaxiApp import cn.trans88.taxiappkotlin.ext.logd import cn.trans88.taxiappkotlin.ext.loge -import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao import cn.trans88.taxiappkotlin.logic.dao.DaoUtil import cn.trans88.taxiappkotlin.logic.dao.RunTimeDataDao import cn.trans88.taxiappkotlin.logic.model.PlayLogger import cn.trans88.taxiappkotlin.logic.model.RunTimeData import cn.trans88.taxiappkotlin.logic.model.RuntimeJson import cn.trans88.taxiappkotlin.logic.network.ProcessingCommands -import cn.trans88.taxiappkotlin.ui.advertise.AdvertiseType import com.google.gson.Gson -import com.google.gson.reflect.TypeToken import com.zhouyou.http.EasyHttp import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.RequestBody import com.zhouyou.http.callback.SimpleCallBack import com.zhouyou.http.exception.ApiException import okhttp3.Request -import java.util.stream.Collectors +import java.util.concurrent.CountDownLatch /** @@ -35,38 +34,87 @@ object EasyHttpTool { * 提交运行时长 * @param runtimeJson String */ - fun sendRunTimeToServer(runtimeJson: String){ + lateinit var latch: CountDownLatch + var isSendSuccess = false + fun sendRunTimeToServer(runtimeJson: String) { "sendRunTimeToServer run".logd() + latch = CountDownLatch(1) + sendRuntimeToServerRequest(runtimeJson) + Thread { + latch.await() + var count = 10 + // 网络可用时每一分钟发一次请求 + while (!isSendSuccess && count > 0) { + latch = CountDownLatch(1) + sendRuntimeToServerRequest(runtimeJson) + Log.d("EasyHttpTool", "sendRunTimeToServer: 重发次数${count}") + latch.await() + count--; + Thread.sleep(1000 * 60) + } + // 网络不可用时监听网络状态是否发送请求 + if (!isSendSuccess) { + var isRunning = true + while (isRunning) { + val networkAvailable = NetworkChangeReceiver.isNetworkAvailable + if (networkAvailable) { + latch = CountDownLatch(1) + sendRuntimeToServerRequest(runtimeJson) + Log.d("EasyHttpTool", "sendRunTimeToServer: 重发网络${networkAvailable}") + latch.await() + if (isSendSuccess) { + isRunning = false + } + } + Thread.sleep(1000 * 60) + } + } + }.start() + } + + fun sendRuntimeToServerRequest(runtimeJson: String) { + Log.d("EasyHttpTool", "sendRuntimeToServerRequest: ") val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull() val body = RequestBody.create(parse, runtimeJson) - EasyHttp.post(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postRunningTimeLog") - .readTimeOut(80*1000) - .writeTimeOut(80*1000) - .connectTimeout(80*1000) - .headers("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}") + EasyHttp.post( + Configurations.config(TaxiApp.instance()).logServiceUrl() + "postRunningTimeLog" + ) + .readTimeOut(80 * 1000) + .writeTimeOut(80 * 1000) + .connectTimeout(80 * 1000) + .headers( + "Authorization", + "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}" + ) .headers("Accept-Encoding", "gzip") .requestBody(body) .retryCount(5)//本次请求重试次数 .retryDelay(600)//本次请求重试延迟时间600ms - .execute(object :SimpleCallBack(){ + .execute(object : SimpleCallBack() { override fun onError(e: ApiException?) { "上传运行时长失败:${e?.message}".loge() + isSendSuccess = false + latch.countDown() } override fun onSuccess(t: String?) { "上传运行时长成功:${t}".loge() + isSendSuccess = true + latch.countDown() } }) } + /** * 提交运行时长 */ - fun sendRunTimeToServer(){ + fun sendRunTimeToServer() { val sumTimeList = DaoUtil.getRunTimeDao().queryBuilder().where( - RunTimeDataDao.Properties.IsUpload.eq(0)).list() + RunTimeDataDao.Properties.IsUpload.eq(0) + ).list() "未提交的运行时长数量sumTimeList size: ${sumTimeList?.size}".logd() - if (!sumTimeList.isNullOrEmpty()){ + if (!sumTimeList.isNullOrEmpty()) { for (runTimeData in sumTimeList) { @@ -115,10 +163,11 @@ object EasyHttpTool { /** * 上传1条运行日志 */ - fun sendRunLogToServer(runTimeData:RunTimeData){ + fun sendRunLogToServer(runTimeData: RunTimeData) { // val logJson = ProcessingCommands.gson.toJson(dbPlayerLogs) - val runtimeJson = RuntimeJson(runTimeData.cardId,runTimeData.sumRuntime,runTimeData.startRuntime) - val runtimeJsonStr = Gson().toJson(runtimeJson) + val runtimeJson = + RuntimeJson(runTimeData.cardId, runTimeData.sumRuntime, runTimeData.startRuntime) + val runtimeJsonStr = Gson().toJson(runtimeJson) "提交运行时长sendRunTimeToServer:$runtimeJsonStr".logd() val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull() val body = RequestBody.create(parse, runtimeJsonStr) @@ -127,14 +176,17 @@ object EasyHttpTool { try { val request = Request.Builder() .url(url) - .addHeader("Authorization","Bearer ${Configurations.config(TaxiApp.instance()).appToken()}") - .addHeader("Accept-Encoding","gzip") + .addHeader( + "Authorization", + "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}" + ) + .addHeader("Accept-Encoding", "gzip") .post(body) .build() val response = OkHttpTool.getInstance().client.newCall(request).execute() "response code:${response?.code}".logd() "response body:${response?.body?.string().toString()}".logd() - if (response.isSuccessful){ + if (response.isSuccessful) { "上传运行时长成功".loge() runTimeData.isUpload = 1 DaoUtil.getRunTimeDao().update(runTimeData) @@ -153,20 +205,25 @@ object EasyHttpTool { * 提交日志摘要 * @param gpsJson String */ - fun sendPlayLogToServer(logJson: String){ + fun sendPlayLogToServer(logJson: String) { "提交日志摘要 $logJson".logd() val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull() val body = RequestBody.create(parse, logJson) - EasyHttp.post(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postPlayerLogPlus") - .readTimeOut(80*1000) - .writeTimeOut(80*1000) - .connectTimeout(80*1000) - .headers("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}") + EasyHttp.post( + Configurations.config(TaxiApp.instance()).logServiceUrl() + "postPlayerLogPlus" + ) + .readTimeOut(80 * 1000) + .writeTimeOut(80 * 1000) + .connectTimeout(80 * 1000) + .headers( + "Authorization", + "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}" + ) .headers("Accept-Encoding", "gzip") .requestBody(body) .retryCount(5) //本次请求重试次数 .retryDelay(600) //本次请求重试延迟时间600ms - .execute(object :SimpleCallBack(){ + .execute(object : SimpleCallBack() { override fun onError(e: ApiException?) { "上传日志摘要失败:${e?.message}".loge() } @@ -182,20 +239,25 @@ object EasyHttpTool { * 提交GPS数据 * @param gpsJson String */ - fun sendGPSToServer(gpsJson: String){ + fun sendGPSToServer(gpsJson: String) { "提交GPS数据 $gpsJson".logd() val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull() val body = RequestBody.create(parse, gpsJson) - EasyHttp.post(Configurations.config(TaxiApp.instance()).logServiceUrl() + "postGpsLocationLog") - .readTimeOut(80*1000) - .writeTimeOut(80*1000) - .connectTimeout(80*1000) - .headers("Authorization", "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}") + EasyHttp.post( + Configurations.config(TaxiApp.instance()).logServiceUrl() + "postGpsLocationLog" + ) + .readTimeOut(80 * 1000) + .writeTimeOut(80 * 1000) + .connectTimeout(80 * 1000) + .headers( + "Authorization", + "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}" + ) .requestBody(body) .retryCount(5) //本次请求重试次数 .retryDelay(600) //本次请求重试延迟时间600ms .syncRequest(true)//设置同步请求 - .execute(object :SimpleCallBack(){ + .execute(object : SimpleCallBack() { override fun onError(e: ApiException?) { "上传GPS数据失败:${e?.message}".loge() } @@ -209,7 +271,7 @@ object EasyHttpTool { /** * 上传100条播放日志 */ - fun sendPlayLogToServer(dbPlayerLogs:List){ + fun sendPlayLogToServer(dbPlayerLogs: List) { val logJson = ProcessingCommands.gson.toJson(dbPlayerLogs) "提交日志Json $logJson".logd() val parse = ("application/json;charset=UTF-8").toMediaTypeOrNull() @@ -219,24 +281,27 @@ object EasyHttpTool { try { val request = Request.Builder() .url(url) - .addHeader("Authorization","Bearer ${Configurations.config(TaxiApp.instance()).appToken()}") - .addHeader("Accept-Encoding","gzip") + .addHeader( + "Authorization", + "Bearer ${Configurations.config(TaxiApp.instance()).appToken()}" + ) + .addHeader("Accept-Encoding", "gzip") .post(body) .build() val response = OkHttpTool.getInstance().client.newCall(request).execute() "response code:${response?.code}".logd() "response body:${response?.body?.string().toString()}".logd() - if (response.isSuccessful){ + if (response.isSuccessful) { "上传日志成功 ".logd() DaoUtil.getPlayLogger().deleteInTx(dbPlayerLogs) "删除日志成功".logd() } else { "上传日志失败".loge() - Thread.sleep(60*1000L) + Thread.sleep(60 * 1000L) } } catch (e: Exception) { "提交失败Exception:${e.message}".loge() - Thread.sleep(60*1000L) + Thread.sleep(60 * 1000L) } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayActivity.kt b/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayActivity.kt index 7591dc3..0575bf6 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayActivity.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayActivity.kt @@ -7,14 +7,12 @@ import android.net.wifi.WifiManager import android.os.* import android.os.Build.VERSION import android.os.Build.VERSION_CODES +import android.util.Log import android.view.View import android.view.WindowManager -import android.widget.ImageView import android.widget.ImageView.ScaleType.FIT_XY import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity -import androidx.core.view.children -import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import cn.trans88.taxiappkotlin.BootBroadcast import cn.trans88.taxiappkotlin.Configurations @@ -23,9 +21,16 @@ import cn.trans88.taxiappkotlin.R.string import cn.trans88.taxiappkotlin.TaxiApp import cn.trans88.taxiappkotlin.TaxiApp.Companion.HAOSHENG import cn.trans88.taxiappkotlin.TaxiApp.Companion.MAIDIER +import cn.trans88.taxiappkotlin.TaxiApp.Companion.instance import cn.trans88.taxiappkotlin.ext.logd import cn.trans88.taxiappkotlin.ext.loge import cn.trans88.taxiappkotlin.jetpack.PlayViewModelFactory +import cn.trans88.taxiappkotlin.ledok.LedOkActivity +import cn.trans88.taxiappkotlin.ledok.LedOkAdvertise +import cn.trans88.taxiappkotlin.ledok.LedOkCommands +import cn.trans88.taxiappkotlin.ledok.LedOkCommands.PLAYLIST +import cn.trans88.taxiappkotlin.ledok.LedOkCommands.playlist +import cn.trans88.taxiappkotlin.ledok.TaskSocketServer import cn.trans88.taxiappkotlin.logic.Repository import cn.trans88.taxiappkotlin.logic.Repository.powerOnAdvertise import cn.trans88.taxiappkotlin.logic.dao.DaoUtil @@ -56,9 +61,11 @@ import com.permissionx.guolindev.PermissionX import com.trs88.kurolibrary.execute.KuroExecutor import com.trs88.kurolibrary.util.MainHandler import com.xixun.xy.conn.aidl.ConnService -import com.zhouyou.http.EasyHttp import kotlinx.android.synthetic.main.activity_main.* +import java.io.BufferedReader import java.io.File +import java.io.FileReader +import java.io.IOException import java.lang.ref.WeakReference import java.util.* import kotlin.concurrent.thread @@ -66,6 +73,7 @@ import kotlin.concurrent.thread //未校时或没网时卡的初始时间存在为1970年的情况, // 时间至少大于1970-10-02 00:21:26才有可能已经校时完成 const val NOVALIDTIME = 23646086L + class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreenSizeListener { val CREATE_VIEW_MSG = 11111111 @@ -74,6 +82,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) + private lateinit var socketServer: TaskSocketServer private val netBroadcastReceiver = NetworkReceiver()//网络状态Receiver private val busReceiver = BusReceiver()//豪胜公交Receiver private val gpsReceiver = GpsReceiver()//Gps信息Receiver @@ -82,9 +91,9 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen private lateinit var playViewModel: PlayViewModel - private var saveRuntimeTimer:Timer? = null - private var startSaveRunTimer:Timer? = null - private var sumTimeTimer:Timer? = null + private var saveRuntimeTimer: Timer? = null + private var startSaveRunTimer: Timer? = null + private var sumTimeTimer: Timer? = null val handler = MyHandler(this) @@ -112,7 +121,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen //测试 // Advertise().toString().loge() - + setContentView(R.layout.activity_main) configurations = Configurations.config(this) @@ -129,7 +138,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen taxiApp.activity = this val isFirstInstalled = Configurations.config(this).isFirstInstalled - if (isFirstInstalled){ + if (isFirstInstalled) { //升级后关闭日志 Configurations.config(this).gpsSwitchSave(false) Configurations.config(this).loggerSwitchSave(false) @@ -162,7 +171,10 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen // requestLocationAndContacts() //通过ViewModelProvider拿到viewModel实例 viewModel的生命周期要长于activity - playViewModel = ViewModelProvider(this, PlayViewModelFactory(lifecycle, fl_play, img_bus_top)).get(PlayViewModel::class.java) + playViewModel = + ViewModelProvider(this, PlayViewModelFactory(lifecycle, fl_play, img_bus_top)).get( + PlayViewModel::class.java + ) playViewModel.playLogo() @@ -194,27 +206,43 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen playViewModel.initLocation() playViewModel.apply { - if (mLocationManager == null || currentLocation == null || !isLocationEnabled){ + if (mLocationManager == null || currentLocation == null || !isLocationEnabled) { clearAreaAdvertise() } mLocationManager?.removeUpdates(getLocationListener()) } - },30 * 1000) + }, 30 * 1000) saveStartTimeThread() // testLocation() + //zl + playViewModel = ViewModelProvider(this).get(PlayViewModel::class.java) + ConnManger.setPlayViewModel(playViewModel) // 设置 ViewModel + + + Thread { + socketServer = TaskSocketServer(this, 3338) + socketServer.listen() + }.start() + + //TODO + if (LedOkActivity.isPersistPlay()) { + LedOkCommands.startLedOkActivity() + } } - fun saveStartTimeThread(){ + + //重启后,因为可能需要更新日期的总运行时长还有开机一次的运行时长,所以都需要判断 + fun saveStartTimeThread() { thread { while (true) { - var cacheStartTime:Long = configurations.startRunTime() + var cacheStartTime: Long = configurations.startRunTime() var currentTime = System.currentTimeMillis() "saveStartTimeThread ---> 当前系统时间:currentTime:$currentTime".loge() "saveStartTimeThread ---> 上一次的启动时间:cacheStartTime:$cacheStartTime".loge() if (currentTime > NOVALIDTIME && currentTime > cacheStartTime) { //如果上一次启动时间和当前时间相比是第二天,重置当天的总运行时长,todaySunRuntime - var dayType = DateUtil.getDaysDiff(currentTime,cacheStartTime) - if (dayType != DayType.IS_SAME_DAY.ordinal){ + var dayType = DateUtil.getDaysDiff(currentTime, cacheStartTime) + if (dayType != DayType.IS_SAME_DAY.ordinal) { "第二天了,重置当天的运行时长".logd() configurations.todaySumRunTimeSave(0) } @@ -226,7 +254,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen val cacheSumTime = configurations.sumRunTime() "cacheSumTime ---> 上一次的运行时长:cacheSumTime:$cacheSumTime".loge() - if (cacheSumTime > 0 && cacheStartTime > NOVALIDTIME){ + if (cacheSumTime > 0 && cacheStartTime > NOVALIDTIME) { val cardId = configurations.cardId() val runTimeData = RunTimeData() runTimeData.cardId = cardId @@ -237,7 +265,6 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen } - //重新初始化startRunTime为当前启动时间,sumRuntime为0 configurations.startRunTimeSave(currentTime) configurations.sumRunTimeSave(0) @@ -251,8 +278,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen } else { "系统时间尚未校时,80s后重新获取系统时间".loge() try { - Thread.sleep(80*1000) - } catch (e:Exception) { + Thread.sleep(80 * 1000) + } catch (e: Exception) { e.printStackTrace() } } @@ -264,12 +291,12 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen /** * 保存开始运行时间 */ - fun saveStartTime(){ - var cacheStartTime:Long = configurations.startRunTime() + fun saveStartTime() { + var cacheStartTime: Long = configurations.startRunTime() var currentTime = System.currentTimeMillis() "saveStartTime ---> currentTime:$currentTime".loge() - if (currentTime > NOVALIDTIME && currentTime > cacheStartTime){ + if (currentTime > NOVALIDTIME && currentTime > cacheStartTime) { startSaveRunTimer?.let { it.purge() @@ -277,8 +304,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen } startSaveRunTimer = null - var dayType = DateUtil.getDaysDiff(currentTime,cacheStartTime) - when(dayType){ + var dayType = DateUtil.getDaysDiff(currentTime, cacheStartTime) + when (dayType) { DayType.IS_OTHER_DAY.ordinal -> { //如果缓存的启动时间是三天前(或更久)了,或者为零,直接覆盖 configurations.logSummaryJsonStringSave("") Thread(Runnable { clearOverdueLogger() }).start() @@ -292,6 +319,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen configurations.runtimeJsonStringSave("") startRuntimeTimer() } + DayType.IS_SAME_DAY.ordinal -> {//同一天重启 isSendedLog = false @@ -332,6 +360,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen configurations.endRunTimeSave(currentTime) startRuntimeTimer() } + DayType.IS_SECOND_DAY.ordinal -> { // ConnManger.sendLogsSummary() sendLogInterval() @@ -346,7 +375,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen "程序启动,昨天运行时间(毫秒):${yesterdaySumTime}".loge() //提交昨天一整天的运行时间 val firstRuntime = configurations.firstRunTime() - val runtimeJson = RuntimeJson(configurations.cardId(),yesterdaySumTime,firstRuntime) + val runtimeJson = + RuntimeJson(configurations.cardId(), yesterdaySumTime, firstRuntime) // configurations.runtimeJsonStringSave(Gson().toJson(runtimeJson)) //edit by ljh on 2024/2/28 //优化上传运行时长方式 @@ -359,6 +389,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen configurations.sumRunTimeSave(0) startRuntimeTimer() } + else -> { configurations.startRunTimeSave(currentTime) configurations.endRunTimeSave(currentTime) @@ -368,13 +399,13 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen } } } else { - if (startSaveRunTimer == null){ + if (startSaveRunTimer == null) { startSaveRunTimer = Timer() - startSaveRunTimer?.schedule(object :TimerTask(){ + startSaveRunTimer?.schedule(object : TimerTask() { override fun run() { saveStartTime() } - },30*1000L,30*1000L) + }, 30 * 1000L, 30 * 1000L) } } } @@ -382,10 +413,10 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen /** * 定时传日志摘要 */ - private fun sendLogInterval(){ + private fun sendLogInterval() { val logInterval = configurations.logInterval() "logInterval:$logInterval".logd() - if (logInterval > 0){ + if (logInterval > 0) { // ConnManger.sendLogSummaryByInterval(logInterval) } } @@ -394,20 +425,20 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen /** * 启动计算运行时长的计时器 */ - private fun startSaveSumTimer(){ + private fun startSaveSumTimer() { sumTimeTimer?.purge() sumTimeTimer?.cancel() sumTimeTimer = Timer() "计算运行时长的计时器启动".logd() - sumTimeTimer?.schedule(object : TimerTask(){ + sumTimeTimer?.schedule(object : TimerTask() { override fun run() { val startRuntime = configurations.startRunTime() val currentTime = System.currentTimeMillis() - val currentType = DateUtil.getDaysDiff(currentTime,startRuntime) + val currentType = DateUtil.getDaysDiff(currentTime, startRuntime) var cacheSumRunTime = configurations.sumRunTime() var cacheTodaySumRunTime = configurations.todaySumRunTime() - if (currentType == DayType.IS_SECOND_DAY.ordinal){ + if (currentType == DayType.IS_SECOND_DAY.ordinal) { "当前时间已经是第二天了,记录一次".logd() val cardId = configurations.cardId() val rumTimeData = RunTimeData() @@ -427,29 +458,29 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen //每30s累加一次 "当前运行时长cacheSumRunTime:${cacheSumRunTime},累加30s".logd() - configurations.sumRunTimeSave(cacheSumRunTime+30*1000L) - configurations.todaySumRunTimeSave(cacheTodaySumRunTime+30*1000L) + configurations.sumRunTimeSave(cacheSumRunTime + 30 * 1000L) + configurations.todaySumRunTimeSave(cacheTodaySumRunTime + 30 * 1000L) } - },30*1000L,30*1000L) + }, 30 * 1000L, 30 * 1000L) } /** * 启动计算运行时长的计时器 */ - private fun startRuntimeTimer(){ + private fun startRuntimeTimer() { "startRuntimeTimer()".loge() saveRuntimeTimer?.purge() saveRuntimeTimer?.cancel() - if (saveRuntimeTimer == null){ + if (saveRuntimeTimer == null) { saveRuntimeTimer = Timer() - saveRuntimeTimer?.schedule(object : TimerTask(){ + saveRuntimeTimer?.schedule(object : TimerTask() { override fun run() { val endRuntime = configurations.endRunTime() val startRuntime = configurations.startRunTime() val currentTime = System.currentTimeMillis() "RuntimeTimer --> currentEndRuntime:$endRuntime".loge() - val type = DateUtil.getDaysDiff(endRuntime,startRuntime) - val currentType = DateUtil.getDaysDiff(currentTime,startRuntime) + val type = DateUtil.getDaysDiff(endRuntime, startRuntime) + val currentType = DateUtil.getDaysDiff(currentTime, startRuntime) val isSecond = DayType.IS_SECOND_DAY.ordinal == currentType // if (isSecond && Repository.taxiApp.sendLogTimes == 0) { // //当前时间被手动设置成第二天了,提交一次运行时长数据 @@ -475,7 +506,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen val yesterdayRuntime = configurations.sumRunTime() + lastRunTime //提交昨天一整天的运行时间 val firstRuntime = configurations.firstRunTime() - val runtimeJson = RuntimeJson(configurations.cardId(),yesterdayRuntime,firstRuntime) + val runtimeJson = + RuntimeJson(configurations.cardId(), yesterdayRuntime, firstRuntime) // configurations.runtimeJsonStringSave(Gson().toJson(runtimeJson)) // ConnManger.sendRuntimeToWeb() //edit by ljh on 2024/2/28 @@ -486,23 +518,23 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen configurations.sumRunTimeSave(0) } - configurations.endRunTimeSave(endRuntime+30*1000L) + configurations.endRunTimeSave(endRuntime + 30 * 1000L) } - },30*1000L,30*1000L) + }, 30 * 1000L, 30 * 1000L) } } //#edit by ljh 2023/2/16 - fun getViewModel():PlayViewModel{ + fun getViewModel(): PlayViewModel { return playViewModel } var testcount = 60 - fun testLocation(){ - Timer().schedule(object : TimerTask(){ + fun testLocation() { + Timer().schedule(object : TimerTask() { override fun run() { testcount-- - if (testcount>=0){ + if (testcount >= 0) { val location = Location().apply { timestamp = System.currentTimeMillis() setLongitude(1.0) @@ -516,7 +548,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen "存储了假数据:testcount:$testcount,${location.toString()}".logd() } } - },0,5000) + }, 0, 5000) } private fun bindConnService() { @@ -566,7 +598,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen val lp: WindowManager.LayoutParams = this.window.attributes - lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES + lp.layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES this.window.attributes = lp val decorView = window.decorView @@ -588,7 +621,9 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen val currentTimeMillis = System.currentTimeMillis() val overdueTime = currentTimeMillis - 30 * 24 * 60 * 60 * 1000 //lt < gt > ge >= le <= - DaoUtil.getPlayLoggerDao().queryBuilder().where(PlayLoggerDao.Properties.Created_at.lt(overdueTime)).buildDelete().executeDeleteWithoutDetachingEntities() + DaoUtil.getPlayLoggerDao().queryBuilder() + .where(PlayLoggerDao.Properties.Created_at.lt(overdueTime)).buildDelete() + .executeDeleteWithoutDetachingEntities() "清除日志后,当前日志数量:${DaoUtil.getPlayLoggers().size}".logd() } @@ -621,13 +656,20 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen HAOSHENG -> { ll_bus.visibility = View.VISIBLE val busLayoutParams = ll_bus.layoutParams - YoungUtil.YoungLog("豪胜公交屏幕customView 宽:${Configurations.config(TaxiApp.instance()).screenSizeX()} ,高:${ Configurations.config(TaxiApp.instance()).screenSizeY()}") + YoungUtil.YoungLog( + "豪胜公交屏幕customView 宽:${ + Configurations.config(TaxiApp.instance()).screenSizeX() + } ,高:${Configurations.config(TaxiApp.instance()).screenSizeY()}" + ) busLayoutParams.width = Configurations.config(TaxiApp.instance()).screenSizeX() / 7 busLayoutParams.height = Configurations.config(TaxiApp.instance()).screenSizeY() img_bus_top.visibility = View.VISIBLE - 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, "busLicence") if (dest.exists()) { Glide.with(this) @@ -658,7 +700,10 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen imgOtherScreen.width = 128 imgOtherScreen.height = 64 - 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, "no_service") glideToMdr(R.mipmap.no_service, dest) @@ -672,9 +717,9 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen /** * 取消自定义显示,路线、左转右转等.. */ - fun cancelCustomView(){ + fun cancelCustomView() { YoungUtil.YoungLog("取消自定义显示,路线、左转右转等..") - runOnUiThread{ + runOnUiThread { ll_bus.visibility = View.GONE img_other_screen.visibility = View.GONE } @@ -688,7 +733,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen } } - val program = File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program)) + val program = + File(TaxiApp.instance().filesDir, TaxiApp.instance().getString(R.string.dir_program)) val logo = File(program, "logo") val logoTemp = File(program, "logo.temp") @@ -804,7 +850,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen */ fun timeRefreshAdvertise() { YoungUtil.YoungLog("定时刷新广告") - if (Repository.getTestPlayLevels() != AdvertiseType.AREA.ordinal){ + if (Repository.getTestPlayLevels() != AdvertiseType.AREA.ordinal) { RefreshPlayer.refresh() } @@ -830,10 +876,11 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen } override fun onDestroy() { + socketServer.destroy() TaxiApp.isActive = false; YoungUtil.YoungLog("onDestroy") val intent = Intent(this, PlayServer::class.java) - WsManager.stopConnect(1005,"程序关闭,关闭连接") + WsManager.stopConnect(1005, "程序关闭,关闭连接") //取消注册liveData playViewModel.playLiveData.removeObservers(this) unregisterReceiver(netBroadcastReceiver) @@ -911,7 +958,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen busLayoutParams.width = Configurations.config(TaxiApp.instance()).screenSizeX() / 7 busLayoutParams.height = Configurations.config(TaxiApp.instance()).screenSizeY() - 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, "busLicence") if (dest.exists()) { @@ -935,7 +983,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen override fun turnLeft() { YoungUtil.YoungLog("bus信号 左转") ll_bus.visibility = View.VISIBLE - 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, "turnLeft") glideToSignal(R.mipmap.turn_left, dest) @@ -944,7 +993,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen override fun turnRight() { YoungUtil.YoungLog("bus信号 右转") ll_bus.visibility = View.VISIBLE - 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, "turnRight") glideToSignal(R.mipmap.turn_right, dest) } @@ -953,28 +1003,32 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen YoungUtil.YoungLog("bus信号 刹车") ll_bus.visibility = View.VISIBLE - 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, "turnStop") glideToSignal(R.mipmap.turn_stop, dest) } override fun vacant() { YoungUtil.YoungLog("麦迪尔:vacant") - 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, "vacant") glideToMdr(R.mipmap.vacant, dest) } override fun hired() { YoungUtil.YoungLog("麦迪尔:hired") - 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, "hired") glideToMdr(R.mipmap.hired, dest) } override fun booked() { YoungUtil.YoungLog("麦迪尔:booked") - 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, "booked") if (dest.exists()) { @@ -1007,7 +1061,8 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen // img_other_screen.layoutParams =imgOtherScreen - 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, "no_service") glideToMdr(R.mipmap.no_service, dest) } diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayView.kt b/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayView.kt index 2c57a12..9b21e67 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayView.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayView.kt @@ -94,7 +94,8 @@ fun View.createView(context: Context, advertise: Advertise, seek: Int): View? { val video: View YoungUtil.YoungLog("素材是视频:${Configurations.config(TaxiApp.instance()).downloadUrl()}${advertise.media_url}") -//exoPlayer + +// exoPlayer // if (Build.VERSION.SDK_INT != 23){ // val taxiApp = TaxiApp.instance() as TaxiApp // taxiApp.player!!.clearMediaItems() @@ -164,6 +165,7 @@ fun View.createView(context: Context, advertise: Advertise, seek: Int): View? { YoungUtil.YoungLog("视频准备完成,当前线程${Looper.getMainLooper().thread === Thread.currentThread()}") YoungUtil.YoungLog("视频的播放时长${jVideoView.duration}") try { + YoungUtil.YoungLog("视频开始播放") mediaPlayer.start() } catch (e:Exception){ "播放异常:${e.printStackTrace()}".loge() diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayViewModel.kt b/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayViewModel.kt index a73a757..5c89d9a 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayViewModel.kt +++ b/app/src/main/java/cn/trans88/taxiappkotlin/ui/play/PlayViewModel.kt @@ -13,13 +13,11 @@ import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.Color import android.location.Criteria -import android.location.Location.distanceBetween import android.location.LocationListener import android.location.LocationManager import android.media.MediaMetadataRetriever import android.os.Bundle import android.os.Handler -import android.os.Looper import android.util.Log import android.view.View import android.view.ViewGroup @@ -27,9 +25,7 @@ import android.view.animation.Animation import android.view.animation.AnimationUtils import android.widget.FrameLayout import android.widget.ImageView -import android.widget.Toast import androidx.core.app.ActivityCompat -import androidx.core.view.children import androidx.core.view.get import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleObserver @@ -46,6 +42,7 @@ import cn.trans88.taxiappkotlin.TaxiApp.Companion.XIXUN import cn.trans88.taxiappkotlin.ext.logd import cn.trans88.taxiappkotlin.ext.loge import cn.trans88.taxiappkotlin.ext.logi +import cn.trans88.taxiappkotlin.ledok.LedOkActivity import cn.trans88.taxiappkotlin.logic.Repository import cn.trans88.taxiappkotlin.logic.Repository.updatePlayerUI import cn.trans88.taxiappkotlin.logic.dao.AdvertiseDao @@ -56,8 +53,12 @@ import cn.trans88.taxiappkotlin.logic.dao.PositionAdvertiseDao import cn.trans88.taxiappkotlin.logic.dao.RegionsDao import cn.trans88.taxiappkotlin.logic.gps.GpsInformationListener import cn.trans88.taxiappkotlin.logic.gps.GpsReceiver -import cn.trans88.taxiappkotlin.logic.model.* -import cn.trans88.taxiappkotlin.logic.myListMap +import cn.trans88.taxiappkotlin.logic.model.Advertise +import cn.trans88.taxiappkotlin.logic.model.Container +import cn.trans88.taxiappkotlin.logic.model.Location +import cn.trans88.taxiappkotlin.logic.model.PlayLogger +import cn.trans88.taxiappkotlin.logic.model.PositionAdvertise +import cn.trans88.taxiappkotlin.logic.model.Regions import cn.trans88.taxiappkotlin.logic.network.ConnManger import cn.trans88.taxiappkotlin.logic.network.JoeyDownloadManager import cn.trans88.taxiappkotlin.logic.network.ProcessingCommands @@ -66,14 +67,14 @@ import cn.trans88.taxiappkotlin.play.RefreshPlayer import cn.trans88.taxiappkotlin.ui.advertise.AdvertiseType import cn.trans88.taxiappkotlin.ui.advertise.AdvertiseType.AREA import cn.trans88.taxiappkotlin.ui.advertise.MaterialType -import cn.trans88.taxiappkotlin.ui.custom.JVideoView import cn.trans88.taxiappkotlin.util.DateUtil import cn.trans88.taxiappkotlin.util.YoungUtil -import kotlinx.android.synthetic.main.activity_main.* -import org.greenrobot.greendao.query.LazyList import java.io.ByteArrayOutputStream import java.io.File -import java.util.* +import java.util.Calendar +import java.util.Date +import java.util.Timer +import java.util.TimerTask /** @@ -83,13 +84,20 @@ import java.util.* //todo 这里不应该持有ui,应该要建立对应的livedata去回调给ui //如果是第二天,但是第一天日志没传完,就设为true var isSendedLog: Boolean = true + //从缓存获取次数达到8888次后,从数据库获取一次数据,并更新缓存 const val MAX_CACHE: Int = 8888 + // 跳跃点的距离阈值,单位为米 const val JUMP_THRESHOLD = 10000.0f -class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, private val imageView: ImageView) : ViewModel(), GpsInformationListener, IPlay, LifecycleObserver { - private val providerMap = HashMap() +class PlayViewModel( + val lifecycle: Lifecycle, + private val fl_play: FrameLayout, + private val imageView: ImageView +) : ViewModel(), GpsInformationListener, IPlay, LifecycleObserver { + + private val providerMap = HashMap() var mLocationManager: LocationManager? = null var isLocationEnabled = false var currentLocation: android.location.Location? = null @@ -120,7 +128,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, private var curLongitude: Double = 0.0 private var curlatitude: Double = 0.0 - private var locationTimer:Timer? =null + private var locationTimer: Timer? = null //不同步走这个线程 private val nextCheck: Runnable = Runnable { @@ -169,13 +177,14 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, val advertiseList = ArrayList() - val taxiApp:TaxiApp = TaxiApp.instance() as TaxiApp + val taxiApp: TaxiApp = TaxiApp.instance() as TaxiApp /** * 添加多时段播放任务 * @param advertise Advertise */ - fun addTimer(advertise: Advertise){ + fun addTimer(advertise: Advertise) { + "addTimer调用了".loge() taxiApp.isTimed = true val list = advertise.time_section @@ -188,7 +197,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, val weekDays = schedule.week_day for (weekDay in weekDays) { //SUNDAY(周天) = 1,Calendar.MONDAY(周一) == 2,依此类推SATURDAY == 7(周六) - val wDay = when(weekDay){ + val wDay = when (weekDay) { 1 -> 2 2 -> 3 3 -> 4 @@ -197,20 +206,33 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, 6 -> 7 else -> 1 } - if (startTime != endTime){ - val startCalendar:Calendar = DateUtil.getStartOrEndCalendar(wDay,startTime) - val endCalendar:Calendar = DateUtil.getStartOrEndCalendar(wDay,endTime) - endCalendar.set(Calendar.MONTH,startCalendar.get(Calendar.MONTH)) - endCalendar.set(Calendar.DAY_OF_MONTH,startCalendar.get(Calendar.DAY_OF_MONTH)) + if (startTime != endTime) { + val startCalendar: Calendar = DateUtil.getStartOrEndCalendar(wDay, startTime) + val endCalendar: Calendar = DateUtil.getStartOrEndCalendar(wDay, endTime) + val cal = Calendar.getInstance() + Log.d( + "DateUtil", + "差" + (weekDay - cal[Calendar.DAY_OF_WEEK] + 1).toString() + "天" + ) +// "没转换前的开始时间戳:${startTime}".loge() +// "没转换前的结束时间戳:${endTime}".loge() +// "没转换前的当前时间戳:${Calendar.getInstance()}".loge() +// "安卓获取时区转换后的当前时间:${Calendar.getInstance().time}".loge() +// "通过自身写的函数转换后的开始时间:${startCalendar}".loge() +// "通过自身写的函数转换后的结束时间:${endCalendar}".loge() +// "通过安卓转换后的开始---结束时间:${startCalendar.time}-${endCalendar.time}".loge() + + endCalendar.set(Calendar.MONTH, startCalendar.get(Calendar.MONTH)) + endCalendar.set(Calendar.DAY_OF_MONTH, startCalendar.get(Calendar.DAY_OF_MONTH)) //获取第一次开始执行定时任务的日期 - val startDate:Date = startCalendar.time + val startDate: Date = startCalendar.time "获取第一次开始执行定时任务的日期:${DateUtil.dateTimeFormat.format(startDate)}".loge() //获取任务轮询时间 val startTimeDiff = DateUtil.getTimeDiff(startCalendar, wDay, startTime) "获取任务轮询时间:${startTimeDiff.toString()}".loge() //获取第一次结束执行定时任务的日期 - val endDate:Date = endCalendar.time + val endDate: Date = endCalendar.time "获取第一次结束执行定时任务的日期:${DateUtil.dateTimeFormat.format(endDate)}".loge() //获取任务轮询时间 val endTimeDiff = DateUtil.getTimeDiff(endCalendar, wDay, endTime) @@ -219,18 +241,18 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, val currentTime = Date() val startCalender = Calendar.getInstance() startCalender.time = startDate - startCalender.add(Calendar.DAY_OF_MONTH,-7) + startCalender.add(Calendar.DAY_OF_MONTH, -7) val tempStartDate = startCalender.time val endCalender = Calendar.getInstance() endCalender.time = endDate - endCalender.add(Calendar.DAY_OF_MONTH,-7) + endCalender.add(Calendar.DAY_OF_MONTH, -7) val tempEndDate = endCalender.time "tempStartDate:${DateUtil.dateTimeFormat.format(tempStartDate)}".loge() "tempEndDate:${DateUtil.dateTimeFormat.format(tempEndDate)}".loge() if (currentTime.after(tempStartDate) && currentTime.before(tempEndDate)) { "当前时间在时间段之间".logi("SectionAdvertise") addTimedAdvertise(advertise) - val endTask = object : TimerTask(){ + val endTask = object : TimerTask() { var executeTime = 0L override fun run() { executeTime = System.currentTimeMillis() @@ -239,13 +261,26 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, "taxiApp.isTimedAdvertise:${Configurations.config(taxiApp.activity).isTimedAdvertise}".loge() } } - taxiApp.timer.schedule(endTask,tempEndDate) + //使用 taxiApp.timer 调度 endTask,在 tempEndDate 时间点执行任务。 + //如果是分时段,看他是否计次?达到次数就暂停播放 +// "是分时段里面的计次吗ZL:+${advertise.isCount}".loge() +// if (advertise.isCount){ +// if(advertise.play_numbers != -1){ +// ConnManger.getAdCount(advertise) +// } +// if (advertise.play_numbers < 0){ +// stopPlay() +// refreshAdvertise() +// return +// } +// } + taxiApp.timer.schedule(endTask, tempEndDate) } else { "当前时间不在时间段之间".logi("SectionAdvertise") } "---".logi("SectionAdvertise") //按照指定日期开始执行任务,对指定的任务按周期重复执行 - val startTask = object : TimerTask(){ + val startTask = object : TimerTask() { var executeTime = 0L override fun run() { executeTime = System.currentTimeMillis() @@ -254,10 +289,10 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, "taxiApp.isTimedAdvertise:${Configurations.config(taxiApp.activity).isTimedAdvertise}".loge() } } - taxiApp.timer.schedule(startTask,startDate,startTimeDiff) + taxiApp.timer.schedule(startTask, startDate, startTimeDiff) tasks.add(startTask) - val endTask = object : TimerTask(){ + val endTask = object : TimerTask() { var executeTime = 0L override fun run() { executeTime = System.currentTimeMillis() @@ -266,7 +301,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, // "taxiApp.isTimedAdvertise:${Configurations.config(taxiApp.activity).isTimedAdvertise}".loge() } } - taxiApp.timer.schedule(endTask,endDate,endTimeDiff) + taxiApp.timer.schedule(endTask, endDate, endTimeDiff) tasks.add(endTask) } } @@ -278,22 +313,26 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, * 添加定时广告 * @param advertise Advertise */ - private fun addTimedAdvertise(advertise: Advertise){ - if (advertise.is_exclusive){ //定时插播 - if (!taxiApp.timedAds.contains(advertise)){ - taxiApp.timedAds.add(0,advertise) + private fun addTimedAdvertise(advertise: Advertise) { + if (advertise.is_exclusive) { //定时插播 + if (!taxiApp.timedAds.contains(advertise)) { + taxiApp.timedAds.add(0, advertise) "分时段播放的广告数量:${taxiApp.timedAds.size}".loge() Configurations.config(taxiApp.activity).isTimedAdvertiseSave(true) val timedAdJsonStr = ProcessingCommands.gson.toJson(taxiApp.timedAds) Configurations.config(taxiApp.activity).timedAdListSave(timedAdJsonStr) //只有一个广告时才会立刻刷新画面,否则添加后正常轮播不刷新 - if (taxiApp.timedAds.size == 1){ + if (taxiApp.timedAds.size == 1) { refreshAdvertise() } } } else {//定时轮播 + "判断是不是计次广告0.o${advertise.isCount}".loge() + "那它这里也进来了噢".loge() "${advertise.ad_id}定时轮播".loge() - val daoAdvertise = getAdvertise().queryBuilder().where(Properties.Ad_id.eq(advertise.ad_id.toString())).unique() + val daoAdvertise = + getAdvertise().queryBuilder().where(Properties.Ad_id.eq(advertise.ad_id.toString())) + .unique() daoAdvertise.isTimedAd = false //edit by ljh @2023/8/14 taxiApp.daoAds.clear() @@ -310,14 +349,14 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, * 分时段播放结束 * @param advertise Advertise */ - private fun endTimedAd(advertise: Advertise){ - if (advertise.is_exclusive){ - if (taxiApp.timedAds.contains(advertise)){ + private fun endTimedAd(advertise: Advertise) { + if (advertise.is_exclusive) { + if (taxiApp.timedAds.contains(advertise)) { taxiApp.timedAds.remove(advertise) "${advertise.ad_id}定时广告移除".loge() val timedAdJsonStr = ProcessingCommands.gson.toJson(taxiApp.timedAds) Configurations.config(taxiApp.activity).timedAdListSave(timedAdJsonStr) - if (taxiApp.timedAds.size == 0){ + if (taxiApp.timedAds.size == 0) { Configurations.config(taxiApp.activity).isTimedAdvertiseSave(false) // refreshAdvertise() } @@ -328,15 +367,21 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, } } } else { - val daoAdvertise = getAdvertise().queryBuilder().where(Properties.Ad_id.eq(advertise.ad_id.toString())).unique() - daoAdvertise.isTimedAd = true - //edit by ljh @2023/8/14 - taxiApp.daoAds.clear() - getAdvertise().update(daoAdvertise) - try { - RefreshPlayer.refresh() - } catch (e: InterruptedException) { - e.printStackTrace() + val daoAdvertise = + getAdvertise().queryBuilder().where(Properties.Ad_id.eq(advertise.ad_id.toString())) + .unique() + if (daoAdvertise != null) { + daoAdvertise.isTimedAd = true + //edit by ljh @2023/8/14 + taxiApp.daoAds.clear() + getAdvertise().update(daoAdvertise) + try { + RefreshPlayer.refresh() + } catch (e: InterruptedException) { + e.printStackTrace() + } + } else { + Log.e("PlayViewModel", "daoAdvertise is null for ad_id: ${advertise.ad_id}") } } } @@ -345,39 +390,79 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, * 调这个方法就会从仓库中拿advertise播放 */ fun refreshAdvertise() { + if (LedOkActivity.isPersistPlay()) { + return + } + LedOkActivity.instance()?.finish() YoungUtil.YoungLog("刷新播放界面,开始播放 ") var advertise = Repository.getAdvertiseTEST() + Log.d("PlayViewModel", "从仓库中拿到的广告" + advertise.toString()) //#edit by ljh 2023/2/6 - if (advertise != null && advertise.isCount){ - if(advertise.play_numbers != -1){ + if (advertise != null && advertise.isCount) { + if (advertise.play_numbers != -1) { + Log.d("PlayViewModel", "从仓库中拿到的广告222$advertise") ConnManger.getAdCount(advertise) } + // Repository.playByCount(advertise) - if (advertise.play_numbers < 0){ - "删除次数已到达的广告".loge() - //删除次数已到达的广告 - DaoUtil.deleteAdvertise(advertise) - //如果是分时段广告 - if (advertise.isTimedAd){ - //移除广告的定时任务 - val tasks = taxiApp.timerTaskMap[advertise.ad_id] - tasks?.let { - if (tasks.isNotEmpty()){ - tasks.forEach { timeTask -> - timeTask.cancel() - } - } - } - } - ConnManger.sendOfflineAd(advertise.ad_id) - Repository.currentListOrder += 1 - refreshAdvertise() - return - } + +// if (advertise.play_numbers < 0){ +// Log.d("PlayViewModel", "广告具体内容:$advertise"); +// var ad= getAdvertise() +// .queryBuilder() +// .where(AdvertiseDao.Properties.Ad_id.eq(advertise.ad_id)) +// .unique() +// //if (advertise.time_section!=null && advertise.time_section.size>0) +// Log.d("PlayViewModel", "从数据库中拿到的广告内容:${ad}"); +// if (ad.time_section!=null && advertise.time_section.size>0) +// { +// val firstPlay = getFirstPlayDao() +// .queryBuilder() +// .where(FirstPlayModelDao.Properties.Id.eq(advertise.ad_id)) +// .unique() +// advertise.isTimedAd=true +// //从数据库中获取到的节目播放次数,然后在这里重新给advertise.play_numbers赋值,然后持久化到数据库 +// advertise.play_numbers=firstPlay.play_numbers +// getAdvertise().insertOrReplace(advertise) +// } +// Log.d("PlayViewModel","是分时段广告?"+advertise.isTimedAd); +// if (advertise.isTimedAd){ +// Handler(Looper.getMainLooper()).post { +// "是定时广告,进来了要先删除后添加,广告内容是:${advertise}".loge() +// "是定时广告,进来了要先删除后添加,广告id是:${advertise.ad_id}".loge() +// //删除是为了停止播放定时节目后能继续播放普通广告 +// DaoUtil.deleteAdvertise(advertise) +// //添加是为了定时广告在后面能继续播放 +// getAdvertise().insert(advertise) +// refreshAdvertise() +// } +// return +// } +// "删除次数已到达的广告".loge() +// //删除次数已到达的广告 +// DaoUtil.deleteAdvertise(advertise) +// //如果是分时段广告 +// if (advertise.isTimedAd){ +// //移除广告的定时任务 +// val tasks = taxiApp.timerTaskMap[advertise.ad_id] +// tasks?.let { +// if (tasks.isNotEmpty()){ +// tasks.forEach { timeTask -> +// timeTask.cancel() +// } +// } +// } +// } +// ConnManger.sendOfflineAd(advertise.ad_id) +// Repository.currentListOrder += 1 +// refreshAdvertise() +// return +// } + // saveCountAdLog(advertise) } // "当前播放的广告:${Repository.getTestPlayCircularList().toString()}".loge() - playLiveData.postValue(advertise) + playLiveData.postValue(advertise) //MutableLiveData用于数据更新和UI响应的组件。是响应式的,当数据发生变化时,它会自动通知观察者(通常是UI组件),并更新UI。 } /** @@ -385,7 +470,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, * @param advertise Advertise */ @Synchronized - fun saveCountAdLog(advertise: Advertise){ + fun saveCountAdLog(advertise: Advertise) { if (Configurations.config(TaxiApp.instance()).loggerSwitch()) { var container: Container? = null val list = DaoUtil.getContainerDao().loadAll() @@ -460,7 +545,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, * 播放广告 */ fun playAdvertise(advertise: Advertise?) { - YoungUtil.YoungLog( "playAdvertise here .") + YoungUtil.YoungLog("playAdvertise here .") synchronized(fl_play) { if (advertise != null) { @@ -468,7 +553,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, // ConnManger.getAdCount(advertise) // } - YoungUtil.YoungLog( "Advertise id:" + advertise.ad_id + " " + advertise.pathName) + YoungUtil.YoungLog("Advertise id:" + advertise.ad_id + " " + advertise.pathName) //记录上一个广告日志的duration // if (curLogger != null && Configurations.config(TaxiApp.instance()).loggerSwitch()) { // var duration: Long = System.currentTimeMillis() - curLogger!!.created_at @@ -504,7 +589,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, YoungUtil.YoungLog("添加新的广告region_id:${advertise.region_id}") - if(!advertise.isCount){ + if (!advertise.isCount) { setCurAdvertise(advertise) } else { curAdvertise = advertise @@ -528,8 +613,10 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, } */ //替换成下面的逻辑,为了同步播放前持续播放广告,同步触发一次后就走以前正常逻辑 - if(TaxiApp.startSyncMode) { - if (Configurations.config(TaxiApp.instance()).sync() && advertise.belongTo == AdvertiseType.GROUP.ordinal) { + if (TaxiApp.startSyncMode) { + if (Configurations.config(TaxiApp.instance()) + .sync() && advertise.belongTo == AdvertiseType.GROUP.ordinal + ) { YoungUtil.YoungLog("是同步的逻辑") handler.removeCallbacksAndMessages(null) RefreshPlayer.refresh() @@ -570,6 +657,75 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, } + + /** + * ledok播放广告 + */ + fun playAdvertiseLedOk(advertise: Advertise?) { + Log.d(TAG, "playAdvertiseLedOk: ") + synchronized(fl_play) { + if (advertise != null) { + Log.d( + TAG, + "playAdvertiseLedOk: Advertise id:" + advertise.ad_id + " " + advertise.pathName + ) + val createView = fl_play.createView(fl_play.context, advertise, 0) + fl_play.apply { + val currentTimeMillis = System.currentTimeMillis() + addChildView(createView, advertise) + Log.d( + TAG, + "playAdvertiseLedOk: " + "切换节目用时:${System.currentTimeMillis() - currentTimeMillis}" + ) + Log.d( + TAG, + "playAdvertiseLedOk: " + "播放素材更新 id = ${advertise.ad_id} 是否在主线程${isMainThread()}" + ) + } + Log.d(TAG, "playAdvertiseLedOk: " + "添加新的广告region_id:${advertise.region_id}") + + if (!advertise.isCount) { + setCurAdvertise(advertise) + } else { + curAdvertise = advertise + } + + //替换成下面的逻辑,为了同步播放前持续播放广告,同步触发一次后就走以前正常逻辑 + if (TaxiApp.startSyncMode) { + if (Configurations.config(TaxiApp.instance()) + .sync() && advertise.belongTo == AdvertiseType.GROUP.ordinal + ) { + YoungUtil.YoungLog("是同步的逻辑") + handler.removeCallbacksAndMessages(null) + RefreshPlayer.refresh() + } else { + YoungUtil.YoungLog("非同步的逻辑") + when (Configurations.config(TaxiApp.instance()).company()) { + XIXUN -> checkIsStartTimerByXixun() + SANLE -> checkIsStartTimerBySanle() + HAOSHENG -> checkIsStartTimerBySanle() + MAIDIER -> checkIsStartTimerBySanle() + } + } + } else { + YoungUtil.YoungLog("非同步的逻辑") + when (Configurations.config(TaxiApp.instance()).company()) { + XIXUN -> checkIsStartTimerByXixun() + SANLE -> checkIsStartTimerBySanle() + HAOSHENG -> checkIsStartTimerBySanle() + MAIDIER -> checkIsStartTimerBySanle() + } + } + + } else { + YoungUtil.YoungLog("收到的广告为空停止播放") + Log.d(TAG, "playAdvertiseLedOk: 收到的广告为空停止播放") + stopPlay() + } + } + + } + private fun addChildView(view: View?, advertise: Advertise) { if (view != null) { view.tag = advertise.ad_id @@ -617,7 +773,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, fl_play.removeView(childView) } } - },2000L) + }, 2000L) // fl_play.postDelayed({ // YoungUtil.YoungLog("删除View,FrameLayout有多少子视图:${fl_play.childCount}") @@ -660,22 +816,34 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, YoungUtil.YoungLog("设置变化状态") layoutTransition.setDuration(LayoutTransition.APPEARING, 1000) - val addAnimator = ObjectAnimator.ofFloat(null, "alpha", 0.0f, 1.0f).setDuration(layoutTransition.getDuration(LayoutTransition.APPEARING)) + val addAnimator = ObjectAnimator.ofFloat(null, "alpha", 0.0f, 1.0f) + .setDuration(layoutTransition.getDuration(LayoutTransition.APPEARING)) layoutTransition.setAnimator(LayoutTransition.APPEARING, addAnimator) // layoutTransition.setStartDelay(LayoutTransition.APPEARING,0) layoutTransition.setDuration(LayoutTransition.DISAPPEARING, 1000) - val removeAnimator = ObjectAnimator.ofFloat(null, "alpha", 1.0f, 0.0f).setDuration(layoutTransition.getDuration(LayoutTransition.DISAPPEARING)) + val removeAnimator = ObjectAnimator.ofFloat(null, "alpha", 1.0f, 0.0f) + .setDuration(layoutTransition.getDuration(LayoutTransition.DISAPPEARING)) layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, removeAnimator) layoutTransition.addTransitionListener(object : TransitionListener { - override fun startTransition(transition: LayoutTransition?, container: ViewGroup?, view: View?, transitionType: Int) { + override fun startTransition( + transition: LayoutTransition?, + container: ViewGroup?, + view: View?, + transitionType: Int + ) { YoungUtil.YoungLog("startTransition$transitionType") } - override fun endTransition(transition: LayoutTransition?, container: ViewGroup?, view: View?, transitionType: Int) { + override fun endTransition( + transition: LayoutTransition?, + container: ViewGroup?, + view: View?, + transitionType: Int + ) { YoungUtil.YoungLog("endTransition$transitionType") } }) @@ -750,7 +918,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, } else { status = PlayerStatus.START YoungUtil.YoungLog("checkIsStartTimer ThreadId: ${Thread.currentThread().id} ,curAdvertise:${curAdvertise.toString()}}") - handler.postDelayed(nextCheck,curAdvertise!!.duration.toLong()) + handler.postDelayed(nextCheck, curAdvertise!!.duration.toLong()) } } @@ -803,6 +971,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, var cachePlayLoggers = ArrayList() + /** * 将curLogger设置为播放完成后存储到LoggerContainer中,并将curLogger清空 */ @@ -852,7 +1021,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, // latitude =advertise.latitude longitude = curLongitude latitude = curlatitude - // YoungUtil.YoungLog("advertise adid :${advertise.ad_id}, 经纬度 ${longitude},${latitude}") + // YoungUtil.YoungLog("advertise adid :${advertise.ad_id}, 经纬度 ${longitude},${latitude}") //#edit by ljh // if (advertise.isCount){ // duration = advertise.duration.toLong() @@ -879,7 +1048,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 { // ThreadUtil.executeByPool( //edit by ljh @2023/8/16 @@ -900,12 +1075,12 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, //edit by ljh @2023/8/28 regionCacheSwitch -= 1 - if (regionCacheSwitch<=0){ + if (regionCacheSwitch <= 0) { regionCacheSwitch = MAX_CACHE taxiApp.regionsList.clear() } - // val regions = DaoUtil.getRegion().loadAll() - var regions = if (taxiApp.regionsList.isNotEmpty()){ + // val regions = DaoUtil.getRegion().loadAll() + var regions = if (taxiApp.regionsList.isNotEmpty()) { "从缓存获取regions数据:${taxiApp.regionsList},regionCacheSwitch:$regionCacheSwitch".logd() taxiApp.regionsList } else { @@ -919,19 +1094,37 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, var isRefresh = false for (region in regions) { "regionAdId:${region.regionAdId},index:${regions.indexOf(region)}".logd() - YoungUtil.YoungLog("当前两点间距离:${DistanceUtil.getDistance(region.lat, region.lng, latitude, longitude)}") - YoungUtil.YoungLog("points: "+ latitude + " & " + region.lat + " & " + longitude + " & " + region.lng); - if (DistanceUtil.inRadius(region.lat, region.lng, latitude, longitude, region.radius)) { + YoungUtil.YoungLog( + "当前两点间距离:${ + DistanceUtil.getDistance( + region.lat, + region.lng, + latitude, + longitude + ) + }" + ) + YoungUtil.YoungLog("points: " + latitude + " & " + region.lat + " & " + longitude + " & " + region.lng); + if (DistanceUtil.inRadius( + region.lat, + region.lng, + latitude, + longitude, + region.radius + ) + ) { YoungUtil.YoungLog("进圈 regionId: ${region.id}") region.isInRegion = true //edit by ljh @2023/8/14 - if (taxiApp.regionsList.isNotEmpty()){ + if (taxiApp.regionsList.isNotEmpty()) { taxiApp.updateCacheRegions(region) - val reg = DaoUtil.getRegion().queryBuilder().where(RegionsDao.Properties.AutoId.eq(region.autoId)).unique() - if (reg != null){ + val reg = DaoUtil.getRegion().queryBuilder() + .where(RegionsDao.Properties.AutoId.eq(region.autoId)) + .unique() + if (reg != null) { reg.isInRegion = true DaoUtil.getRegion().update(reg) } else { @@ -953,9 +1146,17 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, DaoUtil.getAdvertise().insert(advertise) RefreshPlayer.refresh() */ - val positionAdvertise = DaoUtil.getPositionAdvertise().queryBuilder().where(PositionAdvertiseDao.Properties.Task_id.eq(region.regionAdId)).unique() - if(positionAdvertise != null) { - val advertise = setAdvertiseByPosition(positionAdvertise, region.id, longitude, latitude) + val positionAdvertise = + DaoUtil.getPositionAdvertise().queryBuilder() + .where(PositionAdvertiseDao.Properties.Task_id.eq(region.regionAdId)) + .unique() + if (positionAdvertise != null) { + val advertise = setAdvertiseByPosition( + positionAdvertise, + region.id, + longitude, + latitude + ) DaoUtil.getAdvertise().insert(advertise) //edit by ljh @2023/8/15 taxiApp.daoAds.clear() @@ -974,12 +1175,14 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, region.isInRegion = false //edit by ljh @2023/8/14 - if (taxiApp.regionsList.isNotEmpty()){ + if (taxiApp.regionsList.isNotEmpty()) { taxiApp.updateCacheRegions(region) - val reg = DaoUtil.getRegion().queryBuilder().where(RegionsDao.Properties.AutoId.eq(region.autoId)).unique() - if (reg != null){ + val reg = DaoUtil.getRegion().queryBuilder() + .where(RegionsDao.Properties.AutoId.eq(region.autoId)) + .unique() + if (reg != null) { reg.isInRegion = false DaoUtil.getRegion().update(reg) } else { @@ -998,7 +1201,9 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, //edit by ljh @2023/12/12 Repository.cancelTimer() isRefresh = true - DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.Ad_id.eq(region.regionAdId)).buildDelete() + DaoUtil.getAdvertise().queryBuilder() + .where(AdvertiseDao.Properties.Ad_id.eq(region.regionAdId)) + .buildDelete() .executeDeleteWithoutDetachingEntities() YoungUtil.YoungLog("没进圈删除定点广告:${region.regionAdId}") taxiApp.isPositionRefresh = true @@ -1006,14 +1211,14 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, } } } - if (isRefresh){ + if (isRefresh) { "定点变动,刷新列表".loge() RefreshPlayer.refresh() } } - if(locationTimer!=null){ + if (locationTimer != null) { YoungUtil.YoungLog("收到新的坐标,取消之前定时") locationTimer!!.cancel() locationTimer!!.purge() @@ -1022,12 +1227,12 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, locationTimer = Timer() //如果30秒没有收到坐标变化,清空定点广告 - locationTimer!!.schedule(object :TimerTask(){ + locationTimer!!.schedule(object : TimerTask() { override fun run() { YoungUtil.YoungLog("长时间没新的坐标,恢复普通广告") clearAreaAdvertise() } - },30*1000) + }, 30 * 1000) } }) @@ -1041,7 +1246,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, "list对象是空的吗:${list == null}".loge() "list元素是0吗:${list?.size}".loge() //edit by ljh @2024/4/19修复收到的GPS卫星数量为0时频繁刷新问题 - if (list.isNotEmpty()){ + if (list.isNotEmpty()) { //edit by ljh @2023/8/11 taxiApp.daoAds.clear() for (advertise in list) { @@ -1057,10 +1262,13 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, } + private var lastExecutionTime: Long = 0 + + //超过20米记录gps距离 private fun saveLocation(longitude: Double, latitude: Double, bearing: Float, speed: Float) { if (curLocation == null) { YoungUtil.YoungLog("当前curLocation == null") - if (longitude == 0.0 || latitude == 0.0){ + if (longitude == 0.0 || latitude == 0.0) { return } val location = Location().apply { @@ -1078,7 +1286,12 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, } else { if (curLocation?.longitude?.toDouble() != longitude || curLocation?.latitude?.toDouble() != latitude) { //YoungUtil.YoungLog("当前位置不相等${curLocation.toString()},当前longitude =$longitude,latitude =$latitude") - val distanceLocation = DistanceUtil.getDistance(curLocation!!.latitude, curLocation!!.longitude, latitude, longitude) + val distanceLocation = DistanceUtil.getDistance( + curLocation!!.latitude, + curLocation!!.longitude, + latitude, + longitude + ) //edit by ljh@2023/8/22 if (distanceLocation > 20) { // Log.d("LCT","DistanceUtil --> distanceLocation:$distanceLocation") @@ -1112,7 +1325,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, //过滤掉距离过大的数据,edit by ljh 2023/8/8 location.distance?.let { - if (it < JUMP_THRESHOLD){ + if (it < JUMP_THRESHOLD) { DaoUtil.getLocationDao().insert(location) // 如果不是跳跃点,更新上一个有效点的坐标 curLocation = location @@ -1158,7 +1371,11 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, distance = distanceLocation.toFloat() elapse = timestamp - curLocation?.timestamp!! } - saveQuietGPS(location) + val currentTime = System.currentTimeMillis() + if (currentTime - lastExecutionTime >= (1000 * 60 * 2)) { + lastExecutionTime = currentTime + saveQuietGPS(location) + } return } } else { @@ -1172,16 +1389,8 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, * @param location Location */ private fun saveQuietGPS(location: Location) { - if (taxiApp.quietGpsTimer == null) { - "开启存储静止点的定时器".logd() - taxiApp.quietGpsTimer = Timer() - taxiApp.quietGpsTimer?.schedule(object :TimerTask(){ - override fun run() { - "三分钟没收到非静止的点了,存储静止点:${location.timestamp}".logd() - DaoUtil.getLocationDao().insert(location) - } - },3*60*1000,3*60*1000) - } + "save gps存储静止点:${location.timestamp}".logd() + DaoUtil.getLocationDao().insert(location) } /** @@ -1190,7 +1399,8 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, private fun isHavePositionAdvertise(region: Regions): Boolean { // val advertise: Advertise? = DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.Ad_id.eq(region.regionAdId)).unique() if (region.isInRegion) { - val advertiseList = DaoUtil.getAdvertise().queryBuilder().where(AdvertiseDao.Properties.Ad_id.eq(region.regionAdId)).list() + val advertiseList = DaoUtil.getAdvertise().queryBuilder() + .where(AdvertiseDao.Properties.Ad_id.eq(region.regionAdId)).list() if (advertiseList.size > 1) { for (index in 0 until advertiseList.size) { @@ -1258,9 +1468,10 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, /** * 初始化定位 */ - fun initLocation(){ + fun initLocation() { //从系统服务中获取定位管理器 - mLocationManager = TaxiApp.instance().getSystemService(Context.LOCATION_SERVICE) as LocationManager + mLocationManager = + TaxiApp.instance().getSystemService(Context.LOCATION_SERVICE) as LocationManager // 创建一个定位准则对象 val criteria = Criteria() // 设置定位精确度 @@ -1281,7 +1492,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, bestProvider?.let { if (mLocationManager != null && mLocationManager!!.isProviderEnabled(it)) { // 定位提供者当前可用 "定位类型为${providerMap[it]},开始定位".loge() - beginLocation(it,15*1000) // 开始定位 + beginLocation(it, 15 * 1000) // 开始定位 isLocationEnabled = true } else { // 定位提供者暂不可用 "${providerMap[bestProvider!!].toString()} 不可用".loge() @@ -1296,9 +1507,12 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, * 开始定位 * @param method String */ - private fun beginLocation(method: String,minTime:Long):Boolean { + private fun beginLocation(method: String, minTime: Long): Boolean { // 检查当前设备是否已经开启了定位功能 - if (ActivityCompat.checkSelfPermission(TaxiApp.instance(), Manifest.permission.ACCESS_FINE_LOCATION) + if (ActivityCompat.checkSelfPermission( + TaxiApp.instance(), + Manifest.permission.ACCESS_FINE_LOCATION + ) != PackageManager.PERMISSION_GRANTED ) { "location not opened,请授予定位权限并开启定位功能".loge() @@ -1327,9 +1541,11 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, 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() } @@ -1339,7 +1555,7 @@ class PlayViewModel(val lifecycle: Lifecycle, private val fl_play: FrameLayout, * 获取位置变更监听器 * @return LocationListener? */ - fun getLocationListener(): LocationListener{ + fun getLocationListener(): LocationListener { return mLocationListener } } \ No newline at end of file diff --git a/app/src/main/java/cn/trans88/taxiappkotlin/util/DateUtil.java b/app/src/main/java/cn/trans88/taxiappkotlin/util/DateUtil.java index 75a2bd5..1e0a161 100644 --- a/app/src/main/java/cn/trans88/taxiappkotlin/util/DateUtil.java +++ b/app/src/main/java/cn/trans88/taxiappkotlin/util/DateUtil.java @@ -31,14 +31,18 @@ public class DateUtil { */ public static Calendar getStartOrEndCalendar(Integer weekDay,Long startOrEndTime){ Calendar calendar = Calendar.getInstance(); +// Log.d("DateUtil", String.valueOf(new Date(startOrEndTime))); calendar.setTime(new Date(startOrEndTime)); int hourTime = calendar.get(Calendar.HOUR_OF_DAY); int minuteTime = calendar.get(Calendar.MINUTE); int secondTime = calendar.get(Calendar.SECOND); +// Log.d("DateUtil", "hourTime:"+hourTime); +// Log.d("DateUtil", "minuteTime:"+minuteTime); +// Log.d("DateUtil", "secondTime:"+secondTime); // 获取当前时间 Calendar cal = Calendar.getInstance(); +// Log.d("DateUtil", "进入转换,当前时间."+cal); - // 计算距离下一个周一的天数,SUNDAY = 1,Calendar.MONDAY == 2,依此类推SATURDAY == 7 int day = weekDay - cal.get(Calendar.DAY_OF_WEEK); if (day <= 0) { day += 7; @@ -157,6 +161,26 @@ public class DateUtil { return dayType; } + //判断两天之间的天数差 + public static long daysBetweenTimestamps(long savedTimestamp, long currentTimestamp) { + Calendar savedDate = Calendar.getInstance(); + savedDate.setTimeInMillis(savedTimestamp); + // 将时间设置为当天的开始(00:00:00) + savedDate.set(Calendar.HOUR_OF_DAY, 0); + savedDate.set(Calendar.MINUTE, 0); + savedDate.set(Calendar.SECOND, 0); + savedDate.set(Calendar.MILLISECOND, 0); + Calendar currentDate = Calendar.getInstance(); + currentDate.setTimeInMillis(currentTimestamp); + // 将时间设置为当天的开始(00:00:00) + currentDate.set(Calendar.HOUR_OF_DAY, 0); + currentDate.set(Calendar.MINUTE, 0); + currentDate.set(Calendar.SECOND, 0); + currentDate.set(Calendar.MILLISECOND, 0); + + long diffInMillis = currentDate.getTimeInMillis() - savedDate.getTimeInMillis(); + return diffInMillis / (24 * 60 * 60 * 1000); + } } diff --git a/app/src/main/res/layout/activity_ledok.xml b/app/src/main/res/layout/activity_ledok.xml new file mode 100644 index 0000000..5de36ff --- /dev/null +++ b/app/src/main/res/layout/activity_ledok.xml @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-mdpi/logo2.jpg b/app/src/main/res/mipmap-mdpi/logo2.jpg index 87db084..d75051a 100644 Binary files a/app/src/main/res/mipmap-mdpi/logo2.jpg and b/app/src/main/res/mipmap-mdpi/logo2.jpg differ diff --git a/app/src/main/res/raw/black_background.png b/app/src/main/res/raw/black_background.png new file mode 100644 index 0000000..ec85866 Binary files /dev/null and b/app/src/main/res/raw/black_background.png differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c334c44..cd46572 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,7 +1,10 @@ TaxiApp + TopLevelActivity + + /sdcard/logger TaxiAppCrash- smtp.163.com diff --git a/build.gradle b/build.gradle index 9bd7937..5bab12f 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,12 @@ buildscript { ext.livedata ='2.2.0' repositories { + maven { url 'https://maven.aliyun.com/repository/public' } + maven { url 'https://maven.aliyun.com/repository/central' } + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } google() + mavenCentral() jcenter() maven { url 'https://jitpack.io' } @@ -25,6 +30,10 @@ buildscript { allprojects { repositories { + maven { url 'https://maven.aliyun.com/repository/public' } + maven { url 'https://maven.aliyun.com/repository/central' } + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } google() jcenter() maven { url 'https://jitpack.io' } diff --git a/build/intermediates/lint-cache/sdk-registry.xml/sdk-registry.xml b/build/intermediates/lint-cache/sdk-registry.xml/sdk-registry.xml deleted file mode 100644 index 2b099a4..0000000 --- a/build/intermediates/lint-cache/sdk-registry.xml/sdk-registry.xml +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f12a391..a380318 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ -#Mon Jun 08 10:25:29 CST 2020 +#Sat Oct 26 16:06:05 CST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -#distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/kurolibrary/build.gradle b/kurolibrary/build.gradle index e34bac9..17139f3 100644 --- a/kurolibrary/build.gradle +++ b/kurolibrary/build.gradle @@ -1,3 +1,14 @@ + +buildscript { + repositories { + maven { url 'https://maven.aliyun.com/repository/public' } + maven { url 'https://maven.aliyun.com/repository/central' } + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } + jcenter() + } +} + plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' @@ -50,4 +61,5 @@ dependencies { api 'com.squareup.okhttp3:okhttp:4.1.0' api 'com.squareup.retrofit2:retrofit:2.7.1' api 'com.squareup.retrofit2:converter-scalars:2.7.1' -} \ No newline at end of file +} + diff --git a/kurotool/build.gradle b/kurotool/build.gradle index aecb5e0..264e619 100644 --- a/kurotool/build.gradle +++ b/kurotool/build.gradle @@ -72,6 +72,10 @@ dependencies { buildscript { repositories { + maven { url 'https://maven.aliyun.com/repository/public' } + maven { url 'https://maven.aliyun.com/repository/central' } + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } jcenter() } dependencies { diff --git a/local.properties b/local.properties index 42be3be..5a7784b 100644 --- a/local.properties +++ b/local.properties @@ -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. -#Tue Jun 25 17:11:45 GMT+08:00 2024 -sdk.dir=D\:\\Android\\sdk +#Sat Oct 26 14:09:46 CST 2024 +sdk.dir=D\:\\develop\\Android\\Sdk diff --git a/release/output.json b/release/output.json index c8a8905..fa68e02 100644 --- a/release/output.json +++ b/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":257,"versionName":"3.3.3-beta26.4.1.4-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.4.1.4-release{257}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.4.1.4-release{257}.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":259,"versionName":"3.3.3-beta26.4.1.7-release","enabled":true,"outputFile":"TaxiApp_v3.3.3-beta26.4.1.7-release{259}.apk","fullName":"release","baseName":"release","dirName":""},"path":"TaxiApp_v3.3.3-beta26.4.1.7-release{259}.apk","properties":{}}] \ No newline at end of file