新增对话

This commit is contained in:
2024-09-23 23:47:16 +08:00
parent 2b79ff319f
commit b94d8fb7b3
18 changed files with 743 additions and 51 deletions

View File

@@ -34,10 +34,15 @@ import com.aiosman.riderpro.ui.navigateToPost
import com.aiosman.riderpro.ui.post.NewPostViewModel
import com.aiosman.riderpro.utils.Utils
import com.google.firebase.analytics.FirebaseAnalytics
import com.tencent.imsdk.v2.V2TIMCallback
import com.tencent.imsdk.v2.V2TIMLogListener
import com.tencent.imsdk.v2.V2TIMManager
import com.tencent.imsdk.v2.V2TIMSDKConfig
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class MainActivity : ComponentActivity() {
// Firebase Analytics
private lateinit var analytics: FirebaseAnalytics
@@ -50,7 +55,7 @@ class MainActivity : ComponentActivity() {
if (isGranted) {
// FCM SDK (and your app) can post notifications.
} else {
// TODO: Inform user that that your app will not show notifications.
}
}
@@ -61,17 +66,6 @@ class MainActivity : ComponentActivity() {
val accountService: AccountService = AccountServiceImpl()
try {
val resp = accountService.getMyAccount()
val calendar: Calendar = Calendar.getInstance()
val tz: TimeZone = calendar.timeZone
val offsetInMillis: Int = tz.rawOffset
accountService.updateUserExtra(
Utils.getCurrentLanguage(),
// 时区偏移量单位是秒
offsetInMillis / 1000,
tz.displayName
)
// 设置当前登录用户 ID
AppState.UserId = resp.id
return true
} catch (e: Exception) {
return false
@@ -102,11 +96,9 @@ class MainActivity : ComponentActivity() {
JPushInterface.init(this)
// JPushInterface.setAlias(this, 0, "myTest")
// Log.d("MainActivity", "pushId: $pushId")
enableEdgeToEdge()
// 初始化腾讯云通信 SDK
scope.launch {
@@ -115,9 +107,10 @@ class MainActivity : ComponentActivity() {
var startDestination = NavigationRoute.Login.route
// 如果有登录态,且记住登录状态,且账号有效,则初始化 FCM下一步进入首页
if (AppStore.token != null && AppStore.rememberMe && isAccountValidate) {
Messaging.RegistDevice(scope, this@MainActivity)
AppState.initWithAccount(scope, this@MainActivity)
startDestination = NavigationRoute.Index.route
}
setContent {
Navigation(startDestination) { navController ->
// 处理带有 postId 的通知点击