缓存上次加入的群组
This commit is contained in:
parent
b0a5eb7234
commit
2e3de6b968
|
|
@ -345,6 +345,8 @@ public class CallBackResolution {
|
||||||
indexGroupId = userGroupId;
|
indexGroupId = userGroupId;
|
||||||
indexGroupName = userGroupName;
|
indexGroupName = userGroupName;
|
||||||
CallBackUtil.callBackNotifyUpdateGroup(userGroupId, userGroupName);
|
CallBackUtil.callBackNotifyUpdateGroup(userGroupId, userGroupName);
|
||||||
|
// 触发首次进入群组状态
|
||||||
|
com.stand.standapp.MainActivity.onFirstGroupEntered();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -453,6 +453,9 @@ class AndroidInterface(private val activity: MainActivity) {
|
||||||
com.stand.standapp.MainActivity.executeJs("if(window.appLogin){window.appLogin('$escaped');}")
|
com.stand.standapp.MainActivity.executeJs("if(window.appLogin){window.appLogin('$escaped');}")
|
||||||
Timber.tag("AndroidInterface").d("Called appLogin")
|
Timber.tag("AndroidInterface").d("Called appLogin")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 页面加载并初始化完成后触发状态
|
||||||
|
com.stand.standapp.MainActivity.onPageLoadFinished()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.tag("UI").e(e, "隐藏加载布局失败")
|
Timber.tag("UI").e(e, "隐藏加载布局失败")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,22 +43,65 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var hasFirstGroupEntered = false
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var hasPageFinished = false
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var hasAutoJumped = false
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun onFirstGroupEntered() {
|
||||||
|
Timber.tag("PTT").d("Condition met: First group entered")
|
||||||
|
hasFirstGroupEntered = true
|
||||||
|
checkAndAutoJumpToLastGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun onPageLoadFinished() {
|
||||||
|
Timber.tag("PTT").d("Condition met: Web page loaded and initialized")
|
||||||
|
hasPageFinished = true
|
||||||
|
checkAndAutoJumpToLastGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun resetAutoJumpStates() {
|
||||||
|
hasFirstGroupEntered = false
|
||||||
|
hasPageFinished = false
|
||||||
|
hasAutoJumped = false
|
||||||
|
Timber.tag("PTT").d("Auto jump states reset")
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun checkAndAutoJumpToLastGroup() {
|
||||||
|
synchronized(this) {
|
||||||
|
if (hasFirstGroupEntered && hasPageFinished && !hasAutoJumped) {
|
||||||
|
hasAutoJumped = true
|
||||||
|
instance?.let { ctx ->
|
||||||
|
val lastGroupId = AppConfig.getLastGroupId(ctx)
|
||||||
|
if (lastGroupId.isNotEmpty()) {
|
||||||
|
Timber.tag("PTT").d("Both conditions met. Auto-jumping to last joined group: %s after 2s delay", lastGroupId)
|
||||||
|
ctx.runOnUiThread {
|
||||||
|
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
|
||||||
|
instance?.pttInterface?.pttJumpGroup(lastGroupId)
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Timber.tag("PTT").d("Both conditions met but lastGroupId is empty, skip auto-jump")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Timber.tag("PTT").d("Check auto jump: hasFirstGroupEntered=$hasFirstGroupEntered, hasPageFinished=$hasPageFinished, hasAutoJumped=$hasAutoJumped")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onPttLoginSuccess() {
|
fun onPttLoginSuccess() {
|
||||||
Timber.tag("MainActivity").d("onPttLoginSuccess called from Native")
|
Timber.tag("MainActivity").d("onPttLoginSuccess called from Native")
|
||||||
executeJs("onPttLoginSuccess()")
|
executeJs("onPttLoginSuccess()")
|
||||||
|
|
||||||
instance?.let { ctx ->
|
|
||||||
val lastGroupId = AppConfig.getLastGroupId(ctx)
|
|
||||||
if (lastGroupId.isNotEmpty()) {
|
|
||||||
Timber.tag("PTT").d("Auto-jumping to last joined group: %s after delay", lastGroupId)
|
|
||||||
ctx.runOnUiThread {
|
|
||||||
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
|
|
||||||
instance?.pttInterface?.pttJumpGroup(lastGroupId)
|
|
||||||
}, 2000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 硬件按键触发
|
// 硬件按键触发
|
||||||
|
|
@ -500,6 +543,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
Timber.tag("MainActivity").e(e, "Failed to redirect to LoginActivity")
|
Timber.tag("MainActivity").e(e, "Failed to redirect to LoginActivity")
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
resetAutoJumpStates()
|
||||||
CallBackResolution.resetPttLoginStatus();
|
CallBackResolution.resetPttLoginStatus();
|
||||||
}catch (e: Exception) {
|
}catch (e: Exception) {
|
||||||
Timber.tag("MainActivity").e(e, "Failed to clear public value")
|
Timber.tag("MainActivity").e(e, "Failed to clear public value")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue