Commit 95943cd1 authored by mengcuiguang's avatar mengcuiguang

新人红包去除倒计时,添加关闭

parent 951df63f
......@@ -19,6 +19,8 @@ import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.duben.miniplaylet.R
import com.duben.miniplaylet.ad.AdManager
import com.duben.miniplaylet.ad.AdStatusListener
......@@ -52,6 +54,7 @@ import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.activity_task_award.*
import kotlinx.android.synthetic.main.fragment_main.*
import kotlinx.android.synthetic.main.layout_draw_header.*
import java.lang.reflect.Field
......@@ -84,6 +87,8 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
private var isShowNewuserFlag = false
private var isNoSignFlag = false
private var rope: YoYo.YoYoString? = null
// 新人红包
var newcomerDialog: NewcomerDialog? = null
......@@ -130,7 +135,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (AppConfig.mainShowHalfAd) {
AppConfig.mainShowHalfAd = false
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
HalfScreenManager.getInstance().showAd(requireActivity(), null)
}, 200)
......@@ -140,6 +145,9 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
override fun onFragmentPause() {
banner?.stop()
rope?.stop()
rope = null
}
private fun initListener() {
......@@ -148,6 +156,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
iv_main_sign.setOnClickListener(this)
btn_draw_gold.setOnClickListener(this)
btn_draw_cash.setOnClickListener(this)
iv_main_newcomer.setOnClickListener(this)
}
override fun onClick(v: View?) {
......@@ -172,6 +181,9 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
R.id.btn_draw_cash -> {
(requireActivity() as MainActivity).clickTab4Layout()
}
R.id.iv_main_newcomer -> {
showNewcomerDialog(userInfo?.rewardCoin ?: 188800)
}
}
}
......@@ -184,52 +196,55 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
Constant.CARRIERTYPE_REWARD_FIRST -> {
val tempCoin = userInfo?.rewardCoin ?: 0
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
tv_cash.text = "18.88元"
ConsumerToastUtil.showAwardText(requireContext(), tempCoin, 0)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_main_tempanim, iv_cash, R.mipmap.ic_redpkg)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_main_tempanim, iv_cash, R.mipmap.ic_redpkg)
}, 100)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_main_tempanim, iv_cash, R.mipmap.ic_redpkg)
}, 200)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_main_tempanim, iv_cash, R.mipmap.ic_redpkg)
}, 300)
}, 1400)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
tv_cash.text = "18.88元"
showSignDialog()
if (!isShowSignFlag) {
showSignDialog()
}
}, 2000)
}, 300)
}
Constant.CARRIERTYPE_SIGN -> {
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
// 1、第一次打款
showDrawAlipayDialog(signMsg?.cashCashFirst ?: 0.01)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
// 2、展示签到余额
drawAlipayDialog?.dismiss()
showSignDrawDialog(0)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
// 3、发放奖励弹窗
if (!isSignDrawFlag) {
......@@ -238,7 +253,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
bundle.putString(LoadingActivity.TEXT, "正在为您发放奖励..")
readyGo(LoadingActivity::class.java, bundle)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
showAd(Constant.CARRIERTYPE_SIGN_DRAW)
}, 2500)
......@@ -250,11 +265,11 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
Constant.CARRIERTYPE_SIGN_DRAW -> {
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
showDrawAlipayDialog(signMsg?.cashCashSecond ?: 0.01)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
// 2、第二次展示签到余额
drawAlipayDialog?.dismiss()
......@@ -332,7 +347,18 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (!isShowNewuserFlag) {
isShowNewuserFlag = true
showNewcomerDialog(user.userMsg.rewardCoin)
} else {
iv_main_newcomer.visibility = View.VISIBLE
Handler(Looper.getMainLooper()).postDelayed({
if (!isAdded) return@postDelayed
rope = YoYo.with(Techniques.Pulse).duration(500).repeat(-1)
.playOn(iv_main_newcomer)
}, 300)
}
} else {
iv_main_newcomer.visibility = View.GONE
}
......@@ -349,8 +375,10 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
} else {
iv_main_sign.visibility = View.VISIBLE
tv_main_signcash.text = "${data!!.signMsg!!.sumCash}元"
AppConfig.signCash1 = FormatUtil.sub(data!!.signMsg!!.surCash, data!!.signMsg!!.cashCashFirst)
AppConfig.signCash2 = FormatUtil.sub(AppConfig.signCash1, data!!.signMsg!!.cashCashSecond)
AppConfig.signCash1 =
FormatUtil.sub(data!!.signMsg!!.surCash, data!!.signMsg!!.cashCashFirst)
AppConfig.signCash2 =
FormatUtil.sub(AppConfig.signCash1, data!!.signMsg!!.cashCashSecond)
if (data!!.signMsg!!.signDay <= 7) {
if (!isShowSignFlag && userInfo?.rewardFirst != 0) {
isShowSignFlag = true
......@@ -416,9 +444,27 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
* 新人弹窗
*/
private fun showNewcomerDialog(rewardCoin: Int) {
if(!isAdded) return
if (!isAdded) return
newcomerDialog = NewcomerDialog(requireContext(), rewardCoin, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View) {
when (v.id) {
R.id.tv_newcomer_time -> {
newcomerDialog?.dismiss()
iv_main_newcomer.visibility = View.VISIBLE
Handler(Looper.getMainLooper()).postDelayed({
if (!isAdded) return@postDelayed
rope = YoYo.with(Techniques.Pulse).duration(500).repeat(-1)
.playOn(iv_main_newcomer)
}, 300)
}
}
}
})
newcomerDialog = NewcomerDialog(requireContext(), rewardCoin)
newcomerDialog?.setAdListener(object : NewcomerDialog.AdListener {
override fun showAd() {
newcomerDialog?.dismiss()
......@@ -438,7 +484,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
* 2-7天后 第一次进入.不用定时
*/
private fun showSignDrawDialog(times: Int) {
if(!isAdded) return
if (!isAdded) return
signDrawDialog = SignDrawDialog(requireContext(), times)
signDrawDialog?.setAdListener(object : SignDrawDialog.AdListener {
......@@ -451,7 +497,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
bundle.putString(LoadingActivity.TEXT, "正在为您发放奖励..")
readyGo(LoadingActivity::class.java, bundle)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
showAd(Constant.CARRIERTYPE_SIGN_DRAW)
}, 2500)
......@@ -464,7 +510,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
bundle.putString(LoadingActivity.TEXT, "正在为您发放奖励..")
readyGo(LoadingActivity::class.java, bundle)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
showAd(Constant.CARRIERTYPE_SIGN_7)
}, 2500)
......@@ -485,7 +531,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
private fun showDrawAlipayDialog(cash: Double) {
TrackManager.getInstance().addCashoutReq(signMsg?.unitId)
if(!isAdded) return
if (!isAdded) return
drawAlipayDialog = DrawAlipayDialog(requireContext(), cash)
drawAlipayDialog!!.show()
......@@ -535,7 +581,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
private fun showSignDialog() {
if (signMsg == null) return
if(!isAdded) return
if (!isAdded) return
DialogUtils.showSignDialog(requireContext(), object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View) {
......@@ -561,7 +607,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
showToast("支付宝授权成功")
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
dialog?.dismiss()
val bundle = Bundle()
......@@ -576,7 +622,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
readyGo(LoadingActivity::class.java, bundle)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
showAd(Constant.CARRIERTYPE_SIGN)
}, 2500)
......@@ -599,7 +645,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
readyGo(LoadingActivity::class.java, bundle)
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
showAd(Constant.CARRIERTYPE_SIGN)
}, 2500)
......
......@@ -18,7 +18,7 @@ import kotlinx.android.synthetic.main.dialog_newcomer.*
import kotlinx.android.synthetic.main.dialog_sign.*
import java.math.BigDecimal
class NewcomerDialog(private val context: Context, private val rewardCoin: Int) :
class NewcomerDialog(private val context: Context, private val rewardCoin: Int, listener: DialogListener) :
Dialog(
context, R.style.dialog
) {
......@@ -59,6 +59,7 @@ class NewcomerDialog(private val context: Context, private val rewardCoin: Int)
isClickBtn = true
adListener?.showAd()
}
tv_newcomer_time.setOnClickListener(listener)
val sumCoin = rewardCoin.toString()
val allcoinBig = BigDecimal(sumCoin)
......@@ -71,18 +72,18 @@ class NewcomerDialog(private val context: Context, private val rewardCoin: Int)
.append("元")
.create()
Handler().postDelayed({
startTimer()
}, 900)
// Handler().postDelayed({
// startTimer()
// }, 900)
}
override fun dismiss() {
super.dismiss()
if (timer != null) { //防止计时器重复
timer!!.stop()
timer = null
}
// if (timer != null) { //防止计时器重复
// timer!!.stop()
// timer = null
// }
}
fun startTimer() {
......
......@@ -37,6 +37,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="@mipmap/ic_draw_quit"
android:gravity="center"
android:textColor="@color/white"
android:textSize="14sp"></TextView>
......
......@@ -175,7 +175,7 @@
android:id="@+id/iv_main_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:layout_marginTop="330dp"
android:layout_marginRight="20dp"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
......@@ -201,6 +201,18 @@
android:textSize="13sp" />
</FrameLayout>
<ImageView
android:id="@+id/iv_main_newcomer"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_marginLeft="10dp"
android:visibility="gone"
android:layout_marginTop="430dp"
android:layout_marginRight="20dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@mipmap/ic_main_comer" />
<ImageView
android:id="@+id/iv_main_tempanim"
......
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