Commit e4e5a11c authored by mengcuiguang's avatar mengcuiguang

添加广告

parent accced25
......@@ -25,6 +25,7 @@ public class AppConfig {
public static boolean enterVipAct = false;
public static boolean enterAlipay = false;
public static boolean showVipVedio = false;
public static boolean showVipAdDialog = false;
public static long splashTime = 0L;
public static double firstVipPrice = 0.0;
......
......@@ -60,7 +60,7 @@ class GuideActivity : BaseActivity() {
readyGoThenKill(MainActivity::class.java)
} else {
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_GUIDE, true)
// bundle.putBoolean(VipActivity.IS_GUIDE, true)
readyGoThenKill(VipActivity::class.java, bundle)
}
//带点渐变动画
......
package com.duben.xixiplaylet.ui.widgets
import android.app.Dialog
import android.content.Context
import android.os.Handler
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.duben.xixiplaylet.R
import com.duben.xixiplaylet.ui.widgets.countdowntimer.CountDownTimerSupport
import com.duben.xixiplaylet.ui.widgets.countdowntimer.OnCountDownTimerListener
import com.duben.xixiplaylet.utils.SpanUtils
import com.duben.xixiplaylet.utils.TimeRender
import java.util.*
class DetailAdDialog(private val context: Context, private val listener: DialogListener) :
Dialog(
context, R.style.dialog
) {
private val lp: WindowManager.LayoutParams
private val iv_agreement_quit: ImageView
private val tv_detail_ad_next: TextView
private val tv_rule_date1: TextView
private val tv_rule_date2: TextView
init {
setContentView(R.layout.dialog_detail_ad)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.BOTTOM
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { dialogInterface, i, keyEvent ->
if (i == KeyEvent.KEYCODE_BACK) {
true
} else false
}
// 查找View
tv_detail_ad_next = findViewById<View>(R.id.tv_agreement_next) as TextView
iv_agreement_quit = findViewById<View>(R.id.iv_agreement_quit) as ImageView
tv_rule_date1 = findViewById<View>(R.id.tv_rule_date1) as TextView
tv_rule_date2 = findViewById<View>(R.id.tv_rule_date2) as TextView
iv_agreement_quit.setOnClickListener(listener)
tv_detail_ad_next.setOnClickListener(listener)
}
}
\ No newline at end of file
......@@ -2,6 +2,9 @@ package com.duben.xixiplaylet.video.tx
import android.app.Dialog
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.view.View
import com.google.gson.Gson
import com.duben.xixiplaylet.R
......@@ -21,15 +24,13 @@ import com.duben.xixiplaylet.ui.activitys.NineActivity
import com.duben.xixiplaylet.ui.activitys.VipActivity
import com.duben.xixiplaylet.ui.activitys.base.BaseActivity
import com.duben.xixiplaylet.ui.adapter.VideoEpisodeAdapter
import com.duben.xixiplaylet.ui.widgets.DialogListener
import com.duben.xixiplaylet.ui.widgets.VideoEpisodeDialog
import com.duben.xixiplaylet.ui.widgets.VipCountDialog
import com.duben.xixiplaylet.utils.AppPreferencesManager
import com.duben.xixiplaylet.utils.SpanUtils
import com.duben.xixiplaylet.video.tx.adapter.TxVideoAdapter
import com.duben.library.utils.GlideUtils
import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.xixiplaylet.common.AppConfig
import com.duben.xixiplaylet.ui.widgets.*
import kotlinx.android.synthetic.main.activity_new_vip.*
import kotlinx.android.synthetic.main.activity_tx_video.*
......@@ -41,6 +42,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
var videos = ArrayList<VedioEpisodeBean>()
private var dialog: VideoEpisodeDialog? = null
private var detailAdDialog: DetailAdDialog? = null
private var isLuckyShow = false
private val videoPresenter by lazy { VideoPresenter() }
......@@ -90,6 +92,14 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
playIndex = super_short_video_view.currentPosition
mVedioBean?.let { videoPresenter.getIndexList("" + it.vedioId) }
}
// vip界面返回弹出广告弹窗
if (AppConfig.showVipAdDialog) {
Handler(Looper.getMainLooper()).postDelayed({
adDialog()
AppConfig.showVipAdDialog = false
}, 300)
}
}
override fun onPause() {
......@@ -318,44 +328,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
R.id.unlock -> {
// 看广告解锁
val carrierType = Constant.CARRIERTYPE_TX_VEDIO
AdManager.instance.showAd(this, carrierType,
object : AdStatusListener {
var canFail = false
override fun adSuccess() {
canFail = true
}
override fun adFail() {
if (canFail) return
NoPreAdManager.loadVideoAd(
this@TxVideoActivity,
carrierType, object : AdStatusListener {
override fun adFail() {
showToast("广告太火爆了,请稍候再试")
}
override fun adSuccess() {
}
override fun adClose(vo: HashMap<String, Any>?) {
vo?.let {
vo["vedioId"] = mVedioBean!!.vedioId
videoPresenter.unlock(vo)
}
}
})
}
override fun adClose(vo: HashMap<String, Any>?) {
vo?.let {
vo["vedioId"] = mVedioBean!!.vedioId
videoPresenter.unlock(vo)
}
}
})
showAd()
}
R.id.vip -> {
......@@ -363,6 +336,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
val bundle = Bundle()
bundle.putString(VipActivity.VEDIO_ID, mVedioBean!!.vedioId.toString())
bundle.putString(VipActivity.THIRD_ID, mVedioBean!!.thirdId)
bundle.putBoolean(VipActivity.IS_DETAIL, true)
readyGo(VipActivity::class.java, bundle)
}
......@@ -370,6 +344,47 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
}
}
private fun showAd() {
val carrierType = Constant.CARRIERTYPE_TX_VEDIO
AdManager.instance.showAd(this, carrierType,
object : AdStatusListener {
var canFail = false
override fun adSuccess() {
canFail = true
}
override fun adFail() {
if (canFail) return
NoPreAdManager.loadVideoAd(
this@TxVideoActivity,
carrierType, object : AdStatusListener {
override fun adFail() {
showToast("广告太火爆了,请稍候再试")
}
override fun adSuccess() {
}
override fun adClose(vo: HashMap<String, Any>?) {
vo?.let {
vo["vedioId"] = mVedioBean!!.vedioId
videoPresenter.unlock(vo)
}
}
})
}
override fun adClose(vo: HashMap<String, Any>?) {
vo?.let {
vo["vedioId"] = mVedioBean!!.vedioId
videoPresenter.unlock(vo)
}
}
})
}
/**
* @param index 当前下标的集数
*/
......@@ -450,4 +465,20 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
}
return readPosition
}
private fun adDialog() {
detailAdDialog = DetailAdDialog(context, object : DialogListener() {
override fun onClick(v: View) {
if (AntiShake.check(v.id)) return
when (v.id) {
R.id.tv_detail_ad_next -> {
showAd()
detailAdDialog?.dismiss()
}
}
}
})
detailAdDialog!!.show()
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/shape_bg_write"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="试用订阅规则说明"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold"></TextView>
<ImageView
android:id="@+id/iv_agreement_quit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:src="@mipmap/ic_activity_quit"></ImageView>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="8dp"
android:background="#E1E1E1" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_marginRight="4dp"
android:background="@drawable/shape_bg_agreement"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_rule_date1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="试用订阅规则说明"
android:textColor="@color/black"
android:textSize="14sp"></TextView>
</FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_arrow_bottom"></ImageView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:background="@drawable/shape_bg_agreement"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="续费提醒"
android:textColor="@color/black"
android:textSize="14sp"></TextView>
</FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_arrow_bottom"></ImageView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:background="@drawable/shape_bg_agreement"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="试用到期后进行自动续费扣款"
android:textColor="@color/black"
android:textSize="14sp"></TextView>
</FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_arrow_bottom"></ImageView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:background="@drawable/shape_bg_agreement"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_rule_date2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/black"
android:textSize="14sp"></TextView>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:text="支付方式"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold"></TextView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="right"
android:layout_marginRight="20dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@mipmap/ic_alipay"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:text="支付宝"
android:textColor="@color/black"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="center"
android:src="@mipmap/ic_vip_enable_blue" />
</LinearLayout>
</FrameLayout>
<TextView
android:id="@+id/tv_detail_ad_next"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="10dp"
android:layout_marginRight="40dp"
android:layout_marginBottom="10dp"
android:background="@drawable/shape_rule_gary"
android:gravity="center"
android:text=""
android:enabled="false"
android:textColor="@color/white"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="会员到期后自动续费,可随时取消;订阅管理,可前往会员付费界面最下方进行相关操作"
android:textColor="@color/black"
android:textSize="13sp"></TextView>
</LinearLayout>
</RelativeLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment