Skip to content

Commit 23a6763

Browse files
author
videopls
committed
把资源建立放到VideoPlusView.start(),把资源释放放到VideoPlusView.stop()中
1 parent 0ba3bfd commit 23a6763

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ protected void navigation(Uri uri, HashMap<String, String> params, IRouterCallba
401401
return;
402402
}
403403

404+
if (mContentView.getVisibility() == View.GONE || mContentView.getVisibility() == View.INVISIBLE) {
405+
mContentView.setVisibility(View.VISIBLE);
406+
}
407+
404408
mPlatform = initPlatform(mVideoPlusAdapter);
405409

406410
PostInfo postInfo = VenvyRouterManager.getInstance().setUri(uri)
@@ -764,9 +768,7 @@ public void refreshRecentHistory(String appId) {
764768
}
765769

766770
public void downloadAdsRes(Bundle bundle) {
767-
if (this.mPlatform == null) {
768-
this.mPlatform = initPlatform(mVideoPlusAdapter);
769-
}
771+
this.mPlatform = initPlatform(mVideoPlusAdapter);
770772
if (videoAdsHandler == null) {
771773
videoAdsHandler = new VideoAdsHandler(mPlatform);
772774
}

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

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
public abstract class VideoPlusView<T extends VideoPlusController> extends FrameLayout {
3535

36-
3736
// 顶层小程序容器 4
3837
protected VideoProgramView programTopLevel;
3938
// A 类小程序 0,1
@@ -52,39 +51,15 @@ public abstract class VideoPlusView<T extends VideoPlusController> extends Frame
5251
private Pair<Float, Float> videoModeDeskOffset; // 视联网模式桌面偏移量
5352

5453
public VideoPlusView(Context context) {
55-
super(context);
56-
init();
54+
this(context,null);
5755
}
5856

5957
public VideoPlusView(Context context, AttributeSet attrs) {
60-
super(context, attrs);
61-
init();
58+
this(context, attrs, 0);
6259
}
6360

6461
public VideoPlusView(Context context, AttributeSet attrs, int defStyleAttr) {
6562
super(context, attrs, defStyleAttr);
66-
init();
67-
}
68-
69-
70-
@Override
71-
protected void onDetachedFromWindow() {
72-
super.onDetachedFromWindow();
73-
if (plusViewHelper != null) {
74-
plusViewHelper.detachedFromWindow();
75-
}
76-
}
77-
78-
@Override
79-
protected void onConfigurationChanged(Configuration newConfig) {
80-
super.onConfigurationChanged(newConfig);
81-
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
82-
// 手机竖屏
83-
84-
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
85-
// 手机横屏
86-
87-
}
8863
}
8964

9065
private void init() {
@@ -96,6 +71,7 @@ private void init() {
9671
addView(programViewB);
9772
addView(programTopLevel);
9873
programViewB.setClickable(false);
74+
initViewAdapter();
9975
}
10076

10177
/**
@@ -107,7 +83,6 @@ private VideoProgramView createTypeAProgram() {
10783
return new VideoProgramView(getContext());
10884
}
10985

110-
11186
/**
11287
* 生成B类小程序容器
11388
*
@@ -190,6 +165,10 @@ public void closeInfoView() {
190165
}
191166

192167
public void setVideoOSAdapter(VideoPlusAdapter adapter) {
168+
this.adapter = adapter;
169+
}
170+
171+
private void initViewAdapter() {
193172
if (programTopLevel != null) {
194173
programTopLevel.setVideoOSAdapter(adapter);
195174
}
@@ -199,39 +178,46 @@ public void setVideoOSAdapter(VideoPlusAdapter adapter) {
199178
if (programViewB != null) {
200179
programViewB.setVideoOSAdapter(adapter);
201180
}
202-
this.adapter = adapter;
203181
}
204182

205183
public VideoPlusAdapter getAdapter() {
206184
return adapter;
207185
}
208186

209187
public void start() {
188+
init();
210189
if (programViewA != null) {
211190
programViewA.start();
212191
}
213192
}
214193

215194
public void stop() {
195+
if (plusViewHelper != null) {
196+
plusViewHelper.detachedFromWindow();
197+
plusViewHelper = null;
198+
}
199+
216200
if (programViewA != null) {
217201
programViewA.stop();
218202
VideoPositionHelper.getInstance().cancel();
203+
programViewA = null;
219204
}
220205

221206
if (programViewB != null) {
222207
programViewB.closeAllProgram();
223-
// programViewB = null;
208+
programViewB = null;
224209
}
225210

226211
if (programTopLevel != null) {
227212
programTopLevel.stop();
228-
// programTopLevel = null;
213+
programTopLevel = null;
229214
}
230215

231216
if (programViewDesktop != null) {
232217
programViewDesktop.stop();
233218
programViewDesktop = null;
234219
}
220+
this.removeAllViews();
235221
}
236222

237223
/**

0 commit comments

Comments
 (0)