diff --git a/app/src/main/java/com/kaixed/kchat/network/NetworkInterface.kt b/app/src/main/java/com/kaixed/kchat/network/NetworkInterface.kt index cba1e43..e533084 100644 --- a/app/src/main/java/com/kaixed/kchat/network/NetworkInterface.kt +++ b/app/src/main/java/com/kaixed/kchat/network/NetworkInterface.kt @@ -7,6 +7,8 @@ package com.kaixed.kchat.network object NetworkInterface { private const val URL = "app.kaixed.com/kchat" + +// private const val URL = "192.168.45.209:6196/kchat" const val SERVER_URL = "https://$URL" const val WEBSOCKET_SERVER_URL = "wss://$URL" const val WEBSOCKET = "/websocket/single/" diff --git a/app/src/main/java/com/kaixed/kchat/network/RetrofitClient.kt b/app/src/main/java/com/kaixed/kchat/network/RetrofitClient.kt index e3c151b..d9801af 100644 --- a/app/src/main/java/com/kaixed/kchat/network/RetrofitClient.kt +++ b/app/src/main/java/com/kaixed/kchat/network/RetrofitClient.kt @@ -15,7 +15,7 @@ import retrofit2.converter.gson.GsonConverterFactory object RetrofitClient { private const val BASE_URL = "https://app.kaixed.com/kchat/" -// private const val BASE_URL = "http://192.168.156.209:6196/" +// private const val BASE_URL = "http://192.168.45.209:6196/" private val loggingInterceptor = HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY diff --git a/app/src/main/java/com/kaixed/kchat/ui/activity/ApplyAddFriendActivity.kt b/app/src/main/java/com/kaixed/kchat/ui/activity/ApplyAddFriendActivity.kt index 086da38..9b083d9 100644 --- a/app/src/main/java/com/kaixed/kchat/ui/activity/ApplyAddFriendActivity.kt +++ b/app/src/main/java/com/kaixed/kchat/ui/activity/ApplyAddFriendActivity.kt @@ -22,6 +22,18 @@ class ApplyAddFriendActivity : BaseActivity() { super.onCreate(savedInstanceState) enableEdgeToEdge() setListener() + observeData() + } + + private fun observeData() { + contactViewModel.addContactResult + .observe(this) { result -> + result.onSuccess { + toast(result.getOrNull().toString()) + finish() + } + result.onFailure { toast(it.message.toString()) } + } } private fun setListener() { @@ -38,14 +50,6 @@ class ApplyAddFriendActivity : BaseActivity() { private fun sendContactRequest(contactId: String?) { contactId?.let { - contactViewModel.addContactResult - .observe(this) { result -> - result.onSuccess { - toast(result.getOrNull().toString()) - finish() - } - result.onFailure { toast(it.message.toString()) } - } contactViewModel.addContact(contactId, binding.etMessage.text.toString()) } } diff --git a/app/src/main/java/com/kaixed/kchat/ui/activity/LoginActivity.kt b/app/src/main/java/com/kaixed/kchat/ui/activity/LoginActivity.kt index 57e457c..24ffe07 100644 --- a/app/src/main/java/com/kaixed/kchat/ui/activity/LoginActivity.kt +++ b/app/src/main/java/com/kaixed/kchat/ui/activity/LoginActivity.kt @@ -67,9 +67,10 @@ class LoginActivity : BaseActivity() { private fun login(username: String, password: String) { if (!loginByUsername) { - etUsername.text.toString().length != 11 - toast("请输入正确的手机号码") - return + if(etUsername.text.toString().length != 11){ + toast("请输入正确的手机号码") + return + } } if (username.isEmpty() || password.isEmpty()) { toast("请输入${if (loginByUsername) "用户名" else "手机号"}或密码") diff --git a/app/src/main/java/com/kaixed/kchat/ui/activity/ProfileDetailActivity.kt b/app/src/main/java/com/kaixed/kchat/ui/activity/ProfileDetailActivity.kt index 49c177f..2402145 100644 --- a/app/src/main/java/com/kaixed/kchat/ui/activity/ProfileDetailActivity.kt +++ b/app/src/main/java/com/kaixed/kchat/ui/activity/ProfileDetailActivity.kt @@ -175,6 +175,7 @@ class ProfileDetailActivity : BaseActivity() { private fun updateContent(username: String) { val userInfo = userInfoBox.query(UserInfo_.username.equal(username)).build().findFirst() if (userInfo != null) { + binding.ciKid.setItemDesc(userInfo.username) binding.ciNickname.setItemDesc(userInfo.nickname) val avatarUrl = extractDimensionsAndPrefix(userInfo.avatarUrl)?.first ?: userInfo.avatarUrl diff --git a/app/src/main/java/com/kaixed/kchat/ui/activity/RegisterActivity.kt b/app/src/main/java/com/kaixed/kchat/ui/activity/RegisterActivity.kt index 86a9a1a..6741347 100644 --- a/app/src/main/java/com/kaixed/kchat/ui/activity/RegisterActivity.kt +++ b/app/src/main/java/com/kaixed/kchat/ui/activity/RegisterActivity.kt @@ -5,7 +5,6 @@ import android.graphics.Color import android.graphics.Typeface import android.os.Bundle import android.text.Editable -import android.text.SpannableString import android.text.TextPaint import android.text.method.LinkMovementMethod import android.text.style.ClickableSpan @@ -44,7 +43,17 @@ class RegisterActivity : BaseActivity() { } override fun initData() { + userViewModel.registerResult.observe(this) { result -> + result.onSuccess { + toast("注册成功,请前往登录界面登录") + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } + result.onFailure { + toast(it.message.toString()) + } + } } private fun setOnClickListener() { @@ -58,7 +67,6 @@ class RegisterActivity : BaseActivity() { } private fun onContinueClick() { - if (!tvContinueEnable) return val telephone = binding.etUsername.text.toString().trim() if (telephone.length != 11) { toast("请输入正确的手机号") @@ -79,18 +87,6 @@ class RegisterActivity : BaseActivity() { signature: String, telephone: String ) { - userViewModel.registerResult.observe(this) { result -> - result.onSuccess { - toast("注册成功,请前往登录界面登录") - startActivity(Intent(this, LoginActivity::class.java)) - finish() - } - - result.onFailure { - toast(it.message.toString()) - } - } - val registerRequest = RegisterRequest( nickname = nickname, password = password, @@ -142,17 +138,17 @@ class RegisterActivity : BaseActivity() { } private fun setupTip() { - val clickableSpan: ClickableSpan = object : ClickableSpan() { - override fun onClick(widget: View) { - toast("暂未编写") - } - - override fun updateDrawState(ds: TextPaint) { - super.updateDrawState(ds) - ds.color = Color.parseColor("#576B95") - ds.isUnderlineText = false - } - } +// val clickableSpan: ClickableSpan = object : ClickableSpan() { +// override fun onClick(widget: View) { +// toast("暂未编写") +// } +// +// override fun updateDrawState(ds: TextPaint) { +// super.updateDrawState(ds) +// ds.color = Color.parseColor("#576B95") +// ds.isUnderlineText = false +// } +// } binding.tvTip.text = "我已阅读并同意《软件许可及服务协议》\n本页面收集的信息仅用于注册账户".replaceSpan("《软件许可及服务协议》") { diff --git a/app/src/main/java/com/kaixed/kchat/ui/widget/CustomItem.kt b/app/src/main/java/com/kaixed/kchat/ui/widget/CustomItem.kt index 96903cd..f9a9c11 100644 --- a/app/src/main/java/com/kaixed/kchat/ui/widget/CustomItem.kt +++ b/app/src/main/java/com/kaixed/kchat/ui/widget/CustomItem.kt @@ -6,7 +6,6 @@ import android.net.Uri import android.util.AttributeSet import android.view.LayoutInflater import android.view.View -import android.widget.Toast import androidx.constraintlayout.widget.ConstraintLayout import com.bumptech.glide.Glide import com.kaixed.kchat.R @@ -162,11 +161,13 @@ class CustomItem @JvmOverloads constructor( fun setItemIcon(uri: Uri) { Glide.with(context).load(uri) + .error(R.drawable.ic_default_avatar) .into(binding.ivItemIcon) } fun setItemIcon(url: String) { Glide.with(context).load(url) + .error(R.drawable.ic_default_avatar) .into(binding.ivItemIcon) } diff --git a/app/src/main/res/layout/activity_profile_detail.xml b/app/src/main/res/layout/activity_profile_detail.xml index c88baeb..88e6ed0 100644 --- a/app/src/main/res/layout/activity_profile_detail.xml +++ b/app/src/main/res/layout/activity_profile_detail.xml @@ -49,11 +49,12 @@ app:itemName="拍一拍" /> + app:itemName="星联号" /> - 192.168.156.209 + 192.168.45.209