3333
3434public 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