Commit 5c912b36 authored by jyx's avatar jyx

添加快手广告失败重试回调

parent dea0f819
...@@ -663,4 +663,4 @@ ...@@ -663,4 +663,4 @@
# -dontwarn com.kwad.** # -dontwarn com.kwad.**
# -dontwarn com.ksad.** # -dontwarn com.ksad.**
# -dontwarn aegon.chrome.** # -dontwarn aegon.chrome.**
# ======================= OAID END ================ # ======================= 快手 END ================
\ No newline at end of file \ No newline at end of file
...@@ -132,6 +132,9 @@ public class MintsApplication extends MultiDexApplication { ...@@ -132,6 +132,9 @@ public class MintsApplication extends MultiDexApplication {
// 枫岚广告 // 枫岚广告
MhManager.INSTANCE.initMn(this); MhManager.INSTANCE.initMn(this);
// 天卓珊瑚
TzManager.INSTANCE.initTz(this);
// 一览视频 // 一览视频
YlVideoManager.INSTANCE.init(this); YlVideoManager.INSTANCE.init(this);
...@@ -147,8 +150,6 @@ public class MintsApplication extends MultiDexApplication { ...@@ -147,8 +150,6 @@ public class MintsApplication extends MultiDexApplication {
// 自定义logger // 自定义logger
bindLogger(); bindLogger();
// 天卓珊瑚
TzManager.INSTANCE.initTz(this);
// 子线程初始化三方SDK // 子线程初始化三方SDK
String processName = SystemUtils.INSTANCE.getProcessName(this, android.os.Process.myPid()); String processName = SystemUtils.INSTANCE.getProcessName(this, android.os.Process.myPid());
......
...@@ -55,6 +55,9 @@ class KsVideoAdManager private constructor(activity: Activity) : ...@@ -55,6 +55,9 @@ class KsVideoAdManager private constructor(activity: Activity) :
val scene = KsScene.Builder(KsManager.KS_AD_VEDIO_POSTID).build() val scene = KsScene.Builder(KsManager.KS_AD_VEDIO_POSTID).build()
KsAdSDK.getLoadManager().loadRewardVideoAd(scene, object : KsLoadManager.RewardVideoAdListener { KsAdSDK.getLoadManager().loadRewardVideoAd(scene, object : KsLoadManager.RewardVideoAdListener {
override fun onError(p0: Int, p1: String?) { override fun onError(p0: Int, p1: String?) {
if (ksVideoAdListener != null) {
ksVideoAdListener?.ksVideoAdFail()
}
} }
override fun onRewardVideoAdLoad(p0: MutableList<KsRewardVideoAd>?) { override fun onRewardVideoAdLoad(p0: MutableList<KsRewardVideoAd>?) {
......
...@@ -342,10 +342,15 @@ public class VideoAdingManager { ...@@ -342,10 +342,15 @@ public class VideoAdingManager {
int flVideoAdCount = AppConfig.flVideoAdCount; int flVideoAdCount = AppConfig.flVideoAdCount;
int tzVideoAdCount = AppConfig.shVideoAdCount; int tzVideoAdCount = AppConfig.shVideoAdCount;
int ksVideoAdCount = AppConfig.ksVideoAdCount; int ksVideoAdCount = AppConfig.ksVideoAdCount;
int csjFullVideoAdCount = AppConfig.csjFullVideoAdCount;
if (ylhAdCount <= 0 && csjVideoAdCount <= 0 &&
wnAdCount <= 0 && flVideoAdCount <= 0 && if (ylhAdCount <= 0 &&
tzVideoAdCount <= 0 && ksVideoAdCount <= 0) { csjVideoAdCount <= 0 &&
wnAdCount <= 0 &&
flVideoAdCount <= 0 &&
tzVideoAdCount <= 0 &&
csjFullVideoAdCount <= 0 &&
ksVideoAdCount <= 0) {
// showToast("今日视频已看完,请明天再来吧"); // showToast("今日视频已看完,请明天再来吧");
return true; return true;
} }
...@@ -586,7 +591,7 @@ public class VideoAdingManager { ...@@ -586,7 +591,7 @@ public class VideoAdingManager {
csjFullVideoAdManager.setCsjFullVedioAdListener(new CsjFullVideoAdManager.CsjFullVedioAdListener() { csjFullVideoAdManager.setCsjFullVedioAdListener(new CsjFullVideoAdManager.CsjFullVedioAdListener() {
@Override @Override
public void csjFullVedioAdSuccess() { public void csjFullVedioAdSuccess() {
AppConfig.shVideoAdCount--; AppConfig.csjFullVideoAdCount--;
if (videoAdingListener != null) { if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.CSJ_FULL_AD); videoAdingListener.videoAdingListenerSuccess(Constant.CSJ_FULL_AD);
} }
......
package com.mints.goodmoney.mvp.presenters
import android.app.Activity
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.mvp.model.BaseResponse
import com.mints.goodmoney.mvp.views.VideoAdManagerView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import rx.android.schedulers.AndroidSchedulers
import java.util.*
class CsjFullVedioAdPresenter : BasePresenter<VideoAdManagerView>() {
fun reportAddCoinMsg(activity: Activity?, vo: HashMap<String, Any>) {
if (activity == null) return
loanApplication = activity.application as MintsApplication
loanService = loanApplication.loanService
subscription = loanService.reportAddCoinMsg(vo)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(loanApplication.defaultSubscribeScheduler())
.subscribe(object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {}
override fun onError(e: Throwable) {
}
override fun onNext(baseResponse: BaseResponse<Any>) {}
})
}
fun dispose() {
loanService = null
loanApplication = null
if (subscription != null && !subscription.isUnsubscribed()) {
subscription.unsubscribe()
}
}
}
\ No newline at end of file
package com.mints.goodmoney.mvp.presenters
import android.app.Activity
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.mvp.model.BaseResponse
import com.mints.goodmoney.mvp.views.VideoAdManagerView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import rx.android.schedulers.AndroidSchedulers
import java.util.*
class MhVideoAdPresenter : BasePresenter<VideoAdManagerView>() {
fun reportAddCoinMsg(activity: Activity?, vo: HashMap<String, Any>) {
if (activity == null) return
loanApplication = activity.application as MintsApplication
loanService = loanApplication.loanService
subscription = loanService.reportAddCoinMsg(vo)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(loanApplication.defaultSubscribeScheduler())
.subscribe(object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {}
override fun onError(e: Throwable) {
}
override fun onNext(baseResponse: BaseResponse<Any>) {}
})
}
fun dispose() {
loanService = null
loanApplication = null
if (subscription != null && !subscription.isUnsubscribed()) {
subscription.unsubscribe()
}
}
}
\ No newline at end of file
package com.mints.goodmoney.mvp.presenters
import android.app.Activity
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.mvp.model.BaseResponse
import com.mints.goodmoney.mvp.views.VideoAdManagerView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import rx.android.schedulers.AndroidSchedulers
import java.util.*
class WnVideoAdPresenter : BasePresenter<VideoAdManagerView>() {
fun reportAddCoinMsg(activity: Activity?, vo: HashMap<String, Any>) {
if (activity == null) return
loanApplication = activity.application as MintsApplication
loanService = loanApplication.loanService
subscription = loanService.reportAddCoinMsg(vo)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(loanApplication.defaultSubscribeScheduler())
.subscribe(object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {}
override fun onError(e: Throwable) {
}
override fun onNext(baseResponse: BaseResponse<Any>) {}
})
}
fun dispose() {
loanService = null
loanApplication = null
if (subscription != null && !subscription.isUnsubscribed()) {
subscription.unsubscribe()
}
}
}
\ No newline at end of file
package com.mints.goodmoney.mvp.presenters;
import android.app.Activity;
import com.mints.goodmoney.MintsApplication;
import com.mints.goodmoney.mvp.model.BaseResponse;
import com.mints.goodmoney.mvp.views.VideoAdManagerView;
import com.mints.goodmoney.net.LoanService;
import com.mints.library.net.neterror.BaseSubscriber;
import com.mints.library.net.neterror.Throwable;
import java.util.HashMap;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
public class YlhVideoAdPresenter extends BasePresenter<VideoAdManagerView> {
private MintsApplication loanApplication;
private LoanService loanService;
private Subscription subscription;
public void reportAddCoinMsg(Activity activity, HashMap<String, Object> vo) {
if (activity == null)
return;
loanApplication = (MintsApplication) activity.getApplication();
loanService = loanApplication.getLoanService();
subscription = loanService.reportAddCoinMsg(vo)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(loanApplication.defaultSubscribeScheduler())
.subscribe(new BaseSubscriber<BaseResponse<Object>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
// view.checkLYContextSuc(false);
}
@Override
public void onNext(BaseResponse<Object> baseResponse) {
}
});
}
public void dispose() {
loanService = null;
loanApplication = null;
if (subscription != null && !subscription.isUnsubscribed()) {
subscription.unsubscribe();
}
}
}
package com.mints.goodmoney.ui.widgets;
import android.app.Dialog;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
/**
* 描述:dialog屏幕适配
* 作者:孟崔广
* 时间:2017/10/10 17:51
* 邮箱:mengcga@163.com
*/
public abstract class BaseDialog extends Dialog {
public BaseDialog(@NonNull Context context) {
super(context);
}
public BaseDialog(@NonNull Context context, @StyleRes int themeResId) {
super(context, themeResId);
}
protected BaseDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
}
package com.mints.goodmoney.ui.widgets
import android.app.Activity
import android.app.Dialog
import android.content.Intent
import android.os.Bundle
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.login.LoginApi
import com.mints.goodmoney.login.OnLoginListener
import com.mints.goodmoney.mvp.model.DrawcashBean
import com.mints.goodmoney.mvp.model.WXInfo
import com.mints.goodmoney.mvp.presenters.SettingsPresenter
import com.mints.goodmoney.mvp.views.SettingsView
import com.mints.goodmoney.ui.activitys.AccountMergeActivity
import com.mints.goodmoney.ui.activitys.AwardActivity
import com.mints.goodmoney.utils.ToastUtil
import com.mints.library.utils.json.JsonUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import java.util.*
/**
* 微信授权弹窗
*/
class BindWxDialog(context: Activity) :
Dialog(context, R.style.dialog), OnLoginListener, SettingsView, View.OnClickListener {
private var loginApi: LoginApi? = null
private var settingsPresenter: SettingsPresenter? = null
private var wxInfo: WXInfo? = null
init {
setContentView(R.layout.dialog_bindwx)
// 设置window属性
val lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
findViewById<View>(R.id.btn_dialogper_next).setOnClickListener(this)
loginApi = LoginApi()
settingsPresenter = SettingsPresenter()
settingsPresenter?.attachView(this)
}
override fun dismiss() {
super.dismiss()
loginApi?.setOnLoginListener(null)
settingsPresenter?.detachView()
}
override fun onClick(v: View) {
if (AntiShake.check(v?.id)) return
when (v.id) {
R.id.btn_dialogper_next -> {
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
showToast("请先安装微信")
return
}
loginApi?.let {
it.setOnLoginListener(this)
it.setPlatform(Wechat.NAME)
it.login(context)
}
}
}
}
override fun onLogin(platform: String?, res: HashMap<String, Any>): Boolean {
try {
wxInfo = WXInfo()
wxInfo?.let {
it.setUnionid(res["unionid"].toString() + "")
it.setOpenid(res["openid"].toString() + "")
it.setProvince(res["province"].toString() + "")
it.setCity(res["city"].toString() + "")
it.setCountry(res["country"].toString() + "")
it.setHeadimgurl(res["headimgurl"].toString() + "")
it.setNickname(res["nickname"].toString() + "")
it.setSex((res["sex"].toString() + "").toInt())
}
settingsPresenter?.editUserMsg(res["openid"].toString(), JsonUtil.toJson(wxInfo))
} catch (e: Exception) {
e.printStackTrace()
}
return false
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
val bundle = Bundle()
bundle.putString(Constant.MERGE_MOBILE, mobile)
bundle.putString(Constant.MERGE_WXOPENID, wxOpenId)
bundle.putString(Constant.MERGE_KEY, key)
readyGo(AccountMergeActivity::class.java, bundle)
}
protected fun readyGo(clazz: Class<*>?, bundle: Bundle?) {
val intent = Intent(context, clazz)
if (null != bundle) {
intent.putExtras(bundle)
}
context.startActivity(intent)
}
override fun editUserMsgSuc() {
ToastUtil.show(context, "微信绑定成功")
dismiss()
}
override fun getUserTaskMsgSuc(data: DrawcashBean) {
}
override fun showLoading(msg: String?) {
}
override fun showToast(msg: String?) {
ToastUtil.showLong(context, msg)
}
override fun hideLoading() {
}
override fun getBaseApplication(): MintsApplication {
return MintsApplication.getContext() as MintsApplication
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.widgets
import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.Button
import android.widget.TextView
import com.mints.goodmoney.R
/**
* 提示弹框
*/
class BonusDialog(context: Context, private val listener: DialogListener) :
Dialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams
private val tv_dialogper_title: TextView
private val tv_dialogper_content: TextView
private val btn_dialogper_submit: Button
fun setTitle(title: String) {
tv_dialogper_title.visibility = View.VISIBLE
tv_dialogper_title.text = title
}
fun setContent(content: String) {
tv_dialogper_content.text = content
}
fun setBtnStr(btnStr: String) {
btn_dialogper_submit.text = btnStr
}
init {
setContentView(R.layout.dialog_friends)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
// 查找View
tv_dialogper_title =
findViewById<View>(R.id.tv_title) as TextView
tv_dialogper_content =
findViewById<View>(R.id.tv_content) as TextView
btn_dialogper_submit =
findViewById<View>(R.id.btn_submit) as Button
tv_dialogper_content.setOnClickListener(listener)
tv_dialogper_title.setOnClickListener(listener)
btn_dialogper_submit.setOnClickListener(listener)
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.widgets;
import android.content.Context;
import androidx.core.content.ContextCompat;
import android.os.CountDownTimer;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.TextView;
import com.mints.goodmoney.R;
import java.util.Timer;
import java.util.TimerTask;
/**
* 仿苹果自定义dialog选择框
*/
public class CustomDialogAsApple extends BaseDialog {
private Context context;
private LayoutParams lp;
private DialogListener listener;
private TextView dialog_tv_title, dialog_tv_content;
private Button dialog_btn_left, dialog_btn_right;
private View dialog_v_line;
public CustomDialogAsApple(Context context, DialogListener listener) {
super(context, R.style.dialog);
this.context = context;
this.listener = listener;
setContentView(R.layout.dialog_main);
// 设置window属性
lp = getWindow().getAttributes();
lp.gravity = Gravity.CENTER;
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.WRAP_CONTENT;
lp.windowAnimations = R.style.DialogAnimBottom;
getWindow().setAttributes(lp);
// 设置外部不可关闭
setCancelable(false);
setCanceledOnTouchOutside(false);
setOnKeyListener((dialog, keyCode, event) -> keyCode == KeyEvent.KEYCODE_BACK);
// 查找View
dialog_tv_title = findViewById(R.id.dialog_tv_title);
dialog_tv_content = findViewById(R.id.dialog_tv_content);
dialog_tv_content.setMovementMethod(ScrollingMovementMethod.getInstance());
dialog_btn_left = findViewById(R.id.dialog_btn_left);
dialog_btn_right = findViewById(R.id.dialog_btn_right);
dialog_v_line = findViewById(R.id.dialog_v_line);
dialog_btn_left.setOnClickListener(listener);
dialog_btn_right.setOnClickListener(listener);
}
/**
* Dialog显示标题
*
* @param s
*/
public void setTitle(String s) {
dialog_tv_title.setVisibility(View.VISIBLE);
dialog_tv_title.setText(s);
}
/**
* Dialog显示标题
*
* @param size
*/
public void setTitleSize(int size) {
dialog_tv_title.setTextSize(size);
}
/**
* Dialog显示内容
*
* @param s
*/
public void setContent(String s) {
dialog_tv_content.setText(s);
}
public void setContent(Spanned s) {
dialog_tv_content.setText(s);
}
/**
* Dialog显示content文字
*
* @param color
*/
public void setContentColor(int color) {
dialog_tv_content.setTextColor(ContextCompat.getColor(context, color));
}
/**
* content文字大小
*
* @param size
*/
public void setContentSize(int size) {
dialog_tv_content.setTextSize(size);
}
public void setContentGravity(int gravity) {
dialog_tv_content.setGravity(gravity);
}
/**
* Dialog显示left按钮文字
*
* @param s
*/
public void setLeft(String s) {
dialog_btn_left.setText(s);
if (TextUtils.isEmpty(dialog_btn_right.getText())) {
dialog_btn_right.setVisibility(View.GONE);
dialog_v_line.setVisibility(View.GONE);
} else {
dialog_btn_left.setVisibility(View.VISIBLE);
dialog_v_line.setVisibility(View.VISIBLE);
}
}
/**
* Dialog显示left按钮文字颜色
*
* @param color
*/
public void setLeftColor(int color) {
dialog_btn_left.setTextColor(ContextCompat.getColor(context, color));
}
/**
* Dialog显示right按钮文字
*
* @param s
*/
public void setRight(String s) {
dialog_btn_right.setText(s);
if (TextUtils.isEmpty(dialog_btn_left.getText())) {
dialog_btn_left.setVisibility(View.GONE);
dialog_v_line.setVisibility(View.GONE);
} else {
dialog_btn_right.setVisibility(View.VISIBLE);
dialog_v_line.setVisibility(View.VISIBLE);
}
}
/**
* Dialog显示right按钮文字
*
* @param s
*/
public void setRightDelay(String s, int second) {
dialog_btn_right.setText(s);
if (TextUtils.isEmpty(dialog_btn_left.getText())) {
dialog_btn_left.setVisibility(View.GONE);
dialog_v_line.setVisibility(View.GONE);
} else {
dialog_btn_right.setVisibility(View.VISIBLE);
dialog_v_line.setVisibility(View.VISIBLE);
dialog_btn_right.setEnabled(false);
CountDownTimer countDownTimer = new CountDownTimer(second * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
String value = String.valueOf((int) ((millisUntilFinished / 1000) + 1));
dialog_btn_right.setText(s + "(" + value + ")");
}
@Override
public void onFinish() {
dialog_btn_right.setText(s);
dialog_btn_right.setEnabled(true);
}
};
countDownTimer.start();
}
}
/**
* Dialog显示right按钮文字颜色
*
* @param color
*/
public void setRightColor(int color) {
dialog_btn_right.setTextColor(ContextCompat.getColor(context, color));
}
}
package com.mints.goodmoney.ui.widgets;
import android.view.View;
import android.view.View.OnClickListener;
/**
* 自定义dialog父类监听
*
* @author renjl
*/
public abstract class DialogListener implements OnClickListener {
@Override
public abstract void onClick(View v);
}
package com.mints.goodmoney.ui.widgets
import android.app.Dialog
import android.content.Context
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.downloader.Progress
import com.mints.goodmoney.R
import com.mints.goodmoney.utils.Utils
import com.mints.library.utils.nodoubleclick.AntiShake
/**
* 下载进度弹窗
*/
class DownloadProgressDialog(context: Context) :
Dialog(context, R.style.dialog), View.OnClickListener {
private var tvDownloadProgress: TextView? = null
init {
setContentView(R.layout.dialog_download_progress)
// 设置window属性
val lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
findViewById<ImageView>(R.id.iv_download_quit).setOnClickListener(this)
tvDownloadProgress = findViewById(R.id.tv_download_progress)
}
override fun onClick(v: View) {
if (AntiShake.check(v?.id)) return
when (v.id) {
R.id.iv_download_quit -> {
dismiss()
}
}
}
fun setProgress(progress: Progress) {
tvDownloadProgress?.text = "正在下载 " + Utils.getProgressDisplayLine(progress.currentBytes, progress.totalBytes)
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.widgets
import android.app.Activity
import android.app.Dialog
import android.text.TextUtils
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.video.VideoAdingManager
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.TrackManager
import com.mints.goodmoney.mvp.model.VideoAdingBean
import com.mints.goodmoney.utils.ToastUtil
import com.mints.library.utils.nodoubleclick.AntiShake
/**
* 提现弹窗
*/
class DrawcashVideoDialog(activity: Activity) :
Dialog(activity, R.style.dialog), View.OnClickListener {
private var onClickListener: OnClickListener? = null
private var videoAdingManager: VideoAdingManager? = null
private var loadVideoFailCount = 0
private var tvContent: TextView
private var tvNext: TextView
private var activity: Activity? = null
init {
setContentView(R.layout.dialog_drawcash)
// 设置window属性
val lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
videoAdingManager = VideoAdingManager.getInstance(activity)
findViewById<View>(R.id.btn_dialog_drawcash_back).setOnClickListener(this)
tvContent = findViewById<View>(R.id.btn_dialog_drawcash_content) as TextView
tvNext = findViewById<View>(R.id.btn_dialog_drawcash_next) as TextView
tvNext.setOnClickListener(this)
this.activity = activity
}
fun onDestory(){
videoAdingManager?.setVideoAdingListener(null)
videoAdingManager?.onDestory()
activity = null
}
override fun onClick(v: View) {
if (AntiShake.check(v.id)) return
when (v.id) {
R.id.btn_dialog_drawcash_next -> {
if (TextUtils.equals(tvNext.text.toString(), "去提现")) {
onClickListener?.onClick()
dismiss()
} else {
awardVideo()
}
}
R.id.btn_dialog_drawcash_back -> {
dismiss()
}
}
}
fun setContent(content: String) {
tvContent.text = content
}
fun setBtnText(text: String) {
tvNext.text = text
}
/**
* 获取激励视频
*/
private fun awardVideo() {
if (activity == null) return
loadVideoFailCount = 0
ToastUtil.show(activity, "加载中...")
val bean = VideoAdingBean()
bean.carrierType = Constant.CARRIER_DRAWCASH
videoAdingManager?.let { loadVideo(it, bean, true) }
}
/**
* 加载激励视频
*/
private fun loadVideo(videoAdingManager: VideoAdingManager?, bean: VideoAdingBean, isFirstLoad: Boolean) {
if (activity == null) return
videoAdingManager?.let {
it.setVideoAdingListener(object : VideoAdingManager.VideoAdingListener {
override fun videoAdingListenerError(adType: String) {
ToastUtil.show(activity, "加载超时,请休息一下")
}
override fun videoAdingListenerFail(adType: String) {
loadVideoFailCount++
if (loadVideoFailCount >= 2) {
ToastUtil.show(activity, "加载超时,请休息一下")
} else {
loadVideo(videoAdingManager, bean, false)
}
}
override fun videoAdingListenerSuccess(adType: String) {
if (it.isVideoAdDownload) {
TrackManager.getInstance().drawcashVideo()
}
}
})
if (isFirstLoad) {
// 首页按权重加载
it.loadAding(activity, bean)
} else {
// 失败按优先级加载
it.loadFailAding(activity, bean)
}
}
}
interface OnClickListener {
fun onClick()
}
fun setOnClickListener(onClickListener: OnClickListener?) {
this.onClickListener = onClickListener
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.widgets
import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.KeyEvent
import android.view.WindowManager
import android.widget.Button
import android.widget.ImageView
import com.mints.goodmoney.R
import kotlinx.android.synthetic.main.activity_feekback.*
/**
* 提示弹框
*/
class JDTintDialog(context: Context, listener: DialogListener) :
Dialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams
private val etLoginMobile: ClearEditText
private val btnBindMobile: Button
private val ivClose: ImageView
init {
setContentView(R.layout.dialog_jd_bind_mobile)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.WRAP_CONTENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
// 查找View
etLoginMobile = findViewById(R.id.etLoginMobile)
btnBindMobile = findViewById(R.id.btnBindMobile)
ivClose = findViewById(R.id.ivClose)
ivClose.setOnClickListener(listener)
etLoginMobile.setOnClickListener(listener)
btnBindMobile.setOnClickListener(listener)
}
fun getMobileNum(): String {
return etLoginMobile.text.toString().trim()
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.widgets;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import androidx.core.content.ContextCompat;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.mints.goodmoney.R;
/**
* 描述:加载中dialog
* 作者:孟崔广
* 时间:2017/10/10 17:51
* 邮箱:mengcga@163.com
*/
public class LoadingDialog extends Dialog {
private Context mContext;
private LayoutInflater inflater;
private LayoutParams lp;
private TextView loadtext;
private LinearLayout loading_ll;
public LoadingDialog(Context context) {
super(context, R.style.dialog);
this.mContext = context;
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.loadingdialog, null);
if (android.os.Build.VERSION.SDK_INT > 22) {//android 6.0替换clip的加载动画
final Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.ufo_loading_refresh);
ProgressBar loading_bar = (ProgressBar) layout.findViewById(R.id.loading_bar);
loading_bar.setIndeterminateDrawable(drawable);
}
loadtext = (TextView) layout.findViewById(R.id.loading_text);
loading_ll = (LinearLayout) layout.findViewById(R.id.loading_ll);
setContentView(layout);
// 设置window属性
lp = getWindow().getAttributes();
lp.gravity = Gravity.CENTER;
lp.dimAmount = 0; // 去背景遮盖
// lp.alpha = 1.0f;//透明效果
getWindow().setAttributes(lp);
}
/**
* 设置显示文字
*
* @param content 文字内容
*/
public void setLoadText(String content) {
if (TextUtils.isEmpty(content)) {
loading_ll.setVisibility(View.GONE);
} else {
loading_ll.setVisibility(View.VISIBLE);
loadtext.setText(content);
}
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.widgets
import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import androidx.appcompat.widget.AppCompatButton
import com.mints.goodmoney.R
/**
* 授权弹窗
*/
class PowerDialog(context: Context, private val listener: DialogListener) :
Dialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams
private val tv_dialogper_agreement: TextView
private val tv_dialogper_policy: TextView
private val btn_dialogper_back: TextView
private val btn_dialogper_next: TextView
init {
setContentView(R.layout.dialog_power)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
// lp.dimAmount = 0; // 去背景遮盖
// lp.alpha = 1.0f;//透明效果
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
// 查找View
tv_dialogper_agreement =
findViewById<View>(R.id.tv_dialogper_agreement) as TextView
tv_dialogper_policy =
findViewById<View>(R.id.tv_dialogper_policy) as TextView
btn_dialogper_back =
findViewById<View>(R.id.btn_dialogper_back) as TextView
btn_dialogper_next =
findViewById<View>(R.id.btn_dialogper_next) as TextView
tv_dialogper_policy.setOnClickListener(listener)
tv_dialogper_agreement.setOnClickListener(listener)
btn_dialogper_back.setOnClickListener(listener)
btn_dialogper_next.setOnClickListener(listener)
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.widgets
import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import com.mints.goodmoney.R
import com.mints.library.utils.GlideUtils
/**
* 提示弹框
*/
class TaskCpdDialog(context: Context, listener: DialogListener) :
Dialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams
private val tvTitle: TextView
private val tvText1: TextView
private val tvText2: TextView
private val tvInfo: TextView
private val ivAvatar: ImageView
private val textView: TextView
init {
setContentView(R.layout.dialog_task)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.WRAP_CONTENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
// setCancelable(false)
// setCanceledOnTouchOutside(false)
// setOnKeyListener { _, i, _ ->
// i == KeyEvent.KEYCODE_BACK
// }
// 查找View
tvTitle = findViewById(R.id.dialog_tv_title)
tvText1 = findViewById(R.id.dialog_tv_text1)
tvText2 = findViewById(R.id.dialog_tv_text2)
ivAvatar = findViewById(R.id.dialog_iv_avatar)
tvInfo = findViewById(R.id.dialog_tv_info)
textView = findViewById(R.id.dialog_btn_download)
textView.setOnClickListener(listener)
}
fun setData(title: String, description: String, icon: String, seconds: Int, coin: Int) {
if (seconds > 0) {
tvText1.text = "下载并试玩$seconds" + "秒"
} else {
tvText1.text = "下载领取金币"
}
tvText2.text = "+$coin" + "金币"
tvTitle.text = title
GlideUtils.loadImageView(context, icon, ivAvatar)
tvInfo.text = description
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.widgets
import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import com.mints.goodmoney.R
import com.mints.library.utils.GlideUtils
import com.tz.sdk.coral.ad.CoralAD
import com.tz.sdk.core.ui.ADContainer
/**
* 提示弹框
*/
class TaskDialog(context: Context) : Dialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams
private val tvTitle: TextView
private val tvText1: TextView
private val tvText2: TextView
private val tvInfo: TextView
private val ivAvatar: ImageView
private val textView: TextView
private var adContainer: ADContainer? = null
init {
setContentView(R.layout.dialog_task)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.WRAP_CONTENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
// setCancelable(false)
// setCanceledOnTouchOutside(false)
// setOnKeyListener { _, i, _ ->
// i == KeyEvent.KEYCODE_BACK
// }
// 查找View
tvTitle = findViewById(R.id.dialog_tv_title)
tvText1 = findViewById(R.id.dialog_tv_text1)
tvText2 = findViewById(R.id.dialog_tv_text2)
ivAvatar = findViewById(R.id.dialog_iv_avatar)
tvInfo = findViewById(R.id.dialog_tv_info)
textView = findViewById(R.id.dialog_btn_download)
adContainer = findViewById(R.id.ad_container)
}
fun setData(data: CoralAD, seconds: Int, coin: Int) {
if (seconds > 0) {
tvText1.text = "下载并试玩$seconds" + "秒"
} else {
tvText1.text = "下载领取金币"
}
tvText2.text = "+$coin" + "金币"
tvTitle.text = data.title
GlideUtils.loadImageView(context, data.icon, ivAvatar)
tvInfo.text = data.description
adContainer?.setAdModel(data)
}
override fun dismiss() {
super.dismiss()
// adContainer?.removeAllViews()
adContainer = null
}
}
\ No newline at end of file
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