YunLei 2 лет назад
Родитель
Сommit
d66fd98710
2 измененных файлов: 34 добавлений и 13 удалений
  1. +2
    -2
      app/build.gradle
  2. +32
    -11
      app/src/main/java/com/yzx/ebrand/activity/LoginActivity.kt

+ 2
- 2
app/build.gradle Просмотреть файл

@@ -19,8 +19,8 @@ android {
// minSdkVersion 26 // minSdkVersion 26
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 25 targetSdkVersion 25
versionCode 30000
versionName "3.0.0"
versionCode 30001
versionName "3.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


ndk { ndk {


+ 32
- 11
app/src/main/java/com/yzx/ebrand/activity/LoginActivity.kt Просмотреть файл

@@ -39,6 +39,7 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
} }


private var mTicket = "" private var mTicket = ""
private var isPageShow = true


override val inflateId: Int override val inflateId: Int
get() = R.layout.activity_login get() = R.layout.activity_login
@@ -59,6 +60,7 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
accountLayout.visibility = View.GONE accountLayout.visibility = View.GONE
SPUtils.getInstance().put("last_login_tab_index",1) SPUtils.getInstance().put("last_login_tab_index",1)
KeyboardUtils.hideSoftInput(this@LoginActivity) KeyboardUtils.hideSoftInput(this@LoginActivity)
mPresenter?.getWXQrCode()
} }
} }


@@ -71,6 +73,7 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
qrLayout.visibility = View.VISIBLE qrLayout.visibility = View.VISIBLE
accountLayout.visibility = View.GONE accountLayout.visibility = View.GONE
tabLayout.currentTab = 1 tabLayout.currentTab = 1
mPresenter?.getWXQrCode()
} }
loginBtn.setOnClickListener { loginBtn.setOnClickListener {
this.doLogin() this.doLogin()
@@ -112,7 +115,7 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
} }


override fun initData() { override fun initData() {
mPresenter?.getWXQrCode()
} }


override fun initPresenter(): LoginPresenter = LoginPresenter(this) override fun initPresenter(): LoginPresenter = LoginPresenter(this)
@@ -160,16 +163,36 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
mPresenter?.loginQuery(ticket) mPresenter?.loginQuery(ticket)
} }


private var mBindDialog: QMUIDialog? = null
private var mOverTimeDialog: QMUIDialog? = null
private var mRun = Runnable {
if(isPageShow){
mPresenter?.loginQuery(mTicket)
}
}

override fun onResume() {
super.onResume()
this.isPageShow = true
if(this.mTicket.isNotEmpty()){
qrCodeImg?.apply {
postDelayed(mRun,1000)
}
}
}

override fun onStop() {
super.onStop()
this.isPageShow = false
}

override fun onDestroy() { override fun onDestroy() {
qrCodeImg?.apply { qrCodeImg?.apply {
removeCallbacks(null)
removeCallbacks(mRun)
} }
super.onDestroy() super.onDestroy()
} }


private var mBindDialog: QMUIDialog? = null
private var mOverTimeDialog: QMUIDialog? = null

override fun onLoginQuerySuccess(user: BaseUser, code: Int) { override fun onLoginQuerySuccess(user: BaseUser, code: Int) {
when (code) { when (code) {
0 -> { 0 -> {
@@ -194,15 +217,13 @@ class LoginActivity : BaseActivity<LoginPresenter>(), LoginView {
} else if (!mBindDialog!!.isShowing) { } else if (!mBindDialog!!.isShowing) {
mBindDialog?.show() mBindDialog?.show()
} }
qrCodeImg.postDelayed({
mPresenter?.loginQuery(mTicket)
}, 1000)
qrCodeImg.removeCallbacks(mRun)
qrCodeImg.postDelayed(mRun, 1000)
} }


452 -> { 452 -> {
qrCodeImg.postDelayed({
mPresenter?.loginQuery(mTicket)
}, 1000)
qrCodeImg.removeCallbacks(mRun)
qrCodeImg.postDelayed(mRun, 1000)
} }


else -> { else -> {


Загрузка…
Отмена
Сохранить