From e59a33b1c706acdfd498a239a30f87b6b4e72b42 Mon Sep 17 00:00:00 2001 From: gaozl Date: Fri, 20 Mar 2026 15:14:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 6 +- app/src/main/AndroidManifest.xml | 2 + .../activity/H5/UpdateFileActivity.java | 5 +- .../activity/H5/WebViewActivity.java | 6 +- .../activity/program/MyPresentation.java | 91 ++------------ .../activity/program/ScreenSaverActivity.java | 25 ++-- .../activity/program/ViewScreenSaver.java | 117 ++---------------- .../qianmu/container/app/MyApplication.java | 19 ++- .../qianmu/container/mqtt/MQTTService.java | 41 +++--- .../qianmu/container/util/SignWayUtil.java | 15 +-- app/src/main/res/layout/presentation.xml | 15 +-- 11 files changed, 91 insertions(+), 251 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index bb7ff93..e7202ec 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,7 +12,7 @@ android { minSdkVersion 24 targetSdkVersion 30 versionCode 6 - versionName "V2.0.8.17" + versionName "V2.0.8.18" // 2.0.8.2 修改网络连接证书设置、定时开关机设置 // 2.0.8.3 获取mac修改 // V2.0.8.5 同屏优化 @@ -142,8 +142,8 @@ dependencies { implementation 'cn.hutool:hutool-all:5.8.26' //清除页面缓存 - debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3' - releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3' + //debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3' + //releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3' //检测内存泄漏 // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9ae3840..cb684ab 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ + @@ -88,6 +89,7 @@ android:name=".activity.program.ScreenSaverActivity" android:configChanges="touchscreen|keyboard|keyboardHidden|navigation" android:launchMode="singleTask" + android:hardwareAccelerated="true" android:screenOrientation="nosensor" /> totalQueryCount++, () -> queryResponseCount++ ,bigFiles); + LoggerUtil.e("语音授权: ", String.valueOf(MyApplication.getInstance().duiliteConfig)); + if(MyApplication.getInstance().duiliteConfig){ // 语音授权完成 + H5Data.queryAiServeList( () -> totalQueryCount++, () -> queryResponseCount++ ,bigFiles); + } if("指路机".equals(deviceType)){ DeviceData.getBackgroundMusic( () -> totalQueryCount++, () -> queryResponseCount++ ,bigFiles); diff --git a/app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java b/app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java index 3d1b98f..3021a0e 100644 --- a/app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java +++ b/app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java @@ -112,7 +112,7 @@ public class WebViewActivity extends BaseActivity { static final int TYPE_START_SERVER = 4;//重新启动web服务 static final int TYPE_SHENG_HTML_MAG = 5;//返回接口请求值给h5 static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址 - //static String HtmlUrl = "http://192.168.1.196:5501/index.html"; + //static String HtmlUrl = "http://192.168.0.100:5173/"; int time = 0; String interfaceRequestData=""; private VideoView currentVideo; //当前 @@ -193,8 +193,7 @@ public class WebViewActivity extends BaseActivity { binding = DataBindingUtil.setContentView(this, R.layout.activity_webview); String jsonString = FileUtil.readLocalJsonForStorage(this, StringUtil.strSplice(Constant.CACHE_PATH3,"/JSON/getChatManVideo.json")); - if(!StringUtil.isEmpty(jsonString)){ //是AI - LoggerUtil.e("getChatManVideo:","有数字人视频"); + if(!StringUtil.isEmpty(jsonString) && MyApplication.getInstance().duiliteConfig){ //是AI // 设置背景透明度 binding.web.setBackgroundColor(Color.TRANSPARENT); isChatMan = true; @@ -258,7 +257,6 @@ public class WebViewActivity extends BaseActivity { } } - //设置密码 initPass(); try{ diff --git a/app/src/main/java/qianmu/container/activity/program/MyPresentation.java b/app/src/main/java/qianmu/container/activity/program/MyPresentation.java index 54310d9..bb3e818 100644 --- a/app/src/main/java/qianmu/container/activity/program/MyPresentation.java +++ b/app/src/main/java/qianmu/container/activity/program/MyPresentation.java @@ -507,27 +507,6 @@ class MyPresentation extends Presentation { //存在视频组件 String localPath = StringUtil.strSplice(Constant.CACHE_PATH, components.getMaterials().get(0).getFileUrl()); if(videoViewNumb==0){ - //第一个videoview - if(components.getMaterials().get(0).getDuration()>0){ - //视频 - - if(components.getMaterials().get(0).getPreviewUrl()!=null && !components.getMaterials().get(0).getPreviewUrl().isEmpty()){ - BitmapUtil.loadImage(downloadaddress, Constant.CACHE_PATH, components.getMaterials().get(0).getPreviewUrl(),videoImg2); - } - -// String[] b = localPath.split("\\."); -// String imgUrl = b[0]+".jpg"; -// if(new File(imgUrl).exists()){ -// binding.videoImg0.setVisibility(View.GONE); -// Glide.with(context).load(imgUrl).into(binding.videoImg0) -// } - }else { - //图片 - if(new File(localPath).exists()){ - Glide.with(context).load(localPath).into(videoImg2); - } - } - if(!isNextVideo){ Log.e("(双面屏)TAG","预览设置下个视频"); isNextVideo=true; @@ -541,25 +520,6 @@ class MyPresentation extends Presentation { } } }else { - //第二个videoview - if(components.getMaterials().get(0).getDuration()>0){ - //视频 - - if(components.getMaterials().get(0).getPreviewUrl()!=null && !components.getMaterials().get(0).getPreviewUrl().isEmpty()){ - BitmapUtil.loadImage(downloadaddress, Constant.CACHE_PATH, components.getMaterials().get(0).getPreviewUrl(),videoImg3); - } -// String[] b = localPath.split("\\."); -// String imgUrl = b[0]+".jpg"; -// if(new File(imgUrl).exists()){ -// binding.videoImg1.setVisibility(View.GONE); -// Glide.with(context).load(imgUrl).into(binding.videoImg1); -// } - }else { - //图片 - if(new File(localPath).exists()){ - Glide.with(context).load(localPath).into(videoImg3); - } - } if(!isNextVideo){ Log.e("(双面屏)TAG","预览设置下个视频"); @@ -1339,8 +1299,6 @@ class MyPresentation extends Presentation { ImageView otherImg14; ImageView otherImg15; RelativeLayout relativeLayoutMax; - ImageView videoImg2; - ImageView videoImg3; ImageView img0; ImageView img1; ImageView img2; @@ -1400,8 +1358,6 @@ class MyPresentation extends Presentation { layoutTime4 = findViewById(R.id.layout_time4); layoutVideo2 = findViewById(R.id.layout_video2); layoutVideo3 = findViewById(R.id.layout_video3); - videoImg2 = findViewById(R.id.videoImg2); - videoImg3 = findViewById(R.id.videoImg3); layoutImg0 = findViewById(R.id.layout_img0); layoutImg1 = findViewById(R.id.layout_img1); layoutImg2 = findViewById(R.id.layout_img2); @@ -1531,9 +1487,7 @@ class MyPresentation extends Presentation { videoPlayCount0 = 0; videoPlayCount1 = 0; startVideoTime=0; - isvideoPlay0=false; - isvideoPlay1=false; - + //图片切换 imagePlayCount0 = 0; imagePlayCount1 = 0; @@ -2650,9 +2604,7 @@ class MyPresentation extends Presentation { RelativeLayout.LayoutParams lParams = new RelativeLayout.LayoutParams(components.getWidth(), components.getHeight()); lParams.setMargins(components.getOffsetX(), components.getOffsetY(), 0, 0); if(position==0){ - isNextVideo = true; - isvideoPlay0 = true; videoView2.pause(); videoView2.seekTo(0); layoutVideo2.setX(components.getOffsetX()); @@ -2665,11 +2617,10 @@ class MyPresentation extends Presentation { layoutVideo2.setVisibility(View.VISIBLE); layoutVideo2.bringToFront(); handler.sendEmptyMessage(TYPE_UPDATE_VIDEO0); - videoImg2.setVisibility(View.VISIBLE); videoView2.setOnPreparedListener(new CustomerVideoView.OnPreparedListener() { @Override public void onPrepared() { - videoStartPlay(videoView2, videoImg2, videoComponents0, isvideoPlay0); + videoStartPlay(videoView2, videoComponents0); } }); @@ -2697,7 +2648,6 @@ class MyPresentation extends Presentation { }else if(position==1){ - isvideoPlay1 = true; layoutVideo3.setX(components.getOffsetX()); layoutVideo3.setY(components.getOffsetY()); ViewGroup.LayoutParams layoutParams = layoutVideo3.getLayoutParams(); @@ -2711,15 +2661,13 @@ class MyPresentation extends Presentation { layoutVideo3.setVisibility(View.VISIBLE); layoutVideo3.bringToFront(); - videoImg3.setVisibility(View.VISIBLE); - videoComponents1 = components; handler.sendEmptyMessage(TYPE_UPDATE_VIDEO1); videoView3.setOnPreparedListener(new CustomerVideoView.OnPreparedListener() { @Override public void onPrepared() { - videoStartPlay(videoView3, videoImg3, videoComponents1, isvideoPlay1); + videoStartPlay(videoView3, videoComponents1); } }); @@ -2743,38 +2691,25 @@ class MyPresentation extends Presentation { } } - private void videoStartPlay(CustomerVideoView vView, ImageView imgView, NewProgramBean.components components, Boolean isPlay){ + private void videoStartPlay(CustomerVideoView vView, NewProgramBean.components components){ vView.setOnInfoListener(new CustomerVideoView.OnInfoListener() { @Override public void onInfo() { - //vView.clearBackground(); - imgView.setVisibility(View.GONE); + vView.clearBackground(); } }); //视频准备完毕,可以进行播放 Log.e("(双面屏)TAG","准备好视频,开始播放"); - if( isPlay ){ - handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); - handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); - if(components.getConfig().isPlayAudio()){ - vView.setVolume(15f); - }else { - vView.setVolume(0f); - } - vView.start(); + + handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); + handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); + if(components.getConfig().isPlayAudio()){ + vView.setVolume(1.0f); }else { - vView.start(); vView.setVolume(0f); - //暂停播放 - if(vView == videoView2){ - handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); - handler.sendEmptyMessageDelayed(TYPE_STOP_VIDEO_PLAY0,5000); - }else{ - handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); - handler.sendEmptyMessageDelayed(TYPE_STOP_VIDEO_PLAY1,5000); - } } + vView.start(); } /** * 更新video @@ -2811,7 +2746,7 @@ class MyPresentation extends Presentation { handler.sendEmptyMessageDelayed(TYPE_UPDATE_VIDE,materials0.getDuration()*1000); try { if (videoView.isPlaying()) { - videoView.stopPlayback(); + videoView.pause(); } new Handler(Looper.getMainLooper()).postDelayed(() -> { try { @@ -2838,8 +2773,6 @@ class MyPresentation extends Presentation { videoView3.setLayoutParams(layoutParams); } - videoImg2.setVisibility(View.GONE); - videoImg3.setVisibility(View.GONE); handler.sendEmptyMessageDelayed(TYPE_UPDATE_VIDE,videoComponents.getConfig().getTransitionPeriod()*1000); Drawable drawable = new BitmapDrawable(localPath); videoView.setBackground(drawable); diff --git a/app/src/main/java/qianmu/container/activity/program/ScreenSaverActivity.java b/app/src/main/java/qianmu/container/activity/program/ScreenSaverActivity.java index 561fa9f..80b3391 100644 --- a/app/src/main/java/qianmu/container/activity/program/ScreenSaverActivity.java +++ b/app/src/main/java/qianmu/container/activity/program/ScreenSaverActivity.java @@ -100,7 +100,6 @@ public class ScreenSaverActivity extends BaseActivity { @Override public void handleMessage(@NonNull Message msg) { super.handleMessage(msg); - switch (msg.what) { case TYPE_HINT_PASSWORD: @@ -344,11 +343,11 @@ public class ScreenSaverActivity extends BaseActivity { LoggerUtil.e("ScreenSaverActivity", "诺瓦设备截屏"); Screenshot(message.getData()); } else if (Constant.NOVA_SCREEN_POWER_ON.equals(message.getCode())) { - LoggerUtil.e("ScreenSaverActivity", "诺瓦设备开屏"); - screenPower("OPEN"); + //LoggerUtil.e("ScreenSaverActivity", "诺瓦设备开屏"); + //screenPower("OPEN"); } else if (Constant.NOVA_SCREEN_POWER_CLOSE.equals(message.getCode())) { - LoggerUtil.e("ScreenSaverActivity", "诺瓦设备关屏"); - screenPower("CLOSE"); + //LoggerUtil.e("ScreenSaverActivity", "诺瓦设备关屏"); + //screenPower("CLOSE"); } } @@ -447,11 +446,9 @@ public class ScreenSaverActivity extends BaseActivity { @Override public void dataCallBack(int code, String data) { LoggerUtil.e("QHT: 搜索:", "code:" + code + ",data:" + data); - if (code == 0) { - NovaDeviceBean novaDeviceBean = new Gson().fromJson(data, NovaDeviceBean.class); - sn = novaDeviceBean.getSn(); - login(""); - } + NovaDeviceBean novaDeviceBean = new Gson().fromJson(data, NovaDeviceBean.class); + sn = novaDeviceBean.getSn(); + login(""); } }); } @@ -535,6 +532,14 @@ public class ScreenSaverActivity extends BaseActivity { @Override public void dataCallBack(int code, String data) { LoggerUtil.e("QHT: 开关屏:", "code:" + code + ",data:" + data); + if("CLOSE".equals(state)){ + MyApplication.getInstance().stopService(new Intent(MyApplication.getInstance(),MQTTService.class)); + }else{ + MyApplication.getInstance().startService(new Intent(MyApplication.getInstance(),MQTTService.class)); + } + if(code == 65350){ + login(state); + } } }); } diff --git a/app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java b/app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java index b67b1e7..f41c968 100644 --- a/app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java +++ b/app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java @@ -38,6 +38,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.airbnb.lottie.LottieAnimationView; +import com.aispeech.gourd.util.LogUtil; import com.alibaba.android.arouter.launcher.ARouter; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; @@ -155,8 +156,7 @@ public class ViewScreenSaver extends ViewBase { static final int TYPE_UPDATE_MACTH = 142;//匹配时间是否更新; static final int TYPE_DOWNLOAD_FILE = 143;//下载文件 static final int TYPE_GET_NEXT_OTHER_IMG = 144;//下个节目的图片 - static final int TYPE_STOP_VIDEO_PLAY0 = 145;//暂停播放 - static final int TYPE_STOP_VIDEO_PLAY1 = 146;//暂停播放 + static final int TYPE_HINT_IMG0 = 147;//隐藏额外图片 static final int TYPE_HINT_IMG1 = 148;//隐藏额外图片 static final int TYPE_HINT_IMG2 = 149;//隐藏额外图片 @@ -531,23 +531,8 @@ public class ViewScreenSaver extends ViewBase { //存在视频组件 String localPath = StringUtil.strSplice(Constant.CACHE_PATH, components.getMaterials().get(0).getFileUrl()); if(videoViewNumb==0){ - //第一个videoview - if(components.getMaterials().get(0).getDuration()>0){ - //视频 - - if(components.getMaterials().get(0).getPreviewUrl()!=null && !components.getMaterials().get(0).getPreviewUrl().isEmpty()){ - BitmapUtil.loadImage(downloadaddress, Constant.CACHE_PATH, components.getMaterials().get(0).getPreviewUrl(),binding.videoImg0); - } - - }else { - //图片 - if(new File(localPath).exists()){ - Glide.with(context).load(localPath).into(binding.videoImg0); - } - } if(!isNextVideo){ - Log.e("TAG: ","预览设置下个视频"); isNextVideo=true; if(components.getMaterials().get(0).getDuration()>0){ binding.videoView0.setVideoPath(localPath); @@ -558,28 +543,7 @@ public class ViewScreenSaver extends ViewBase { } } }else { - //第二个videoview - if(components.getMaterials().get(0).getDuration()>0){ - //视频 - - if(components.getMaterials().get(0).getPreviewUrl()!=null && !components.getMaterials().get(0).getPreviewUrl().isEmpty()){ - BitmapUtil.loadImage(downloadaddress, Constant.CACHE_PATH, components.getMaterials().get(0).getPreviewUrl(),binding.videoImg1); - } -// String[] b = localPath.split("\\."); -// String imgUrl = b[0]+".jpg"; -// if(new File(imgUrl).exists()){ -// binding.videoImg1.setVisibility(View.GONE); -// Glide.with(context).load(imgUrl).into(binding.videoImg1); -// } - }else { - //图片 - if(new File(localPath).exists()){ - Glide.with(context).load(localPath).into(binding.videoImg1); - } - } - if(!isNextVideo){ - Log.e("TAG: ","预览设置下个视频"); isNextVideo=true; if(components.getMaterials().get(0).getDuration()>0){ binding.videoView0.setVideoPath(localPath); @@ -650,20 +614,6 @@ public class ViewScreenSaver extends ViewBase { break; - case TYPE_STOP_VIDEO_PLAY0: - if(binding.videoView0.isPlaying()){ - binding.videoView0.pause(); - } - - break; - - case TYPE_STOP_VIDEO_PLAY1: - if(binding.videoView1.isPlaying()){ - binding.videoView1.pause(); - } - - break; - case TYPE_HINT_IMG0: binding.otherImg0.setVisibility(View.INVISIBLE); break; @@ -678,9 +628,7 @@ public class ViewScreenSaver extends ViewBase { break; case TYPE_UPDATE_MEIDA0://音频播放 - updateMedia(mediaComponents0); - break; case TYPE_UPDATE_IMAGE0: //图片切换 @@ -1549,8 +1497,6 @@ public class ViewScreenSaver extends ViewBase { handler.removeMessages(TYPE_CHANGE_IMG_SHOW14); handler.removeMessages(TYPE_CHANGE_IMG_SHOW15); handler.removeMessages(TYPE_UPDATE_TEXT4); - handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); - handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); handler.removeMessages(TYPE_REFRESH_WEBVIEW0); handler.removeMessages(TYPE_REFRESH_WEBVIEW1); handler.removeMessages(TYPE_REFRESH_WEBVIEW2); @@ -1848,21 +1794,6 @@ public class ViewScreenSaver extends ViewBase { startProgram(); } - /** - * 关闭 - * */ - public void stopScreen(){ - if(binding.videoImg0!=null){ - binding.videoImg0.setImageBitmap(null); - binding.videoImg0.setVisibility(View.GONE); - } - - if(binding.videoImg1!=null){ - binding.videoImg1.setImageBitmap(null); - binding.videoImg1.setVisibility(View.GONE); - } - } - //同屏视频 public void videoProgramByIndex(int index){ if(Constant.isMain || handler==null)return; @@ -2226,7 +2157,6 @@ public class ViewScreenSaver extends ViewBase { //视频控件 addVideoView(components,videoCount); videoCount++; - }else if(components.getTypeCode().equals("image")){ //图片控件 initImage(components,imageCount); @@ -2749,9 +2679,7 @@ public class ViewScreenSaver extends ViewBase { RelativeLayout.LayoutParams lParams = new RelativeLayout.LayoutParams(components.getWidth(), components.getHeight()); lParams.setMargins(components.getOffsetX(), components.getOffsetY(), 0, 0); if(position==0){ - isNextVideo = true; - isvideoPlay0 = true; binding.videoView0.pause(); binding.videoView0.seekTo(0); binding.layoutVideo0.setX(components.getOffsetX()); @@ -2763,12 +2691,11 @@ public class ViewScreenSaver extends ViewBase { binding.layoutVideo0.setVisibility(View.VISIBLE); binding.layoutVideo0.bringToFront(); handler.sendEmptyMessage(TYPE_UPDATE_VIDEO0); - binding.videoImg0.setVisibility(View.VISIBLE); binding.videoView0.setOnPreparedListener(new CustomerVideoView.OnPreparedListener() { @Override public void onPrepared() { - videoStartPlay(binding.videoView0, binding.videoImg0, videoComponents0, isvideoPlay0); + videoStartPlay(binding.videoView0, videoComponents0); } }); // 视频播放完成时的操作 @@ -2793,7 +2720,6 @@ public class ViewScreenSaver extends ViewBase { }else if(position==1){ - isvideoPlay1 = true; binding.layoutVideo1.setX(components.getOffsetX()); binding.layoutVideo1.setY(components.getOffsetY()); ViewGroup.LayoutParams layoutParams = binding.layoutVideo1.getLayoutParams(); @@ -2810,11 +2736,11 @@ public class ViewScreenSaver extends ViewBase { videoComponents1 = components; handler.sendEmptyMessage(TYPE_UPDATE_VIDEO1); - + binding.videoView1.setOnPreparedListener(new CustomerVideoView.OnPreparedListener() { @Override public void onPrepared() { - videoStartPlay(binding.videoView1, binding.videoImg1, videoComponents1,isvideoPlay1); + videoStartPlay(binding.videoView1, videoComponents1); } }); @@ -2839,39 +2765,21 @@ public class ViewScreenSaver extends ViewBase { } } - private void videoStartPlay(CustomerVideoView vView, ImageView imgView, NewProgramBean.components components, Boolean isPlay){ + private void videoStartPlay(CustomerVideoView vView, NewProgramBean.components components){ vView.setOnInfoListener(new CustomerVideoView.OnInfoListener() { @Override public void onInfo() { vView.clearBackground(); - imgView.setVisibility(View.GONE); } }); //视频准备完毕,可以进行播放 - if( isPlay ){ - handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); - handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); - if(components.getConfig().isPlayAudio()){ - vView.setVolume(15f); - }else { - vView.setVolume(0f); - } - vView.start(); + if(components.getConfig().isPlayAudio()){ + vView.setVolume(1.0f); }else { - vView.start(); vView.setVolume(0f); - //暂停播放 - if(vView == binding.videoView0){ - handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); - handler.sendEmptyMessageDelayed(TYPE_STOP_VIDEO_PLAY0,5000); - }else{ - handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); - handler.sendEmptyMessageDelayed(TYPE_STOP_VIDEO_PLAY1,5000); - } - } - + vView.start(); } /** @@ -2893,6 +2801,7 @@ public class ViewScreenSaver extends ViewBase { NewProgramBean.materials materials0 = videoComponents.getMaterials().get(videoPlayCount); String localPath = StringUtil.strSplice(Constant.CACHE_PATH, materials0.getFileUrl()); if (!new File(localPath).exists()) { + FileUtil.downloadFile(downloadaddress + materials0.getFileUrl(), localPath); handler.sendEmptyMessageDelayed(TYPE_UPDATE_VIDE,2000); return; @@ -2908,7 +2817,6 @@ public class ViewScreenSaver extends ViewBase { try { if (videoView.isPlaying()) { videoView.pause(); - videoView.stopPlayback(); } new Handler(Looper.getMainLooper()).postDelayed(() -> { try { @@ -2927,22 +2835,17 @@ public class ViewScreenSaver extends ViewBase { layoutParams.height = videoComponents.getHeight(); layoutParams.width = videoComponents.getWidth(); binding.videoView0.setLayoutParams(layoutParams); - binding.videoImg0.setVisibility(View.GONE); }else if(TYPE_UPDATE_VIDE==TYPE_UPDATE_VIDEO1){ ViewGroup.LayoutParams layoutParams = binding.videoView1.getLayoutParams(); layoutParams.height = videoComponents.getHeight(); layoutParams.width = videoComponents.getWidth(); binding.videoView1.setLayoutParams(layoutParams); - binding.videoImg1.setVisibility(View.GONE); } handler.sendEmptyMessageDelayed(TYPE_UPDATE_VIDE,videoComponents.getConfig().getTransitionPeriod()*1000); Drawable drawable = new BitmapDrawable(localPath); videoView.setBackground(drawable); -// Bitmap bitmap = BitmapFactory.decodeFile(localPath); -// WeakReference weakBitmap = new WeakReference<>(bitmap); -// videoView.setBackground(new BitmapDrawable(context.getResources(), weakBitmap.get())); } } diff --git a/app/src/main/java/qianmu/container/app/MyApplication.java b/app/src/main/java/qianmu/container/app/MyApplication.java index ed1ef8c..8bd6055 100644 --- a/app/src/main/java/qianmu/container/app/MyApplication.java +++ b/app/src/main/java/qianmu/container/app/MyApplication.java @@ -84,11 +84,15 @@ public class MyApplication extends Application { return myApplication; } - @Override public void onCreate() { super.onCreate(); myApplication = this; + try { + Thread.sleep(6000); + } catch (InterruptedException e) { + e.printStackTrace(); + } initARouter(); initOkGo(); SocketServerManager.startSocketServer(); @@ -116,19 +120,24 @@ public class MyApplication extends Application { @Override public void onActivityPaused(Activity activity) { + } + + @Override + public void onActivityStopped(Activity activity) { if (mCurrentActivity == activity) { mCurrentActivity = null; } } - @Override - public void onActivityStopped(Activity activity) {} - @Override public void onActivitySaveInstanceState(Activity activity, Bundle outState) {} @Override - public void onActivityDestroyed(Activity activity) { } + public void onActivityDestroyed(Activity activity) { + if (mCurrentActivity == activity) { + mCurrentActivity = null; + } + } }); } diff --git a/app/src/main/java/qianmu/container/mqtt/MQTTService.java b/app/src/main/java/qianmu/container/mqtt/MQTTService.java index fc9a50e..85dd863 100644 --- a/app/src/main/java/qianmu/container/mqtt/MQTTService.java +++ b/app/src/main/java/qianmu/container/mqtt/MQTTService.java @@ -150,7 +150,7 @@ public class MQTTService extends Service { userName= DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_CODE); if(Constant.tywx){ passWord= AesUtil.md5(DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_MAC, SignWayUtil.getEthMacAddress())); - Log.e("MQTTService","passWord:"+passWord); + LoggerUtil.e("MQTTService","passWord:"+passWord); }else { passWord= MqttData.getMqttToken().getPassword(); } @@ -337,7 +337,6 @@ public class MQTTService extends Service { } connectionLostTime = time; LoggerUtil.e(TAG, " 失去连接: 时间:"+connectionLostTime+",次数:"+connectionLostNumb); -// LoggerUtil.e(TAG, " 失去连接 "); } }; @@ -705,24 +704,26 @@ public class MQTTService extends Service { }else{ screenshotFuture = singleThreadExecutor.submit(() -> { View decorView = MyApplication.getInstance().getCurrentActivity().getWindow().getDecorView(); - decorView.setDrawingCacheEnabled(true); - decorView.buildDrawingCache(); - Bitmap bmp = decorView.getDrawingCache(); - Rect frame = new Rect(); - decorView.getWindowVisibleDisplayFrame(frame); - int statusBarHeight = frame.top; - Bitmap screenBitmap = Bitmap.createBitmap(bmp, 0, statusBarHeight, decorView.getWidth(), decorView.getHeight() - statusBarHeight); - decorView.setDrawingCacheEnabled(false); - //保存 - try (FileOutputStream fos = new FileOutputStream(file)) { - screenBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); - fos.flush(); - } catch (IOException e) { - e.printStackTrace(); - } - if(new File(path).exists()){ - LoggerUtil.e("screenShot","截屏完成"); - return true; + if(decorView != null){ + decorView.setDrawingCacheEnabled(true); + decorView.buildDrawingCache(); + Bitmap bmp = decorView.getDrawingCache(); + Rect frame = new Rect(); + decorView.getWindowVisibleDisplayFrame(frame); + int statusBarHeight = frame.top; + Bitmap screenBitmap = Bitmap.createBitmap(bmp, 0, statusBarHeight, decorView.getWidth(), decorView.getHeight() - statusBarHeight); + decorView.setDrawingCacheEnabled(false); + //保存 + try (FileOutputStream fos = new FileOutputStream(file)) { + screenBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); + fos.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + if(new File(path).exists()){ + LoggerUtil.e("screenShot","截屏完成"); + return true; + } } return false; }); diff --git a/app/src/main/java/qianmu/container/util/SignWayUtil.java b/app/src/main/java/qianmu/container/util/SignWayUtil.java index 9c50bb1..2c458ed 100644 --- a/app/src/main/java/qianmu/container/util/SignWayUtil.java +++ b/app/src/main/java/qianmu/container/util/SignWayUtil.java @@ -390,12 +390,6 @@ public class SignWayUtil { zcapi zcApi=new zcapi(); zcApi.getContext(MyApplication.getInstance()); return zcApi.getEthMacAddress("eth0"); - }else if(Constant.androidBoardType.equals("nova")){ - String mac = DeviceUtil.getLanMac(); - if(StringUtil.isEmpty(mac)){ - mac = DeviceUtil.getMacFromHardware(); - } - return mac; }else if(Constant.androidBoardType.equals("huidu")){ HuiduTech helper = new HuiduTech(MyApplication.getInstance()); @@ -407,9 +401,12 @@ public class SignWayUtil { LoggerUtil.e("getEthMacAddress", "wifimac:" + helper.getWifiMac()); return helper.getWifiMac(); } - } - else { - return DeviceUtil.getMacFromHardware(); + }else { + String mac = DeviceUtil.getLanMac(); + if(StringUtil.isEmpty(mac)){ + mac = DeviceUtil.getMacFromHardware(); + } + return mac; } } catch (Throwable t) { diff --git a/app/src/main/res/layout/presentation.xml b/app/src/main/res/layout/presentation.xml index e9604f0..4ac86c5 100644 --- a/app/src/main/res/layout/presentation.xml +++ b/app/src/main/res/layout/presentation.xml @@ -30,12 +30,7 @@ android:layout_height="match_parent" android:id="@+id/videoView2" /> - + @@ -46,18 +41,12 @@ android:gravity="center" android:visibility="gone"> - - +