Commit b4afc767 authored by jyx's avatar jyx

代码优化

parent 2cb786fe
......@@ -9,10 +9,8 @@ import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot
import com.bytedance.sdk.openadsdk.mediation.ad.MediationNativeToBannerListener
import com.duben.dayplaylet.BuildConfig
import com.duben.dayplaylet.MintsApplication
import com.duben.dayplaylet.ad.splash.SplashManager
import com.duben.dayplaylet.common.Constant
import com.duben.dayplaylet.manager.TrackManager
import com.duben.dayplaylet.manager.UserManager
import com.duben.dayplaylet.utils.LogUtil
import com.duben.dayplaylet.utils.UIUtils
import java.lang.ref.WeakReference
......@@ -34,7 +32,7 @@ object BannerManager {
LogUtil.d(TAG, "gromore banner广告-> 1、进入加载")
/** 这里是简单的banner请求adSlot设置,如果需要更多的设置,可参考AdUtils.kt中bannerAdSlot函数部分。 */
var adSlot: AdSlot = AdSlot.Builder()
val adSlot: AdSlot = AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_BANNER_CODE)
// .setImageAcceptedSize(UIUtils.dp2px(weakActivity?.get(), 300f), UIUtils.dp2px(weakActivity?.get(), 45f)) // 单位px
.setImageAcceptedSize(
......@@ -58,7 +56,7 @@ object BannerManager {
)
.build()
var adNativeLoader: TTAdNative = TTAdSdk.getAdManager().createAdNative(weakActivity?.get())
val adNativeLoader: TTAdNative = TTAdSdk.getAdManager().createAdNative(weakActivity?.get())
adNativeLoader.loadBannerExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
override fun onNativeExpressAdLoad(ads: MutableList<TTNativeExpressAd>?) {
LogUtil.d(TAG, "banner广告-> 2、 load success: " + if (ads == null) "0" else ads?.size)
......@@ -73,11 +71,14 @@ object BannerManager {
}
override fun onAdShow(view: View?, type: Int) {
if (bannerAd != null && bannerAd!!.getMediationManager().getShowEcpm() != null) {
if (bannerAd != null && bannerAd!!.mediationManager.showEcpm != null) {
val vo = HashMap<String, Any>()
vo["adcode"] = bannerAd!!.getMediationManager().getShowEcpm().getSlotId()
vo["ecpm"] = bannerAd!!.getMediationManager().getShowEcpm().getEcpm()
vo["adSource"] = bannerAd!!.getMediationManager().getShowEcpm().getSdkName()
vo["adcode"] =
bannerAd!!.mediationManager.showEcpm.slotId
vo["ecpm"] =
bannerAd!!.mediationManager.showEcpm.ecpm
vo["adSource"] =
bannerAd!!.mediationManager.showEcpm.sdkName
vo["adid"] = BuildConfig.GROMORE_BANNER_CODE
vo["adType"] = Constant.GRO_MORE_ADTYPE5
TrackManager.getInstance().reporGromeEcpm(vo)
......@@ -126,7 +127,7 @@ object BannerManager {
if (bannerView != null && weakFrameLayout != null) {
val bannerContainer = weakFrameLayout!!.get()
bannerContainer!!.removeAllViews()
bannerContainer!!.addView(bannerView)
bannerContainer.addView(bannerView)
}
}
}
\ No newline at end of file
......@@ -266,6 +266,8 @@ public class InMoneyVideo {
strings.add(Constant.CARRIERTYPE_SONG_CLICK);
strings.add(Constant.CARRIERTYPE_SONG_MORE);
strings.add(Constant.CARRIERTYPE_SONG_ALL);
strings.add(Constant.CARRIERTYPE_REWARD_HONGBAO);
strings.add(Constant.CARRIERTYPE_REWARD_HONGBAO_MORE);
return strings.contains(carrierType);
}
......
......@@ -205,6 +205,8 @@ public class InMoneyVideoNoPre {
strings.add(Constant.CARRIERTYPE_SONG_CLICK);
strings.add(Constant.CARRIERTYPE_SONG_MORE);
strings.add(Constant.CARRIERTYPE_SONG_ALL);
strings.add(Constant.CARRIERTYPE_REWARD_HONGBAO);
strings.add(Constant.CARRIERTYPE_REWARD_HONGBAO_MORE);
return strings.contains(carrierType);
}
......
......@@ -32,11 +32,14 @@ object Constant {
const val CARRIERTYPE_SING_OVER = "ONLY_SHOW" //猜歌进度完成
const val CARRIERTYPE_SONG_CLICK = "REWARD_GUESS_SONG_CLICK" //不看视频点击答题 的入参
const val CARRIERTYPE_SONG_MORE = "REWARD_GUESS_SONG_MORE" //翻倍 的入参
const val CARRIERTYPE_SONG_ALL = "REWARD_GUESS_SONG_ALL" //画着红包直接看视频的入参
const val CARRIERTYPE_REWARD_HONGBAO = "REWARD_HONGBAO" //看视频得红包券的
const val CARRIERTYPE_REWARD_HONGBAO_MORE = "REWARD_HONGBAO_MORE" //看视频得红包券的
const val CARRIERTYPE_FORCASH_HONGBAO = "FORCASH_HONGBAO" //提现时候传入的
const val CARRIERTYPE_VEDIO_UNLOCK = "VEDIO_UNLOCK"
const val CARRIERTYPE_VEDIO = "REWARD_VEDIO" //加金币
......
package com.duben.dayplaylet.mvp.model;
import java.io.Serializable;
import java.util.List;
public class HongbaoBean implements Serializable {
private List<ListDTO> list;
public List<ListDTO> getList() {
return list;
}
public void setList(List<ListDTO> list) {
this.list = list;
}
public static class ListDTO implements Serializable {
private boolean reward;
private Object image;
private String nickname;
private String text;
public boolean isReward() {
return reward;
}
public void setReward(boolean reward) {
this.reward = reward;
}
public Object getImage() {
return image;
}
public void setImage(Object image) {
this.image = image;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
}
......@@ -10,5 +10,5 @@ class MsgBean(
var content: String? = "", // 内容
var avatarImg: Any? = null, // 头像图片地址
var contentImg: Any? = null, // 图片地址
var showFinger: Boolean = false, // 图片地址
var showFinger: Boolean = false, // 手指
)
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.duben.dayplaylet.mvp.presenters
import com.duben.dayplaylet.manager.AppHttpManager
import com.duben.dayplaylet.mvp.model.BaseResponse
import com.duben.dayplaylet.mvp.model.HongbaoBean
import com.duben.dayplaylet.mvp.views.RedpkgView
import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable
......@@ -9,6 +10,160 @@ import com.google.gson.JsonObject
class RedpkgPresenter : BasePresenter<RedpkgView>() {
// 初始化或者刷新
fun rdHongbaoRefresh() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.rdHongbaoRefresh(),
object : BaseSubscriber<BaseResponse<HongbaoBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.showToast(e.message)
view.rdHongbaoRefreshFail()
}
override fun onNext(baseResponse: BaseResponse<HongbaoBean>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
view.rdHongbaoRefreshSuc(baseResponse.data)
}
else -> {
view.rdHongbaoRefreshFail()
view.showToast(message)
}
}
}
})
}
// 对话
fun rdHongbaoTalk() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.rdHongbaoTalk(),
object : BaseSubscriber<BaseResponse<HongbaoBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.showToast(e.message)
view.rdHongbaoTalkFail()
}
override fun onNext(baseResponse: BaseResponse<HongbaoBean>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
view.rdHongbaoTalkSuc(baseResponse.data)
}
else -> {
view.rdHongbaoTalkFail()
view.showToast(message)
}
}
}
})
}
// 上拉加载更多
fun rdHongbaoMore() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.rdHongbaoMore(),
object : BaseSubscriber<BaseResponse<HongbaoBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.showToast(e.message)
view.rdHongbaoMoreFail()
}
override fun onNext(baseResponse: BaseResponse<HongbaoBean>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
view.rdHongbaoMoreSuc(baseResponse.data)
}
else -> {
view.rdHongbaoMoreFail()
view.showToast(message)
}
}
}
})
}
// 点击红包
fun rdHongbaoClick() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.rdHongbaoClick(),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.showToast(e.message)
view.rdHongbaoClickFail()
}
override fun onNext(baseResponse: BaseResponse<JsonObject>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
val data = baseResponse.data
if (data != null) {
val jsonObject = data["list"].asJsonObject
val isCash = jsonObject["isCash"].asBoolean
if (isCash) {
view.rdHongbaoClickSuc(
isCash,
jsonObject["cash"].asDouble,
jsonObject["unitId"].asString
)
} else {
view.rdHongbaoClickSuc(
isCash,
0.0,
""
)
}
}
}
else -> {
view.rdHongbaoClickFail()
view.showToast(message)
}
}
}
})
}
// 添加金币
fun reportAddCoinMsg(carrierType: String, ecpmId: String = "") {
val vo = HashMap<String, Any>()
......
package com.duben.dayplaylet.mvp.views
import com.duben.dayplaylet.mvp.model.HongbaoBean
interface RedpkgView : BaseView {
fun reportAddCoinMsgSuc(coin: Int, di: Int)
fun rdHongbaoRefreshSuc(data: HongbaoBean)
fun rdHongbaoRefreshFail()
fun rdHongbaoTalkSuc(data: HongbaoBean)
fun rdHongbaoTalkFail()
fun rdHongbaoMoreSuc(data: HongbaoBean)
fun rdHongbaoMoreFail()
fun rdHongbaoClickSuc(isCash: Boolean, cash: Double, unitId: String)
fun rdHongbaoClickFail()
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.text.TextUtils;
import com.duben.dayplaylet.mvp.model.DrawInfoBean;
import com.duben.dayplaylet.mvp.model.HongbaoBean;
import com.duben.dayplaylet.mvp.model.RDVideoBean;
import com.duben.dayplaylet.mvp.model.RiskBean;
import com.duben.dayplaylet.mvp.model.SignInfoBean;
......@@ -249,6 +250,39 @@ public interface LoanService {
@POST("api/reward/rdUserHallList")
Observable<BaseResponse<TaskInfoBean>> rdUserHallList();
/**
* 红包群-初始化或者刷新
*
* @return
*/
@POST("api/reward/rdHongbaoRefresh")
Observable<BaseResponse<HongbaoBean>> rdHongbaoRefresh();
/**
* 红包群-对话
*
* @return
*/
@POST("api/reward/rdHongbaoTalk")
Observable<BaseResponse<HongbaoBean>> rdHongbaoTalk();
/**
* 红包群-上拉加载更多
*
* @return
*/
@POST("api/reward/rdHongbaoMore")
Observable<BaseResponse<HongbaoBean>> rdHongbaoMore();
/**
* 红包群-点击红包
*
* @return
*/
@POST("api/reward/rdHongbaoClick")
Observable<BaseResponse<JsonObject>> rdHongbaoClick();
/**
* 红包券提现列表
*
......
......@@ -4,29 +4,21 @@ 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.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieComposition
import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.LottieDrawable
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.duben.dayplaylet.R
import com.duben.dayplaylet.ad.AdManager
import com.duben.dayplaylet.ad.AdStatusListener
import com.duben.dayplaylet.ad.NoPreAdManager
import com.duben.dayplaylet.ad.half.HalfScreenManager
import com.duben.dayplaylet.common.AppConfig
import com.duben.dayplaylet.common.Constant
import com.duben.dayplaylet.manager.TrackManager
import com.duben.dayplaylet.mvp.model.NineListBean
import com.duben.dayplaylet.mvp.model.NineShowBean
import com.duben.dayplaylet.ui.activitys.base.BaseActivity
import com.duben.dayplaylet.ui.widgets.DialogListener
import com.duben.dayplaylet.ui.widgets.WithDrawSucDialog
import com.duben.dayplaylet.utils.ConsumerToastUtil
import com.duben.dayplaylet.utils.SplitArrayUtils
import com.duben.dayplaylet.utils.rxutil.CommonRxTask
import com.duben.dayplaylet.utils.rxutil.RxjavaUtil
import com.duben.library.utils.nodoubleclick.AntiShake
......@@ -159,17 +151,17 @@ class NineActivity : BaseActivity(), View.OnClickListener {
lucky_panel2.tryToStop(5)
Handler(Looper.getMainLooper()).postDelayed({
showWithdrawSucDialog()
showWithdrawSucDialog(0.0)
}, 2000)
}
})
}
}
private fun showWithdrawSucDialog() {
private fun showWithdrawSucDialog(cash: Double) {
TrackManager.getInstance().addCashoutReq(drawId)
mWithDrawSucDialog =
WithDrawSucDialog(context, cash, object : DialogListener() {
WithDrawSucDialog(context, cash.toString(), object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
super.onClick(dialog, v)
dialog?.dismiss()
......
......@@ -101,12 +101,13 @@ class MsgAdapter : BaseMultiItemQuickAdapter<MSGMultiItemEntity, BaseViewHolder>
setGravityLL(tvName, Gravity.END)
}
if (msgBean.contentImg == null) {
GlideUtils.loadImageView(context, R.mipmap.hongbao, ivContent)
GlideUtils.loadImageView(context, R.mipmap.bg_redpkg_enable, ivContent)
} else {
GlideUtils.loadImageView(context, msgBean.contentImg, ivContent)
}
ivContent.setOnClickListener {
finger.visibility = View.GONE
mOnCustomChildClickListener?.onCustomChildClick(it)
}
tvName.text = msgBean.name
......
......@@ -551,7 +551,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
rl_open_cash.visibility = View.VISIBLE
tv_open_cash_progress.text =
String.format(
"%2d/%2d",
"%d/%d",
it.completeCount,
it.turnNeedCount
)
......
......@@ -21,6 +21,7 @@ public class CountDownVideoView extends LinearLayout {
private ImageView ivCountVedioRedbox;
private boolean isPlaying = false;
private boolean isOver = false;
private YoYo.YoYoString rope;
public CountDownVideoView(Context context) {
......@@ -48,12 +49,14 @@ public class CountDownVideoView extends LinearLayout {
private void initListener() {
cdCountVedioView.setOnLoadingFinishListener(() -> {
if (countDownVideoListener != null) {
isOver = true;
countDownVideoListener.onLoadingFinish();
}
});
}
public void start() {
isOver = false;
cdCountVedioView.start();
isPlaying = true;
}
......@@ -63,10 +66,12 @@ public class CountDownVideoView extends LinearLayout {
}
public void resume() {
isOver = false;
cdCountVedioView.resume();
}
public void reset() {
isOver = false;
cdCountVedioView.reset();
isPlaying = true;
}
......@@ -85,6 +90,11 @@ public class CountDownVideoView extends LinearLayout {
return isPlaying;
}
public boolean isOver() {
return isOver;
}
public void setTime(int time) {
cdCountVedioView.setTime(time);
}
......
......@@ -433,7 +433,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
cdvv.setCountDownVideoListener(this)
cl_red_box.isClickable = false
cl_red_box.setOnClickListener {
if (cdvv.isPlaying) return@setOnClickListener
if (!cdvv.isOver) return@setOnClickListener
dpWidget?.fragment?.onPause()
showRedboxDialog()
......@@ -594,6 +594,8 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
videoPresenter.unlock(it)
}
iv_pause.visibility = View.GONE
// 更新解锁集数
for (i in 1 until lockSet) {
val hasUnlockList: MutableList<Int> =
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- solid指定形状的填充色,只有android:color一个属性 -->
<solid android:color="@color/color_FFDF85" />
<!-- padding设置内容区域离边界的间距 -->
<!-- corners设置圆角,只适用于rectangle -->
<corners android:radius="30dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="30dp" />
<solid android:color="#FFE9E9" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<scale android:scaleWidth="100%">
<shape>
<corners android:radius="30dp" />
<solid android:color="@color/color_FFDF85" />
</shape>
</scale>
</item>
<item android:id="@android:id/progress">
<!--
<clip>
<shape>
<corners android:topRightRadius="20dp"
android:bottomRightRadius="20dp"/>
<solid android:color="#FF009898"/>
</shape>
</clip>
-->
<scale
android:drawable="@drawable/progress_bar_ct3"
android:scaleWidth="100%" />
</item>
</layer-list>
\ No newline at end of file
......@@ -65,10 +65,11 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="18dp"
android:visibility="gone"
android:layout_marginRight="16dp"
android:layout_marginBottom="10dp"
android:background="@drawable/shape_bg_write"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
......@@ -105,8 +106,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="8dp"
android:overScrollMode="never" />
</LinearLayout>
......@@ -117,7 +118,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="15dp" />
<TextView
......@@ -176,8 +176,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:visibility="gone"
android:layout_marginRight="20dp"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
......
......@@ -18,7 +18,7 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="160dp"
android:layout_marginEnd="20dp">
android:layout_marginEnd="15dp">
<ImageView
android:id="@+id/iv_open_cash"
......@@ -34,10 +34,10 @@
android:layout_height="14dp"
android:layout_alignBottom="@id/iv_open_cash"
android:layout_centerHorizontal="true"
android:padding="1dp"
android:layout_marginBottom="22dp"
android:background="@drawable/shape_write"
android:progressDrawable="@drawable/progressbar_versus_changevedio_bg" />
android:padding="1dp"
android:progressDrawable="@drawable/progressbar_song_bg" />
<TextView
android:id="@+id/tv_open_cash_progress"
......
......@@ -54,7 +54,7 @@
android:id="@+id/iv_content"
android:layout_width="200dp"
android:layout_height="85dp"
android:src="@mipmap/hongbao" />
android:src="@mipmap/bg_redpkg_enable" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/finger_view"
......
......@@ -27,10 +27,10 @@
android:id="@+id/triangle"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="30dp"
android:background="@drawable/shape_triangle"
android:visibility="gone"
app:layout_constraintStart_toStartOf="@id/tv_tips"
app:layout_constraintEnd_toEndOf="@id/linearLayout"
app:layout_constraintStart_toStartOf="@id/linearLayout"
app:layout_constraintTop_toBottomOf="@id/tv_tips" />
<LinearLayout
......
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