Commit cf61dca8 authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent bf3dea77
...@@ -25,4 +25,5 @@ public class AppConfig { ...@@ -25,4 +25,5 @@ public class AppConfig {
public static boolean enterAlipay = false; public static boolean enterAlipay = false;
public static long splashTime = 0L; public static long splashTime = 0L;
public static String jtcText = "123123123123123123123123123123123123123123123123123123123123123123123123";
} }
package com.duben.happyplaylet.mvp.presenters package com.duben.happyplaylet.mvp.presenters
import com.duben.happyplaylet.MintsApplication import com.duben.happyplaylet.MintsApplication
import com.duben.happyplaylet.common.AppConfig
import com.duben.happyplaylet.common.Constant import com.duben.happyplaylet.common.Constant
import com.duben.happyplaylet.common.DeviceInfo import com.duben.happyplaylet.common.DeviceInfo
import com.duben.happyplaylet.manager.AppHttpManager import com.duben.happyplaylet.manager.AppHttpManager
...@@ -302,6 +303,7 @@ class HomePresenter : BasePresenter<HomeView>() { ...@@ -302,6 +303,7 @@ class HomePresenter : BasePresenter<HomeView>() {
try { try {
val jsonObject = baseResponse.data val jsonObject = baseResponse.data
val flag=jsonObject["showReceiveJtcCoupons"].asBoolean val flag=jsonObject["showReceiveJtcCoupons"].asBoolean
AppConfig.jtcText=jsonObject["rule"].asString
view.giftSuc(flag) view.giftSuc(flag)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
......
package com.duben.happyplaylet.mvp.presenters package com.duben.happyplaylet.mvp.presenters
import com.duben.happyplaylet.MintsApplication import com.duben.happyplaylet.MintsApplication
import com.duben.happyplaylet.common.AppConfig
import com.duben.happyplaylet.common.DeviceInfo import com.duben.happyplaylet.common.DeviceInfo
import com.duben.happyplaylet.manager.AppHttpManager import com.duben.happyplaylet.manager.AppHttpManager
import com.duben.happyplaylet.manager.UserManager import com.duben.happyplaylet.manager.UserManager
...@@ -9,6 +10,7 @@ import com.duben.happyplaylet.mvp.views.MyView ...@@ -9,6 +10,7 @@ import com.duben.happyplaylet.mvp.views.MyView
import com.duben.happyplaylet.utils.DeviceUuidFactory import com.duben.happyplaylet.utils.DeviceUuidFactory
import com.duben.library.net.neterror.BaseSubscriber import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable import com.duben.library.net.neterror.Throwable
import com.google.gson.JsonObject
class MyPresenter : BasePresenter<MyView>() { class MyPresenter : BasePresenter<MyView>() {
...@@ -266,4 +268,41 @@ class MyPresenter : BasePresenter<MyView>() { ...@@ -266,4 +268,41 @@ class MyPresenter : BasePresenter<MyView>() {
}) })
} }
fun getGift() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getGift(),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<JsonObject>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
try {
val jsonObject = baseResponse.data
val flag=jsonObject["showReceiveJtcCoupons"].asBoolean
AppConfig.jtcText=jsonObject["rule"].asString
view.giftSuc(flag)
} catch (e: Exception) {
e.printStackTrace()
}
}
else -> {
view.showToast(message)
}
}
}
})
}
} }
\ No newline at end of file
...@@ -10,4 +10,6 @@ interface MyView : BaseView { ...@@ -10,4 +10,6 @@ interface MyView : BaseView {
fun getTurnIphoneMsgSuc(data: NineListBean) fun getTurnIphoneMsgSuc(data: NineListBean)
fun toTurnSuc(data: NineListBean.NineBean) fun toTurnSuc(data: NineListBean.NineBean)
fun unlockSuc() fun unlockSuc()
fun giftSuc(data: Boolean)
} }
...@@ -62,7 +62,7 @@ class AboutusActivity : BaseActivity(), View.OnClickListener { ...@@ -62,7 +62,7 @@ class AboutusActivity : BaseActivity(), View.OnClickListener {
// object : TTMediationTestTool.ImageCallBack { // object : TTMediationTestTool.ImageCallBack {
// override fun loadImage(imageView: ImageView?, s: String?) {} // override fun loadImage(imageView: ImageView?, s: String?) {}
// }) // })
readyGo(GiftActivity::class.java) readyGo(GetGiftActivity::class.java)
// VoiceRedEnvelopeManager.load(23,23) // VoiceRedEnvelopeManager.load(23,23)
true true
} }
......
...@@ -39,7 +39,7 @@ class GetGiftActivity : BaseActivity(), View.OnClickListener { ...@@ -39,7 +39,7 @@ class GetGiftActivity : BaseActivity(), View.OnClickListener {
override fun finish() { override fun finish() {
super.finish() super.finish()
//关闭窗体动画显示 //关闭窗体动画显示
overridePendingTransition(0, R.anim.push_bottom_out) overridePendingTransition(0, R.anim.fade_out)
} }
override fun onClick(v: View?) { override fun onClick(v: View?) {
......
...@@ -5,15 +5,20 @@ import android.os.Looper ...@@ -5,15 +5,20 @@ import android.os.Looper
import android.text.TextUtils import android.text.TextUtils
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import com.duben.happyplaylet.BuildConfig
import com.duben.library.utils.nodoubleclick.AntiShake import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.happyplaylet.R import com.duben.happyplaylet.R
import com.duben.happyplaylet.common.AppConfig
import com.duben.happyplaylet.manager.UserManager import com.duben.happyplaylet.manager.UserManager
import com.duben.happyplaylet.mvp.presenters.GiftPresenter import com.duben.happyplaylet.mvp.presenters.GiftPresenter
import com.duben.happyplaylet.mvp.views.GiftView import com.duben.happyplaylet.mvp.views.GiftView
import com.duben.happyplaylet.ui.activitys.base.BaseActivity import com.duben.happyplaylet.ui.activitys.base.BaseActivity
import com.duben.happyplaylet.utils.BackInputUtil import com.duben.happyplaylet.utils.BackInputUtil
import com.duben.happyplaylet.utils.LogUtil import com.duben.happyplaylet.utils.LogUtil
import com.duben.library.utils.ConstantUtil
import kotlinx.android.synthetic.main.activity_aboutus.*
import kotlinx.android.synthetic.main.activity_gift.* import kotlinx.android.synthetic.main.activity_gift.*
import kotlinx.android.synthetic.main.header_layout.*
/** /**
...@@ -28,16 +33,20 @@ class GiftActivity : BaseActivity(), GiftView, View.OnClickListener { ...@@ -28,16 +33,20 @@ class GiftActivity : BaseActivity(), GiftView, View.OnClickListener {
private var mobile: String? = null private var mobile: String? = null
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
tv_title.text = "停车代金券"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
giftPresenter.attachView(this) giftPresenter.attachView(this)
initView() initView()
initListener() initListener()
tv_gift_text.text=AppConfig.jtcText
} }
override fun getContentViewLayoutID() = R.layout.activity_gift override fun getContentViewLayoutID() = R.layout.activity_gift
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.FADE
override fun isApplyKitKatTranslucency() = false override fun isApplyKitKatTranslucency() = false
...@@ -46,21 +55,6 @@ class GiftActivity : BaseActivity(), GiftView, View.OnClickListener { ...@@ -46,21 +55,6 @@ class GiftActivity : BaseActivity(), GiftView, View.OnClickListener {
giftPresenter.detachView() giftPresenter.detachView()
} }
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
true
} else super.onKeyDown(
keyCode,
event
)
}
override fun finish() {
super.finish()
//关闭窗体动画显示
overridePendingTransition(0, R.anim.push_bottom_out)
}
override fun onClick(v: View?) { override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return if (AntiShake.check(v?.id)) return
...@@ -121,6 +115,7 @@ class GiftActivity : BaseActivity(), GiftView, View.OnClickListener { ...@@ -121,6 +115,7 @@ class GiftActivity : BaseActivity(), GiftView, View.OnClickListener {
} }
private fun initListener() { private fun initListener() {
iv_left_icon.setOnClickListener(this)
tvLoginSendcode.setOnClickListener(this) tvLoginSendcode.setOnClickListener(this)
tvLoginNext.setOnClickListener(this) tvLoginNext.setOnClickListener(this)
} }
......
...@@ -52,6 +52,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -52,6 +52,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
private var yoyo: YoYo.YoYoString? = null private var yoyo: YoYo.YoYoString? = null
private var isInitLuckyData = false private var isInitLuckyData = false
private var isTurnLuckyPage = false private var isTurnLuckyPage = false
private var isShowGiftAct = false
private var nineShowBean: NineShowBean? = null private var nineShowBean: NineShowBean? = null
var carrierType = Constant.CARRIERTYPE_NINE var carrierType = Constant.CARRIERTYPE_NINE
...@@ -104,6 +105,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -104,6 +105,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
if (!TextUtils.isEmpty(userManager?.userID)) { if (!TextUtils.isEmpty(userManager?.userID)) {
myPresenter.showTurn() myPresenter.showTurn()
myPresenter.getMyInfo() myPresenter.getMyInfo()
myPresenter.getGift()
} else { } else {
myPresenter.userLogin() myPresenter.userLogin()
} }
...@@ -158,6 +160,18 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -158,6 +160,18 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
loginStatus(data) loginStatus(data)
} }
override fun giftSuc(showGiftflag: Boolean) {
if (showGiftflag && !isShowGiftAct && userManager.vipFlag) {
isShowGiftAct = true
Handler(Looper.getMainLooper()).postDelayed({
if (requireActivity().isFinishing) return@postDelayed
readyGo(GiftActivity::class.java)
}, 500)
}
}
private fun loginStatus(consumer: UserBean) { private fun loginStatus(consumer: UserBean) {
// 1-匹配用户 // 1-匹配用户
if (consumer.activiteFlag == 1) { if (consumer.activiteFlag == 1) {
......
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