tongmengxiao 5 hónapja
szülő
commit
6b538bf323

+ 47 - 0
baseswago/src/main/java/com/swago/baseswago/dialog/CloseAccountDialog.kt

@@ -0,0 +1,47 @@
+package com.swago.baseswago.dialog
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.view.View.OnClickListener
+import com.alibaba.android.arouter.launcher.ARouter
+import com.swago.baseswago.constant.ARouteConstant
+import com.swago.baseswago.databinding.DialogCloseAccountBinding
+import com.swago.baseswago.databinding.DialogInviteBindingBinding
+import com.swago.baseswago.dialog.BaseXDFragment
+import com.swago.baseswago.util.SpUtil
+import com.swago.baseswago.util.UserInfo
+
+class CloseAccountDialog : BaseXDFragment<DialogCloseAccountBinding>() {
+
+    init {
+        setGravity(Gravity.CENTER)
+        setDimAmount(0.5f)
+        setCanCancel(false)
+    }
+
+    companion object {
+        fun newInstance(): CloseAccountDialog {
+            val args = Bundle()
+            val fragment = CloseAccountDialog()
+            fragment.arguments = args
+            return fragment
+        }
+    }
+
+    override fun initOther() {
+        binding.tvOk.setOnClickListener {
+            UserInfo.clearUserInfo()
+            SpUtil.clearSp()
+            ARouter.getInstance().build(ARouteConstant.Login.login)
+                .withFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
+                .navigation()
+            dismissAllowingStateLoss()
+        }
+    }
+
+    override fun initLiveData() {
+
+    }
+}

+ 3 - 4
room/src/main/java/com/swago/room/dialog/CloseLiveDialog.kt → baseswago/src/main/java/com/swago/baseswago/dialog/CloseLiveDialog.kt

@@ -1,12 +1,11 @@
-package com.swago.room.dialog
+package com.swago.baseswago.dialog
 
 import android.os.Bundle
 import android.os.CountDownTimer
 import android.view.Gravity
-import com.swago.baseswago.dialog.BaseXDFragment
+import com.swago.baseswago.R
+import com.swago.baseswago.databinding.DialogCloseLiveBinding
 import com.swago.baseswago.util.AppContext
-import com.swago.room.R
-import com.swago.room.databinding.DialogCloseLiveBinding
 
 class CloseLiveDialog : BaseXDFragment<DialogCloseLiveBinding>() {
     var closeLive:(()->Unit)? = null

+ 29 - 0
baseswago/src/main/java/com/swago/baseswago/im/GroupMsgParser.kt

@@ -9,7 +9,10 @@ import com.swago.baseswago.im.ImConstant.beauty_game
 import com.swago.baseswago.im.ImConstant.beauty_game_grab_host
 import com.swago.baseswago.im.ImConstant.beauty_game_grab_host_two
 import com.swago.baseswago.im.ImConstant.beauty_game_host
+import com.swago.baseswago.im.ImConstant.bind_anchor
 import com.swago.baseswago.im.ImConstant.cancel_forbid_speak
+import com.swago.baseswago.im.ImConstant.change_user_name
+import com.swago.baseswago.im.ImConstant.close_account
 import com.swago.baseswago.im.ImConstant.close_mic_chat
 import com.swago.baseswago.im.ImConstant.common_game_msg
 import com.swago.baseswago.im.ImConstant.delete_room_admin
@@ -337,6 +340,32 @@ class GroupMsgParser : IGroupNewMsgParser {
                     )
                     parserModel = gson.fromJson(resultString,parameterizedTypeImpl)
                 }
+                change_user_name -> {
+                    parameterizedTypeImpl = ParameterizedTypeImpl(
+                        arrayOf<Type>(ChangeNameData::class.java),
+                        CusNewMsgBean::class.java,
+                        CusNewMsgBean::class.java
+                    )
+                    parserModel = gson.fromJson(resultString,parameterizedTypeImpl)
+                }
+
+                bind_anchor -> {
+                    parameterizedTypeImpl = ParameterizedTypeImpl(
+                        arrayOf<Type>(BindAnchorData::class.java),
+                        CusNewMsgBean::class.java,
+                        CusNewMsgBean::class.java
+                    )
+                    parserModel = gson.fromJson(resultString,parameterizedTypeImpl)
+                }
+
+                close_account -> {
+                    parameterizedTypeImpl = ParameterizedTypeImpl(
+                        arrayOf<Type>(CloseAccountData::class.java),
+                        CusNewMsgBean::class.java,
+                        CusNewMsgBean::class.java
+                    )
+                    parserModel = gson.fromJson(resultString,parameterizedTypeImpl)
+                }
 
             }
             parserModel?.v2TIMMessage = v2TIMMessage

+ 14 - 0
baseswago/src/main/java/com/swago/baseswago/im/ImConstant.kt

@@ -229,6 +229,20 @@ object ImConstant {
      */
     const val modify_wish_gift = 404
 
+    /**
+     * 家族长绑定主播
+     * */
+    const val bind_anchor = 501
+
+    /**
+     * 封号下发的im
+     * */
+    const val close_account= 502
+    /**
+     * 重置用户昵称
+     * */
+    const val change_user_name = 503
+
     /**********游戏相关IM********/
     const val fruit_game = 1001
     const val beauty_game = 1002

+ 10 - 0
baseswago/src/main/java/com/swago/baseswago/model/im/BindAnchorData.kt

@@ -0,0 +1,10 @@
+package com.swago.baseswago.model.im
+
+data class BindAnchorData(
+    val userId:String = "",
+    val agentId:String = "",
+    val agentName:String = "",
+    val agentNickName:String = "",
+    val logId:Int = 0,
+    val broadcastLevel:Int = 0
+)

+ 6 - 0
baseswago/src/main/java/com/swago/baseswago/model/im/ChangeNameData.kt

@@ -0,0 +1,6 @@
+package com.swago.baseswago.model.im
+
+data class ChangeNameData(
+    val userId:String = "",
+    val userName:String = ""
+)

+ 10 - 0
baseswago/src/main/java/com/swago/baseswago/model/im/CloseAccountData.kt

@@ -0,0 +1,10 @@
+package com.swago.baseswago.model.im
+
+data class CloseAccountData(
+    val userId:String = "",
+    val agentId:String = "",
+    val agentName:String = "",
+    val agentNickName:String = "",
+    val logId:Int = 0,
+    val broadcastLevel:Int = 0
+)

+ 84 - 0
baseswago/src/main/res/layout/dialog_close_account.xml

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    app:layout_constraintTop_toTopOf="parent">
+
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/cl_content"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp"
+        android:background="@drawable/shape_white_20"
+        android:paddingBottom="30dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintTop_toTopOf="parent">
+
+
+        <TextView
+            android:id="@+id/tv_invite_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="30dp"
+            android:text="@string/tips"
+            android:textColor="#0F172A"
+            android:textSize="18sp"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <TextView
+            android:id="@+id/tv_hint"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="16dp"
+            android:text="@string/close_account_connect_service"
+            android:textColor="#0F172A"
+            android:textSize="14sp"
+            android:gravity="center"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_invite_title" />
+
+        <TextView
+            android:id="@+id/tvOk"
+            android:layout_width="match_parent"
+            android:layout_height="44dp"
+            android:layout_marginTop="20dp"
+            android:layout_marginEnd="24dp"
+            android:layout_marginStart="24dp"
+            android:background="@drawable/shape_ff56b7_37"
+            android:gravity="center"
+            android:text="OK"
+            android:textColor="#fff"
+            android:textSize="@dimen/sp_16"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_hint" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <ImageView
+        android:id="@+id/iv_bg"
+        android:layout_width="match_parent"
+        android:layout_height="100dp"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp"
+        android:background="@mipmap/bg_invite"
+        app:layout_constraintTop_toTopOf="@+id/cl_content" />
+
+    <ImageView
+        android:id="@+id/iv_close"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="20dp"
+        android:src="@mipmap/ic_finish_password"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/cl_content" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 0 - 0
room/src/main/res/layout/dialog_close_live.xml → baseswago/src/main/res/layout/dialog_close_live.xml


+ 1 - 0
baseswago/src/main/res/layout/dialog_enter_password.xml

@@ -40,6 +40,7 @@
             android:text="@string/enter_password"
             android:textColor="#0F172A"
             android:textSize="14sp"
+            android:gravity="center"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toBottomOf="@+id/tv_invite_title" />

+ 1 - 0
baseswago/src/main/res/layout/dialog_invite_binding.xml

@@ -51,6 +51,7 @@
             android:layout_marginStart="20dp"
             android:layout_marginEnd="20dp"
             android:layout_marginTop="24dp"
+            android:gravity="center"
             app:layout_constraintTop_toBottomOf="@+id/tv_invite_title"/>
 
         <LinearLayout

+ 0 - 0
room/src/main/res/mipmap-xxhdpi/bg_close_live.png → baseswago/src/main/res/mipmap-xxhdpi/bg_close_live.png


+ 0 - 0
room/src/main/res/mipmap-xxhdpi/ic_close_live.png → baseswago/src/main/res/mipmap-xxhdpi/ic_close_live.png


+ 1 - 0
baseswago/src/main/res/values-ar/strings.xml

@@ -276,4 +276,5 @@
     <string name="live_setting">يتأكد</string>
     <string name="enter_room_password">الرجاء إدخال كلمة المرور للغرفة</string>
     <string name="connect_error_retry">اتصال غير طبيعي، يرجى التحقق من اتصال الشبكة</string>
+    <string name="close_account_connect_service">تم حظر حسابك، يرجى الاتصال بخدمة العملاء إذا كان لديك أي أسئلة!</string>
 </resources>

+ 1 - 0
baseswago/src/main/res/values-in/strings.xml

@@ -280,4 +280,5 @@
     <string name="live_setting">Konfirmasi</string>
     <string name="enter_room_password">Silakan masukkan kata sandi</string>
     <string name="connect_error_retry">Koneksi tidak normal, silakan periksa koneksi jaringan</string>
+    <string name="close_account_connect_service">Akun Anda telah diblokir, silakan hubungi layanan pelanggan jika Anda memiliki pertanyaan!</string>
 </resources>

+ 1 - 0
baseswago/src/main/res/values-ms/strings.xml

@@ -277,4 +277,5 @@
     <string name="live_setting">Konfirmasi</string>
     <string name="enter_room_password">Silakan masukkan kata sandi</string>
     <string name="connect_error_retry">Koneksi tidak normal, silakan periksa koneksi jaringan</string>
+    <string name="close_account_connect_service">Akun Anda telah diblokir, silakan hubungi layanan pelanggan jika Anda memiliki pertanyaan!</string>
 </resources>

+ 1 - 0
baseswago/src/main/res/values-zh/strings.xml

@@ -276,4 +276,5 @@
     <string name="live_setting">确认</string>
     <string name="enter_room_password">请输入房间密码</string>
     <string name="connect_error_retry">连接异常,请检查网络连接</string>
+    <string name="close_account_connect_service">您的账号已封禁,如有疑问请联系客服!</string>
 </resources>

+ 1 - 0
baseswago/src/main/res/values/strings.xml

@@ -298,4 +298,5 @@
     <string name="live_setting">confirm</string>
     <string name="enter_room_password">Please enter room password</string>
     <string name="connect_error_retry">Abnormal connection, please check the network connection</string>
+    <string name="close_account_connect_service">Your account has been blocked, please contact customer service if you have any questions!</string>
 </resources>

+ 32 - 1
home/src/main/java/com/swago/home/HomeActivity.kt

@@ -3,15 +3,22 @@ package com.swago.home
 import android.text.TextUtils
 import android.widget.Toast
 import androidx.activity.viewModels
+import androidx.fragment.app.FragmentActivity
+import androidx.fragment.app.viewModels
 import androidx.lifecycle.lifecycleScope
 import androidx.viewpager.widget.ViewPager
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.android.billingclient.api.Purchase
+import com.google.gson.Gson
 import com.swago.baseswago.PayVm
 import com.swago.baseswago.SwagoAdapter
+import com.swago.baseswago.UserVm
 import com.swago.baseswago.activity.BaseXActivity
 import com.swago.baseswago.constant.ARouteConstant
 import com.swago.baseswago.constant.UrlConstant
+import com.swago.baseswago.dialog.CloseAccountDialog
+import com.swago.baseswago.dialog.ForceOfflineDialog
+import com.swago.baseswago.dialog.InviteBindingDialog
 import com.swago.baseswago.dialog.OrderLostDialog
 import com.swago.baseswago.im.GroupMsgParser
 import com.swago.baseswago.im.IMMessageManager
@@ -42,6 +49,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
     private val officialVm by viewModels<OfficialVm>()
     private val homeVm by viewModels<HomeVm>()
     private val payVm by viewModels<PayVm>()
+    private val userVm by viewModels<UserVm>()
 
     private val listFragment =
         arrayListOf(HomeFragment(), MessageFragment(), MineFragment())
@@ -181,7 +189,30 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
         }
     }
 
-    override fun initLiveData() {}
+    override fun initLiveData() {
+        homeVm.changeNameChangeFun = {
+            userVm.getUserInfo()
+        }
+
+        homeVm.bindAnchorFun = {
+            val currentActivity = ActivityManagerUtil.get().currentActivity()
+            if (currentActivity is FragmentActivity){
+                InviteBindingDialog.newInstance().show(currentActivity.supportFragmentManager,"InviteBindingDialog")
+            }
+        }
+
+        homeVm.closeAccountFun = {
+            val currentActivity = ActivityManagerUtil.get().currentActivity()
+            if (currentActivity is FragmentActivity){
+                CloseAccountDialog.newInstance().show(currentActivity.supportFragmentManager,"CloseAccountDialog")
+            }
+        }
+
+        userVm.userInfoLiveData.observe(this) {
+            UserInfo.setUserInfo(it)
+            SpUtil.putString("user_info", Gson().toJson(it))
+        }
+    }
 
     override fun onResume() {
         super.onResume()

+ 51 - 0
home/src/main/java/com/swago/home/innerhome/HomeVm.kt

@@ -3,10 +3,19 @@ package com.swago.home.innerhome
 import android.app.Application
 import androidx.lifecycle.MutableLiveData
 import com.swago.baseswago.http.SwagoException
+import com.swago.baseswago.im.IMGroupNewMsgListener
+import com.swago.baseswago.im.ImConstant.bind_anchor
+import com.swago.baseswago.im.ImConstant.change_user_name
+import com.swago.baseswago.im.ImConstant.close_account
 import com.swago.baseswago.inter.ApiManager
 import com.swago.baseswago.model.ConfigModel
 import com.swago.baseswago.model.MomentModel
 import com.swago.baseswago.model.home.BannerModel
+import com.swago.baseswago.model.im.BindAnchorData
+import com.swago.baseswago.model.im.ChangeNameData
+import com.swago.baseswago.model.im.CloseAccountData
+import com.swago.baseswago.model.im.CusNewMsgBean
+import com.swago.baseswago.model.live.audio.Jifen
 import com.swago.baseswago.util.BaseViewModel
 import com.swago.baseswago.util.SwagoInfo
 import kotlinx.coroutines.async
@@ -17,6 +26,48 @@ import kotlinx.coroutines.async
  */
 class HomeVm(application: Application) : BaseViewModel(application) {
 
+    var changeNameChangeFun:((data: ChangeNameData) -> Unit)? = null
+    var bindAnchorFun:((data: BindAnchorData) -> Unit)? = null
+    var closeAccountFun:((data: CloseAccountData) -> Unit)? = null
+
+    val imGroupNewMsgListener = IMGroupNewMsgListener()
+
+    init {
+        imGroupNewMsgListener.attach()
+        receiveMsg()
+    }
+
+    private fun receiveMsg() {
+        imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ChangeNameData>>(
+            change_user_name
+        ){
+            it.data?.let {
+                changeNameChangeFun?.invoke(it)
+            }
+        }
+
+        imGroupNewMsgListener.handleMsgType<CusNewMsgBean<BindAnchorData>>(
+            bind_anchor
+        ){
+            it.data?.let {
+                bindAnchorFun?.invoke(it)
+            }
+        }
+
+        imGroupNewMsgListener.handleMsgType<CusNewMsgBean<CloseAccountData>>(
+            close_account
+        ){
+            it.data?.let {
+                closeAccountFun?.invoke(it)
+            }
+        }
+    }
+
+    override fun onCleared() {
+        super.onCleared()
+        imGroupNewMsgListener.detach()
+    }
+
     val homeListLiveData by lazy {
         MutableLiveData<List<MomentModel>?>()
     }