Commit 1021429d authored by jyx's avatar jyx

代码优化

parent ec43d9df
......@@ -32,7 +32,6 @@ import com.duben.dayplaylet.utils.rxutil.RxjavaUtil
import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable
import com.duben.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_hint.*
import kotlinx.android.synthetic.main.activity_nine.*
/**
......@@ -94,10 +93,10 @@ class NineActivity : BaseActivity(), View.OnClickListener {
when (v.id) {
R.id.iv_nine_back -> {
AppConfig.mainMusicRefresh=true
AppConfig.mainMusicRefresh = true
refreshTaskCount()
Handler(Looper.getMainLooper()).postDelayed({
if(isFinishing) return@postDelayed
if (isFinishing) return@postDelayed
finish()
}, 500)
......@@ -116,7 +115,7 @@ class NineActivity : BaseActivity(), View.OnClickListener {
}
override fun authFail(resultStatus: String) {
showToast("支付宝授权失败 " + resultStatus)
showToast("支付宝授权失败 $resultStatus")
}
})
return
......@@ -174,14 +173,14 @@ class NineActivity : BaseActivity(), View.OnClickListener {
*/
private fun adCloseNext(carrierType: String) {
Handler(Looper.getMainLooper()).postDelayed({
if(isFinishing) return@postDelayed
if (isFinishing) return@postDelayed
startNine()
}, 500)
}
fun startNine() {
private fun startNine() {
if (!lucky_panel2.isGameRunning) {
lucky_panel2.startGame()
......@@ -198,19 +197,21 @@ class NineActivity : BaseActivity(), View.OnClickListener {
lucky_panel2.tryToStop(5)
Handler(Looper.getMainLooper()).postDelayed({
if(isFinishing) return@postDelayed
if (isFinishing) return@postDelayed
showWithdrawSucDialog(0.0)
showWithdrawSucDialog(cash)
}, 2000)
}
})
}
}
private fun showWithdrawSucDialog(cash: Double) {
private fun showWithdrawSucDialog(cash: String) {
if (mWithDrawSucDialog != null && mWithDrawSucDialog!!.isShowing) return
TrackManager.getInstance().addCashoutReq(drawId)
mWithDrawSucDialog =
WithDrawSucDialog(context, cash.toString(), object : DialogListener() {
WithDrawSucDialog(context, cash, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
super.onClick(dialog, v)
dialog?.dismiss()
......@@ -282,7 +283,7 @@ class NineActivity : BaseActivity(), View.OnClickListener {
}
override fun authFail(resultStatus: String) {
showToast("支付宝授权失败 " + resultStatus)
showToast("支付宝授权失败 $resultStatus")
}
})
return
......
......@@ -124,7 +124,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
if (AppConfig.mainMusicRefresh) {
AppConfig.mainMusicRefresh = false
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
musicPresenter.rdSongMsg()
}, 1500)
......@@ -184,10 +184,11 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
if (map == null) {
return
}
mPos = position
RxBus.getDefault().post(MsgEvent("" + map["group_id"]))
RxBus.getDefault()
.postSticky(MsgEvent("" + map["group_id"], position))
mPos = position
LogUtil.d(TAG, "onDPPageChange: $position, map = $map")
}
......@@ -244,23 +245,23 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
quizTvPop.visibility = View.GONE
finger.visibility = View.GONE
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
// 点击过后不展示
if (!rlOption0.isClickable) return@postDelayed
val ls = finger.layoutParams as RelativeLayout.LayoutParams
val ls2 = quizLLPop.layoutParams as RelativeLayout.LayoutParams
if (answer == 0) {
ls.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option0)
ls2.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option0)
} else {
ls.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option1)
ls2.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option1)
}
playFingerAnim(finger)
}, 5000)
// mainHandler.postDelayed({
// if (!isAdded) return@postDelayed
//
// // 点击过后不展示
// if (!rlOption0.isClickable || !rlOption1.isClickable) return@postDelayed
//
// val ls = finger.layoutParams as RelativeLayout.LayoutParams
// val ls2 = quizLLPop.layoutParams as RelativeLayout.LayoutParams
// if (answer == 0) {
// ls.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option0)
// ls2.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option0)
// } else {
// ls.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option1)
// ls2.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option1)
// }
// playFingerAnim(finger)
// }, 5000)
for (i in optionsList.indices) {
val right = answer == i
......@@ -334,7 +335,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
}
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
quizIv.visibility = View.GONE
}, 1000)
......@@ -356,7 +357,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
}
}
RxBus.getDefault().toObservable(MsgEvent::class.java)
RxBus.getDefault().tObservableStick(MsgEvent::class.java)
.subscribe(object : Observer<MsgEvent> {
override fun onSubscribe(d: Disposable) {
}
......@@ -364,14 +365,45 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
override fun onNext(t: MsgEvent) {
// if (!t.msg.equals(feedParamsForCallback["group_id"])) return
if (t.position != mPos) return
LogUtil.d(
TAG,
"answer -> " + answer + "nextIsAd -> " + mMusicBean?.nextIsAd
)
finger.setImageDrawable(null)
mainHandler.postDelayed({
if (!isAdded) return@postDelayed
// 点击过后不展示
if (!rlOption0.isClickable || !rlOption1.isClickable) return@postDelayed
val ls = finger.layoutParams as RelativeLayout.LayoutParams
val ls2 = quizLLPop.layoutParams as RelativeLayout.LayoutParams
if (answer == 0) {
ls.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option0)
ls2.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option0)
} else {
ls.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option1)
ls2.addRule(RelativeLayout.ALIGN_TOP, R.id.rl_option1)
}
playFingerAnim(finger)
}, 5000)
// 重置状态
// finger.visibility = View.GONE
// quizLLPop.visibility = View.GONE
// quizTvPop.visibility = View.GONE
for (i in optionsList.indices) {
val right = answer == i
quizIvRedbox0.visibility = View.GONE
quizIvRedbox1.visibility = View.GONE
if (right) {
mMusicBean?.let {
if (it.nextIsAd && optionsList[i].isClickable) {
quizIvRedbox0.visibility = View.GONE
quizIvRedbox1.visibility = View.GONE
if (i == 0) {
quizIvRedbox0.visibility =
View.VISIBLE
......@@ -384,6 +416,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
quizIvRedbox0.visibility = View.GONE
}
}
break
}
}
}
......@@ -581,7 +614,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
if (!isNineFlag) {
isNineFlag = true
Handler(Looper.getMainLooper()).postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
val bundle = Bundle()
bundle.putString(NineActivity.DRAW_ID, it.unitId)
......@@ -637,26 +670,26 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
} else {
tv_cash_reward.text = "+$cashReward"
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_cash_reward, iv_cash)
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_cash_reward, iv_cash)
}, 200)
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_cash_reward, iv_cash)
}, 400)
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_cash_reward, iv_cash)
}, 800)
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
rope = null
rope = YoYo.with(Techniques.Pulse).duration(300).playOn(rl_cash)
}, 1000)
}, 1200)
}, 100)
}
......@@ -666,31 +699,31 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
} else {
tv_gold_reward.text = "+$goldReward"
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_gold_reward, iv_gold)
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_gold_reward, iv_gold)
}, 200)
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_gold_reward, iv_gold)
}, 400)
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
addAnimation(iv_gold_reward, iv_gold)
}, 800)
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
rope = null
rope = YoYo.with(Techniques.Pulse).duration(300).playOn(rl_gold)
}, 1000)
}, 1200)
}, 100)
}
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
cl_reward.visibility = View.GONE
}, 1500)
}
......@@ -807,7 +840,7 @@ class MusicFragment : LazyLoadBaseFragment(), MusicView, View.OnClickListener {
})
mTimer?.start()
mainHandler.postDelayed({
if(!isAdded) return@postDelayed
if (!isAdded) return@postDelayed
rope = null
rope = YoYo.with(Techniques.Pulse).duration(1000).repeat(-1)
.playOn(quizLLPop)
......
......@@ -93,10 +93,14 @@ public class RxBus {
}
public static class MsgEvent {
private int position;
private String msg;
public MsgEvent(String msg) {
public MsgEvent(String msg, int position) {
this.msg = msg;
this.position = position;
}
public String getMsg() {
......@@ -106,5 +110,13 @@ public class RxBus {
public void setMsg(String msg) {
this.msg = msg;
}
public int getPosition() {
return position;
}
public void setPosition(int position) {
this.position = position;
}
}
}
\ 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