From d66fd98710ed438dce42b556d7463c63e1bc874c Mon Sep 17 00:00:00 2001 From: YunLei Date: Thu, 31 Aug 2023 17:54:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +- .../com/yzx/ebrand/activity/LoginActivity.kt | 43 ++++++++++++++----- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cf11995..1c486f1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,8 +19,8 @@ android { // minSdkVersion 26 minSdkVersion 21 targetSdkVersion 25 - versionCode 30000 - versionName "3.0.0" + versionCode 30001 + versionName "3.0.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { diff --git a/app/src/main/java/com/yzx/ebrand/activity/LoginActivity.kt b/app/src/main/java/com/yzx/ebrand/activity/LoginActivity.kt index e961650..bdc77a7 100644 --- a/app/src/main/java/com/yzx/ebrand/activity/LoginActivity.kt +++ b/app/src/main/java/com/yzx/ebrand/activity/LoginActivity.kt @@ -39,6 +39,7 @@ class LoginActivity : BaseActivity(), LoginView { } private var mTicket = "" + private var isPageShow = true override val inflateId: Int get() = R.layout.activity_login @@ -59,6 +60,7 @@ class LoginActivity : BaseActivity(), LoginView { accountLayout.visibility = View.GONE SPUtils.getInstance().put("last_login_tab_index",1) KeyboardUtils.hideSoftInput(this@LoginActivity) + mPresenter?.getWXQrCode() } } @@ -71,6 +73,7 @@ class LoginActivity : BaseActivity(), LoginView { qrLayout.visibility = View.VISIBLE accountLayout.visibility = View.GONE tabLayout.currentTab = 1 + mPresenter?.getWXQrCode() } loginBtn.setOnClickListener { this.doLogin() @@ -112,7 +115,7 @@ class LoginActivity : BaseActivity(), LoginView { } override fun initData() { - mPresenter?.getWXQrCode() + } override fun initPresenter(): LoginPresenter = LoginPresenter(this) @@ -160,16 +163,36 @@ class LoginActivity : BaseActivity(), LoginView { 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() { qrCodeImg?.apply { - removeCallbacks(null) + removeCallbacks(mRun) } super.onDestroy() } - private var mBindDialog: QMUIDialog? = null - private var mOverTimeDialog: QMUIDialog? = null - override fun onLoginQuerySuccess(user: BaseUser, code: Int) { when (code) { 0 -> { @@ -194,15 +217,13 @@ class LoginActivity : BaseActivity(), LoginView { } else if (!mBindDialog!!.isShowing) { mBindDialog?.show() } - qrCodeImg.postDelayed({ - mPresenter?.loginQuery(mTicket) - }, 1000) + qrCodeImg.removeCallbacks(mRun) + qrCodeImg.postDelayed(mRun, 1000) } 452 -> { - qrCodeImg.postDelayed({ - mPresenter?.loginQuery(mTicket) - }, 1000) + qrCodeImg.removeCallbacks(mRun) + qrCodeImg.postDelayed(mRun, 1000) } else -> {