1717import java .util .HashMap ;
1818import java .util .Map ;
1919
20+ import cn .com .venvy .common .utils .VenvyResourceUtil ;
2021import cn .com .venvy .common .utils .VenvyUIUtil ;
2122
2223/**
2324 * Created by Lucas on 2019/7/31.
24- * 视联网小程序容器
25- * <p>
26- * A类小程序 LuaView://defaultLuaView?template=xxx.lua&id=xxx
27- * 跳转B类小程序 LuaView://applets?appletId=xxxx&type=x(type: 1横屏,2竖屏)
28- * <p>
29- * B类小程序容器内部跳转 LuaView://applets?appletId=xxxx&template=xxxx.lua&id=xxxx&(priority=x)
3025 */
3126public class VideoProgramTypeBView extends FrameLayout {
3227
28+ /**
29+ * 视联网小程序容器
30+ * <p>
31+ * A类小程序 LuaView://defaultLuaView?template=xxx.lua&id=xxx
32+ * 跳转B类小程序 LuaView://applets?appletId=xxxx&type=x(type: 1横屏,2竖屏)
33+ * <p>
34+ * B类小程序容器内部跳转 LuaView://applets?appletId=xxxx&template=xxxx.lua&id=xxxx&(priority=x)
35+ */
36+
3337 /**
3438 * 会有多个B类小程序侧边栏覆盖的情况,所以需要一个Map统一管理
3539 */
@@ -52,23 +56,26 @@ public VideoProgramTypeBView(@NonNull Context context, @Nullable AttributeSet at
5256 init ();
5357 }
5458
55- public VideoProgramTypeBView (@ NonNull Context context , @ Nullable AttributeSet attrs , int defStyleAttr ) {
59+ public VideoProgramTypeBView (@ NonNull Context context , @ Nullable AttributeSet attrs ,
60+ int defStyleAttr ) {
5661 super (context , attrs , defStyleAttr );
5762 init ();
5863 }
5964
6065 @ TargetApi (21 )
61- public VideoProgramTypeBView (@ NonNull Context context , @ Nullable AttributeSet attrs , int defStyleAttr , int defStyleRes ) {
66+ public VideoProgramTypeBView (@ NonNull Context context , @ Nullable AttributeSet attrs ,
67+ int defStyleAttr , int defStyleRes ) {
6268 super (context , attrs , defStyleAttr , defStyleRes );
6369 init ();
6470 }
6571
6672 private void init () {
67- inflate (getContext (), R . layout . video_program_type_b , this );
73+ inflate (getContext (), VenvyResourceUtil . getLayoutId ( getContext (), " video_program_type_b" ) , this );
6874 // for test
6975// setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.holo_red_light));
7076// setAlpha(0.5f);
71- programContent = (FrameLayout ) findViewById (R .id .programContent );
77+ programContent = (FrameLayout ) findViewById (
78+ VenvyResourceUtil .getId (getContext (), "programContent" ));
7279
7380 setOnClickListener (new OnClickListener () {
7481 @ Override
@@ -89,7 +96,8 @@ public VideoProgramToolBarView createProgram(int orientationType) {
8996
9097 private VideoProgramToolBarView generateVideoProgram () {
9198 VideoProgramToolBarView programToolBarView = new VideoProgramToolBarView (getContext ());
92- programToolBarView .setLayoutParams (new LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , ViewGroup .LayoutParams .MATCH_PARENT ));
99+ programToolBarView .setLayoutParams (new LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT ,
100+ ViewGroup .LayoutParams .MATCH_PARENT ));
93101 return programToolBarView ;
94102 }
95103
@@ -122,7 +130,7 @@ public void start(@NonNull String appletId, String data, int orientationType) {
122130 *
123131 * @param appletId
124132 */
125- public void close ( String appletId ) {
133+ public void close (String appletId ) {
126134 if (!TextUtils .isEmpty (appletId )) {
127135 VideoProgramToolBarView programView = programMap .get (appletId );
128136 if (programView != null ) {
@@ -147,26 +155,27 @@ public void closeAllProgram() {
147155
148156 /**
149157 * 删除所有指定方向的视联网小程序
158+ *
150159 * @param orientationType
151160 */
152- public void closeAllProgramByOrientation (int orientationType ){
161+ public void closeAllProgramByOrientation (int orientationType ) {
153162 for (Map .Entry <String , VideoProgramToolBarView > item : programMap .entrySet ()) {
154- if ((int )item .getValue ().getTag () == orientationType ){
155- programContent .removeView (item .getValue ());
156- programMap .remove (item .getKey ());
157- }
163+ if ((int ) item .getValue ().getTag () == orientationType ) {
164+ programContent .removeView (item .getValue ());
165+ programMap .remove (item .getKey ());
166+ }
158167 }
159168 }
160169
161170
162171 public void showExceptionLogic (String msg , boolean needRetry ) {
163172 if (currentProgram != null ) {
164- currentProgram .showExceptionLogic (msg ,needRetry );
173+ currentProgram .showExceptionLogic (msg , needRetry );
165174 }
166175 }
167176
168177
169- public void setCurrentProgramTitle (String title ){
178+ public void setCurrentProgramTitle (String title ) {
170179 if (currentProgram != null ) {
171180 currentProgram .setTitle (title );
172181 }
@@ -179,13 +188,15 @@ private void checkVisionProgram() {
179188
180189
181190 private void doEntranceAnimation (View view ) {
182- ValueAnimator valueAnimator = ObjectAnimator .ofFloat (view , "translationX" , VenvyUIUtil .dip2px (getContext (), 222 ), 0 );
191+ ValueAnimator valueAnimator = ObjectAnimator .ofFloat (view , "translationX" ,
192+ VenvyUIUtil .dip2px (getContext (), 222 ), 0 );
183193 valueAnimator .setDuration (300 );
184194 valueAnimator .start ();
185195 }
186196
187- private void doExitAnimation (final View view ){
188- ValueAnimator valueAnimator = ObjectAnimator .ofFloat (view , "translationX" , 0 , VenvyUIUtil .dip2px (getContext (), 222 ));
197+ private void doExitAnimation (final View view ) {
198+ ValueAnimator valueAnimator = ObjectAnimator .ofFloat (view , "translationX" , 0 ,
199+ VenvyUIUtil .dip2px (getContext (), 222 ));
189200 valueAnimator .setDuration (300 );
190201 valueAnimator .addListener (new AnimatorListenerAdapter () {
191202 @ Override
0 commit comments