Commit 95943cd1 authored by mengcuiguang's avatar mengcuiguang

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

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