Commit 6c51f049 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 59fb3492
......@@ -3,20 +3,28 @@ package com.wenshu.youyou.ui.activitys
import android.content.Context
import android.media.AudioManager
import android.os.Bundle
import android.text.TextUtils
import android.view.KeyEvent
import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import com.wenshu.library.utils.CommonUtils
import com.wenshu.youyou.MintsApplication
import com.wenshu.youyou.R
import com.wenshu.youyou.ad.video.VideoAdingManager
import com.wenshu.youyou.common.AppConfig
import com.wenshu.youyou.common.Constant
import com.wenshu.youyou.ad.express.TTPreLoadCarrierExpressManager
import com.wenshu.youyou.manager.ShumeiManager
import com.wenshu.youyou.manager.WnManager
import com.wenshu.youyou.mvp.views.MainView
import com.wenshu.youyou.ui.activitys.base.BaseActivity
import com.wenshu.youyou.ui.fragment.*
import com.wenshu.youyou.ui.widgets.DialogListener
import com.wenshu.youyou.ui.widgets.PowerDialog
import kotlinx.android.synthetic.main.activity_main.*
import net.grandcentrix.tray.AppPreferences
/**
* 描述:main
......@@ -26,6 +34,9 @@ import kotlinx.android.synthetic.main.activity_main.*
*/
class MainActivity : BaseActivity(), MainView, View.OnClickListener {
private var powerDialog: PowerDialog? = null
private val ps by lazy { AppPreferences(context) }
private val audioManager by lazy { getSystemService(Context.AUDIO_SERVICE) as AudioManager }
// 底部标签切换的Fragment
......@@ -81,6 +92,52 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
tab_rl_two.setOnClickListener(this)
tab_rl_four.setOnClickListener(this)
tab_rl_five.setOnClickListener(this)
// 首次显示权限弹窗
showPowerDialog()
}
private fun showPowerDialog() {
if (ps.getBoolean(Constant.LOAN_PERMISSION_FLAG, true)) {
powerDialog()
}
}
private fun powerDialog() {
powerDialog = PowerDialog(this, object : DialogListener() {
override fun onClick(v: View) {
when (v.id) {
R.id.tv_dialogper_agreement -> {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.register_name))
bundle.putString(WebActivity.WEB_URL, Constant.REGISTER_URL)
readyGo(WebActivity::class.java, bundle)
}
R.id.tv_dialogper_policy -> {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.privacy_name))
bundle.putString(WebActivity.WEB_URL, Constant.PRIVACY_URL)
readyGo(WebActivity::class.java, bundle)
}
R.id.btn_dialogper_back -> {
if (!isFinishing &&
powerDialog != null && powerDialog!!.isShowing
) {
showToast("请您同意授权,否则将无法使用APP功能")
}
}
R.id.btn_dialogper_next -> {
if (!isFinishing &&
powerDialog != null && powerDialog!!.isShowing
) {
powerDialog!!.dismiss()
ps.put(Constant.LOAN_PERMISSION_FLAG, false)
}
}
}
}
})
powerDialog!!.show()
}
override fun isApplyKitKatTranslucency() = false
......
......@@ -287,10 +287,10 @@ class MyFragment : BaseFragment(),
}
override fun signInHomePageSuc() {
val bundle = Bundle()
bundle.putInt(Constant.MAIN_CUR_COIN, curSignCoin)
bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_SIGNIN_HOMEPAGE_AWARD)
readyGo(AwardActivity::class.java, bundle)
// val bundle = Bundle()
// bundle.putInt(Constant.MAIN_CUR_COIN, curSignCoin)
// bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_SIGNIN_HOMEPAGE_AWARD)
// readyGo(AwardActivity::class.java, bundle)
}
override fun userLoginSuc() {
......
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