Skip to content

Commit e24cf45

Browse files
author
lucas
committed
优化视联网模式开关逻辑
1 parent 67f2ff3 commit e24cf45

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VideoPlusView.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public abstract class VideoPlusView<T extends VideoPlusController> extends Frame
3232

3333
private VideoPlusViewHelper plusViewHelper;
3434

35+
private VideoPlusAdapter adapter;
36+
3537
public VideoPlusView(Context context) {
3638
super(context);
3739
init();
@@ -73,10 +75,8 @@ private void init() {
7375

7476
programViewA = createTypeAProgram();
7577
programViewB = createTypeBProgram();
76-
programViewDesktop = createDesktopProgram();
7778
addView(programViewA);
7879
addView(programViewB);
79-
addView(programViewDesktop);
8080
programViewB.setClickable(false);
8181
}
8282

@@ -99,8 +99,8 @@ private VideoProgramTypeBView createTypeBProgram() {
9999
return new VideoProgramTypeBView(getContext());
100100
}
101101

102-
private VideoProgramView createDesktopProgram(){
103-
return new VideoProgramView(getContext());
102+
private VideoProgramView createDesktopProgram() {
103+
return new VideoProgramView(getContext());
104104
}
105105

106106
/**
@@ -119,9 +119,9 @@ public void clearAllVisionProgram() {
119119
* @param msg
120120
* @param needRetry
121121
*/
122-
public void showExceptionLogic(String msg, boolean needRetry,String data) {
122+
public void showExceptionLogic(String msg, boolean needRetry, String data) {
123123
if (programViewB != null) {
124-
programViewB.showExceptionLogic(msg, needRetry,data);
124+
programViewB.showExceptionLogic(msg, needRetry, data);
125125
}
126126

127127
}
@@ -169,9 +169,7 @@ public void setVideoOSAdapter(VideoPlusAdapter adapter) {
169169
if (programViewB != null) {
170170
programViewB.setVideoOSAdapter(adapter);
171171
}
172-
if(programViewDesktop != null){
173-
programViewDesktop.setVideoOSAdapter(adapter);
174-
}
172+
this.adapter = adapter;
175173
}
176174

177175
public void start() {
@@ -220,8 +218,16 @@ public void launchH5VisionProgram(String url) {
220218
}
221219

222220

223-
public void launchDesktopProgram(String targetName){
224-
if(programViewDesktop != null && !TextUtils.isEmpty(targetName)) {
221+
public void launchDesktopProgram(String targetName) {
222+
// 桌面存在则不需要重复加载桌面
223+
if(programViewDesktop != null) return;
224+
225+
programViewDesktop = createDesktopProgram();
226+
if(adapter != null){
227+
programViewDesktop.setVideoOSAdapter(adapter);
228+
}
229+
addView(programViewDesktop);
230+
if (!TextUtils.isEmpty(targetName)) {
225231
programViewDesktop.setVisibility(VISIBLE);
226232
Uri uri = Uri.parse("LuaView://desktopLuaView?template=" + targetName + "&id=" + targetName.substring(0, targetName.lastIndexOf(".")));
227233
programViewDesktop.navigation(uri, new HashMap<String, String>(), null);
@@ -265,10 +271,12 @@ public void stopService(ServiceType serviceType) {
265271
programViewA.stopService(serviceType);
266272
}
267273

268-
if(serviceType == ServiceType.ServiceTypeVideoMode){
269-
// 如果是关闭视联网模式,则隐藏视联网桌面
270-
if(programViewDesktop != null){
274+
if (serviceType == ServiceType.ServiceTypeVideoMode) {
275+
// 如果是关闭视联网模式,则移除视联网桌面
276+
if (programViewDesktop != null) {
271277
programViewDesktop.setVisibility(GONE);
278+
removeView(programViewDesktop);
279+
programViewDesktop = null;
272280
}
273281
}
274282
}

0 commit comments

Comments
 (0)