fix: 修复登录注册判断逻辑

This commit is contained in:
糕小菜 2024-12-25 11:26:57 +08:00
parent c5b16664bc
commit b6af7650d1
9 changed files with 46 additions and 40 deletions

View File

@ -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/"

View File

@ -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

View File

@ -22,6 +22,18 @@ class ApplyAddFriendActivity : BaseActivity<ActivityApplyAddFriendBinding>() {
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<ActivityApplyAddFriendBinding>() {
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())
}
}

View File

@ -67,10 +67,11 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>() {
private fun login(username: String, password: String) {
if (!loginByUsername) {
etUsername.text.toString().length != 11
if(etUsername.text.toString().length != 11){
toast("请输入正确的手机号码")
return
}
}
if (username.isEmpty() || password.isEmpty()) {
toast("请输入${if (loginByUsername) "用户名" else "手机号"}或密码")
}

View File

@ -175,6 +175,7 @@ class ProfileDetailActivity : BaseActivity<ActivityProfileDetailBinding>() {
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

View File

@ -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<ActivityRegisterBinding>() {
}
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<ActivityRegisterBinding>() {
}
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<ActivityRegisterBinding>() {
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<ActivityRegisterBinding>() {
}
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("《软件许可及服务协议》") {

View File

@ -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)
}

View File

@ -49,11 +49,12 @@
app:itemName="拍一拍" />
<com.kaixed.kchat.ui.widget.CustomItem
android:id="@+id/ci_kid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:isTopDividerVisible="true"
app:itemDesc="kaixed"
app:itemName="微信号" />
app:itemName="星联号" />
<com.kaixed.kchat.ui.widget.CustomItem
android:layout_width="match_parent"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">192.168.156.209</domain>
<domain includeSubdomains="true">192.168.45.209</domain>
</domain-config>
</network-security-config>