|
|
@@ -0,0 +1,186 @@
|
|
|
+package com.jld.vod.view.widget;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.app.Dialog;
|
|
|
+import android.content.Context;
|
|
|
+import android.media.MediaPlayer;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.CountDownTimer;
|
|
|
+import android.view.MotionEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.view.Window;
|
|
|
+import android.view.WindowManager;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+import android.widget.VideoView;
|
|
|
+
|
|
|
+import com.jld.vod.R;
|
|
|
+import com.jld.vod.config.Config;
|
|
|
+import com.jld.vod.model.bean.Datas;
|
|
|
+import com.youth.banner.Banner;
|
|
|
+import com.youth.banner.BannerConfig;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public class CustomVideoGEOAdDialog
|
|
|
+ extends Dialog
|
|
|
+{
|
|
|
+
|
|
|
+ //private ImageView mCloseImg;
|
|
|
+ private TextView auto_ms_text;
|
|
|
+ private VideoView vd_geo_ad;
|
|
|
+ private List<String> list = new ArrayList<>();
|
|
|
+ private Context mContext;
|
|
|
+ public OnClickBottomListener onClickBottomListener;
|
|
|
+
|
|
|
+
|
|
|
+ public CustomVideoGEOAdDialog(Context paramContext)
|
|
|
+ {
|
|
|
+ super(paramContext, R.style.MyDialog);
|
|
|
+ this.mContext = paramContext;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void dismiss() {
|
|
|
+ super.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initEvent()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initView()
|
|
|
+ {
|
|
|
+
|
|
|
+ this.auto_ms_text = findViewById(R.id.auto_ms_text);
|
|
|
+
|
|
|
+ //轮播
|
|
|
+ this.vd_geo_ad = (VideoView)findViewById(R.id.vd_geo_ad);
|
|
|
+ vd_geo_ad.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //videoview全屏拉伸
|
|
|
+ RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
|
|
|
+ layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
|
|
+ layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
|
|
+ layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
|
|
|
+ layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
|
|
+ vd_geo_ad.setLayoutParams(layoutParams);
|
|
|
+
|
|
|
+ if (list != null)
|
|
|
+ {
|
|
|
+ vd_geo_ad.setVideoPath(list.get(0));
|
|
|
+ vd_geo_ad.start();
|
|
|
+ //循环播放
|
|
|
+ vd_geo_ad.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
|
|
+ @Override
|
|
|
+ public void onPrepared(MediaPlayer mp) {
|
|
|
+ mp.start();
|
|
|
+ mp.setLooping(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void show() {
|
|
|
+
|
|
|
+ /** 倒计时30秒,一次1秒 */
|
|
|
+ CountDownTimer timer = new CountDownTimer(30*1000, 1000) {
|
|
|
+ @Override
|
|
|
+ public void onTick(long millisUntilFinished) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ auto_ms_text.setText(millisUntilFinished/1000+"");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ vd_geo_ad.stopPlayback();
|
|
|
+ auto_ms_text.setText("0");
|
|
|
+ dismiss();
|
|
|
+ }
|
|
|
+ }.start();
|
|
|
+ super.show();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置数据
|
|
|
+ * @param positionAdvert
|
|
|
+ */
|
|
|
+ public void setDataList(List<Datas> positionAdvert)
|
|
|
+ {
|
|
|
+ list.clear();
|
|
|
+ for (int i = 0;i<positionAdvert.size();i++)
|
|
|
+ {
|
|
|
+ list.add(Config.ApiBaseUrl + "/synchronization/previewImg?imgUrl=" + positionAdvert.get(i).getFilePath());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("WrongConstant")
|
|
|
+ private void refreshView()
|
|
|
+ {
|
|
|
+
|
|
|
+// if (!TextUtils.isEmpty(this.tv_ok)) {
|
|
|
+// this.mBtnOk.setText(this.tv_ok);
|
|
|
+// }
|
|
|
+// if (!TextUtils.isEmpty(this.tv_no)) {
|
|
|
+// this.mBtnNo.setText(this.tv_no);
|
|
|
+// }
|
|
|
+// Button localButton = this.mBtnNo;
|
|
|
+// if (this.visiable) {}
|
|
|
+// for (int i = 0;; i = 8)
|
|
|
+// {
|
|
|
+// localButton.setVisibility(i);
|
|
|
+// if (!TextUtils.isEmpty(this.tv_cus))
|
|
|
+// {
|
|
|
+// this.mBtnCus.setText(this.tv_cus);
|
|
|
+// this.mBtnCus.setVisibility(View.VISIBLE);
|
|
|
+// }
|
|
|
+// return;
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void onCreate(Bundle paramBundle)
|
|
|
+ {
|
|
|
+ super.onCreate(paramBundle);
|
|
|
+ setContentView(R.layout.custom_video_geo_ad_dialog);
|
|
|
+ setCanceledOnTouchOutside(false);
|
|
|
+ Window w = getWindow();
|
|
|
+// int width = 850;
|
|
|
+// int height = 600;
|
|
|
+// w.setLayout(width,height);
|
|
|
+ w.setGravity(17);
|
|
|
+ WindowManager.LayoutParams localLayoutParams = w.getAttributes();
|
|
|
+
|
|
|
+ localLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
|
|
|
+ localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
|
|
+
|
|
|
+ w.setWindowAnimations(R.style.AnimationDialog);
|
|
|
+ w.setAttributes(localLayoutParams);
|
|
|
+
|
|
|
+ initView();
|
|
|
+ refreshView();
|
|
|
+ initEvent();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public CustomVideoGEOAdDialog setOnClickBottomListener(OnClickBottomListener paramOnClickBottomListener)
|
|
|
+ {
|
|
|
+ this.onClickBottomListener = paramOnClickBottomListener;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static abstract interface OnClickBottomListener
|
|
|
+ {
|
|
|
+ public abstract void onBtnCloseClick();
|
|
|
+ }
|
|
|
+}
|