| | |
| | | import android.net.ConnectivityManager; |
| | | import android.net.NetworkInfo; |
| | | import android.os.Bundle; |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | |
| | |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | | /** |
| | | * 视频播放前贴广告 |
| | |
| | | |
| | | private NativeUnifiedADData mGDTAdData; |
| | | |
| | | |
| | | private LinearLayout ll_skip; |
| | | |
| | | private TextView tv_skip; |
| | | |
| | | private TextView tv_no_ad_reward; |
| | | private TextView tv_action; |
| | | |
| | | private View v_cutline; |
| | | |
| | | private ProgressBar pb_progress; |
| | | |
| | |
| | | mContainer = root.findViewById(R.id.native_ad_container); |
| | | img_poster = root.findViewById(R.id.img_poster); |
| | | tv_skip = root.findViewById(R.id.tv_skip); |
| | | tv_no_ad_reward = root.findViewById(R.id.tv_no_ad_reward); |
| | | ll_skip = root.findViewById(R.id.ll_skip); |
| | | tv_action = root.findViewById(R.id.tv_action); |
| | | v_cutline = root.findViewById(R.id.v_cutline); |
| | | pb_progress = root.findViewById(R.id.pb_progress); |
| | | fl_ad = root.findViewById(R.id.fl_ad); |
| | | } |
| | |
| | | tv_skip.setText("跳过"); |
| | | tv_skip.setClickable(true); |
| | | } |
| | | tv_skip.setVisibility(View.VISIBLE); |
| | | ll_skip.setVisibility(View.VISIBLE); |
| | | autoTimer(view); |
| | | } |
| | | }; |
| | |
| | | Log.i(TAG, "loadVideoAD"); |
| | | if (tv_skip == null) |
| | | return; |
| | | tv_skip.setVisibility(View.GONE); |
| | | ll_skip.setVisibility(View.GONE); |
| | | if (mGDTAdData != null) |
| | | mGDTAdData.destroy(); |
| | | pb_progress.setVisibility(View.VISIBLE); |
| | |
| | | pid = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | |
| | | tv_skip.setText(AD_DURATION + "s后可跳过"); |
| | | tv_skip.setVisibility(View.GONE); |
| | | if (setting.isNeedShowRewardNotify()) { |
| | | tv_no_ad_reward.setVisibility(View.VISIBLE); |
| | | ll_skip.setVisibility(View.GONE); |
| | | if (!StringUtils.isNullOrEmpty(setting.getOtherAction())) { |
| | | tv_action.setVisibility(View.VISIBLE); |
| | | v_cutline.setVisibility(View.VISIBLE); |
| | | tv_action.setText(setting.getOtherAction()); |
| | | } else { |
| | | tv_no_ad_reward.setVisibility(View.GONE); |
| | | tv_action.setVisibility(View.GONE); |
| | | v_cutline.setVisibility(View.GONE); |
| | | } |
| | | tv_no_ad_reward.setOnClickListener(new View.OnClickListener() { |
| | | tv_action.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (videoAdListener != null) |
| | | videoAdListener.noAdRewardClick(); |
| | | videoAdListener.onOtherClick(tv_action.getText() + ""); |
| | | } |
| | | }); |
| | | // loadCSJ(CSJConstant.PLAY_VIDEO_PRE, videoAdListener); |
| | |
| | | @Override |
| | | public void onVideoCompleted() { |
| | | Log.d(TAG, "onVideoCompleted: "); |
| | | tv_skip.setVisibility(View.GONE); |
| | | ll_skip.setVisibility(View.GONE); |
| | | if (videoAdListener != null) { |
| | | videoAdListener.finishPlay(); |
| | | } |
| | |
| | | mGDTAdData.stopVideo(); |
| | | if (videoAdListener != null) |
| | | videoAdListener.finishPlay(); |
| | | tv_skip.setVisibility(View.GONE); |
| | | ll_skip.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | } |
| | |
| | | //开始播放 |
| | | public void startPlay(); |
| | | |
| | | //免广告权益 |
| | | public void noAdRewardClick(); |
| | | //附加字段点击事件 |
| | | public void onOtherClick(String name); |
| | | |
| | | } |
| | | |