DoggyZhang 3 месяцев назад
Родитель
Сommit
cf6c2a1b99
18 измененных файлов с 86 добавлено и 35 удалено
  1. 2 1
      app/src/main/java/com/adealink/weparty/module/order/viewmodel/IOrderViewModel.kt
  2. 2 2
      app/src/main/java/com/adealink/weparty/module/profile/viewmodel/IFollowViewModel.kt
  3. BIN
      app/src/main/res/drawable-xhdpi/common_clear_input_ic.png
  4. 13 0
      module/order/src/main/java/com/adealink/weparty/order/CreateOrderActivity.kt
  5. 2 1
      module/order/src/main/java/com/adealink/weparty/order/viewmodel/OrderViewModel.kt
  6. 2 1
      module/profile/src/main/java/com/adealink/weparty/profile/comp/ProfilePlaymateComp.kt
  7. 6 0
      module/profile/src/main/java/com/adealink/weparty/profile/dialog/CharmStarDialog.kt
  8. 2 0
      module/profile/src/main/java/com/adealink/weparty/profile/relation/FansFragment.kt
  9. 2 0
      module/profile/src/main/java/com/adealink/weparty/profile/relation/FollowFragment.kt
  10. 8 7
      module/profile/src/main/java/com/adealink/weparty/profile/relation/RelationShipActivity.kt
  11. 8 8
      module/profile/src/main/java/com/adealink/weparty/profile/relation/data/RelationShipData.kt
  12. 13 11
      module/profile/src/main/java/com/adealink/weparty/profile/relation/viewmodel/FollowViewModel.kt
  13. 1 1
      module/profile/src/main/java/com/adealink/weparty/profile/relation/viewmodel/RelationShipTab.kt
  14. 9 0
      module/profile/src/main/java/com/adealink/weparty/profile/search/SearchActivity.kt
  15. 13 2
      module/profile/src/main/res/layout/activity_user_search.xml
  16. 1 0
      module/profile/src/main/res/layout/item_relationship_fans.xml
  17. 1 0
      module/profile/src/main/res/layout/item_relationship_follow.xml
  18. 1 1
      module/profile/src/main/res/values-in/strings.xml

+ 2 - 1
app/src/main/java/com/adealink/weparty/module/order/viewmodel/IOrderViewModel.kt

@@ -2,6 +2,7 @@ package com.adealink.weparty.module.order.viewmodel
 
 import androidx.lifecycle.LiveData
 import com.adealink.frame.base.Rlt
+import com.adealink.frame.mvvm.livedata.ExtLiveData
 import com.adealink.weparty.module.order.data.CreateOrderRes
 import com.adealink.weparty.module.order.data.OrderDetailData
 
@@ -10,7 +11,7 @@ interface IOrderViewModel {
     suspend fun queryUnCompleteOrder(uid: String): List<OrderDetailData>
 
 
-    val onOrderCreatedLD: LiveData<CreateOrderRes>
+    val onOrderCreatedLD: ExtLiveData<CreateOrderRes>
 
     fun createOrder(
         playmateId: String,

+ 2 - 2
app/src/main/java/com/adealink/weparty/module/profile/viewmodel/IFollowViewModel.kt

@@ -17,9 +17,9 @@ interface IFollowViewModel {
 
     fun isFollow(uids: List<String>): LiveData<Rlt<Map<String, FollowStatus>>>
 
-    fun follow(uid: String): LiveData<Rlt<Any>>
+    fun follow(uid: String): LiveData<Rlt<FollowStatus>>
 
-    fun unFollow(uid: String): LiveData<Rlt<Any>>
+    fun unFollow(uid: String): LiveData<Rlt<FollowStatus>>
 
     fun getFollowCount()
 

BIN
app/src/main/res/drawable-xhdpi/common_clear_input_ic.png


+ 13 - 0
module/order/src/main/java/com/adealink/weparty/order/CreateOrderActivity.kt

@@ -1,8 +1,10 @@
 package com.adealink.weparty.order
 
 import android.os.Bundle
+import androidx.activity.viewModels
 import androidx.constraintlayout.widget.ConstraintLayout
 import androidx.core.view.updateLayoutParams
+import androidx.fragment.app.activityViewModels
 import com.adealink.frame.base.Rlt
 import com.adealink.frame.base.fastLazy
 import com.adealink.frame.mvvm.view.viewBinding
@@ -19,8 +21,11 @@ import com.adealink.weparty.module.order.Order
 import com.adealink.weparty.module.playmate.PlaymateModule
 import com.adealink.weparty.module.playmate.data.PlaymateDetailData
 import com.adealink.weparty.order.databinding.ActivityCreateOrderBinding
+import com.adealink.weparty.order.viewmodel.OrderViewModel
+import com.adealink.weparty.order.viewmodel.OrderViewModelFactory
 import com.adealink.weparty.util.formatNumberStr
 import com.adealink.weparty.util.formatStar
+import kotlin.getValue
 
 @RouterUri(path = [Order.Create.PATH], desc = "创建订单")
 class CreateOrderActivity : BaseActivity() {
@@ -28,6 +33,7 @@ class CreateOrderActivity : BaseActivity() {
     private val binding by viewBinding(ActivityCreateOrderBinding::inflate)
 
     private val playmateViewModel by fastLazy { PlaymateModule.getPlaymateViewModel(this) }
+    private val viewModel by viewModels<OrderViewModel> { OrderViewModelFactory() }
 
     @BindExtra(Order.Create.EXTRA_PLAYMATE)
     var playmateData: PlaymateDetailData? = null
@@ -60,6 +66,13 @@ class CreateOrderActivity : BaseActivity() {
         }
     }
 
+    override fun observeViewModel() {
+        super.observeViewModel()
+        viewModel.onOrderCreatedLD.observeWithoutCache(this) {
+            finish()
+        }
+    }
+
     override fun loadData() {
         super.loadData()
         val playmateData = playmateData

+ 2 - 1
module/order/src/main/java/com/adealink/weparty/order/viewmodel/OrderViewModel.kt

@@ -3,6 +3,7 @@ package com.adealink.weparty.order.viewmodel
 import androidx.lifecycle.LiveData
 import com.adealink.frame.base.CommonDataNullError
 import com.adealink.frame.base.Rlt
+import com.adealink.frame.mvvm.livedata.ExtLiveData
 import com.adealink.frame.mvvm.livedata.ExtMutableLiveData
 import com.adealink.frame.mvvm.livedata.OnceMutableLiveData
 import com.adealink.frame.mvvm.viewmodel.BaseViewModel
@@ -42,7 +43,7 @@ class OrderViewModel : BaseViewModel(), IOrderViewModel {
         }
     }
 
-    override val onOrderCreatedLD: LiveData<CreateOrderRes> = ExtMutableLiveData()
+    override val onOrderCreatedLD: ExtLiveData<CreateOrderRes> = ExtMutableLiveData()
 
     override fun createOrder(
         playmateId: String,

+ 2 - 1
module/profile/src/main/java/com/adealink/weparty/profile/comp/ProfilePlaymateComp.kt

@@ -5,6 +5,7 @@ import com.adealink.frame.util.onClick
 import com.adealink.weparty.commonui.ext.gone
 import com.adealink.weparty.commonui.ext.show
 import com.adealink.weparty.commonui.util.DragViewUtil
+import com.adealink.weparty.module.profile.ProfileModule
 import com.adealink.weparty.module.profile.data.UserInfo
 import com.adealink.weparty.profile.databinding.ActivityUserProfileBinding
 import com.adealink.weparty.profile.dialog.CharmStarDialog
@@ -29,7 +30,7 @@ class ProfilePlaymateComp(
     }
 
     override fun updateUI(userInfo: UserInfo?) {
-        if (userInfo == null) {
+        if (userInfo == null || userUid == ProfileModule.getMyUid()) {
             binding.vPlaymateCharm.root.gone()
             return
         }

+ 6 - 0
module/profile/src/main/java/com/adealink/weparty/profile/dialog/CharmStarDialog.kt

@@ -7,6 +7,7 @@ import com.adealink.frame.mvvm.view.viewBinding
 import com.adealink.frame.util.onClick
 import com.adealink.weparty.commonui.toast.util.showFailedToast
 import com.adealink.weparty.commonui.widget.BottomDialogFragment
+import com.adealink.weparty.commonui.widget.EvaluateView
 import com.adealink.weparty.module.profile.data.UserInfo
 import com.adealink.weparty.profile.R
 import com.adealink.weparty.profile.databinding.DialogPlaymateCharmStarBinding
@@ -23,6 +24,11 @@ class CharmStarDialog : BottomDialogFragment(R.layout.dialog_playmate_charm_star
     private val viewModel by viewModels<PlaymateCharmStarViewModel>()
     override fun initViews() {
         super.initViews()
+        binding.vEvaluate.setListener(object : EvaluateView.OnEvaluateListener {
+            override fun onEvaluate(score: Float) {
+                binding.btnSubmit.isEnabled = score > 0
+            }
+        })
         binding.btnSubmit.onClick {
             submit()
         }

+ 2 - 0
module/profile/src/main/java/com/adealink/weparty/profile/relation/FansFragment.kt

@@ -90,6 +90,7 @@ class FansFragment : BaseFragment(R.layout.fragment_fans), FansItemViewBinder.On
         viewModel.follow(item.data.uid).observe(viewLifecycleOwner) { rlt ->
             when (rlt) {
                 is Rlt.Success -> {
+                    item.data.followStatus = rlt.data.status
                     listAdapter.notifyItemChanged(position)
                 }
 
@@ -107,6 +108,7 @@ class FansFragment : BaseFragment(R.layout.fragment_fans), FansItemViewBinder.On
         viewModel.unFollow(item.data.uid).observe(viewLifecycleOwner) { rlt ->
             when (rlt) {
                 is Rlt.Success -> {
+                    item.data.followStatus = rlt.data.status
                     listAdapter.notifyItemChanged(position)
                 }
 

+ 2 - 0
module/profile/src/main/java/com/adealink/weparty/profile/relation/FollowFragment.kt

@@ -93,6 +93,7 @@ class FollowFragment : BaseFragment(R.layout.fragment_follow),
         viewModel.follow(item.data.uid).observe(viewLifecycleOwner) { rlt ->
             when (rlt) {
                 is Rlt.Success -> {
+                    item.data.followStatus = rlt.data.status
                     listAdapter.notifyItemChanged(position)
                 }
 
@@ -110,6 +111,7 @@ class FollowFragment : BaseFragment(R.layout.fragment_follow),
         viewModel.unFollow(item.data.uid).observe(viewLifecycleOwner) { rlt ->
             when (rlt) {
                 is Rlt.Success -> {
+                    item.data.followStatus = rlt.data.status
                     listAdapter.notifyItemChanged(position)
                 }
 

+ 8 - 7
module/profile/src/main/java/com/adealink/weparty/profile/relation/RelationShipActivity.kt

@@ -22,6 +22,7 @@ import com.adealink.weparty.module.profile.Profile
 import com.adealink.weparty.profile.R
 import com.adealink.weparty.profile.databinding.ActivityProfileRelationshipBinding
 import com.adealink.weparty.profile.databinding.LayoutRelationshipTabBinding
+import com.adealink.weparty.profile.relation.viewmodel.FANS_TAB
 import com.adealink.weparty.profile.relation.viewmodel.FollowViewModel
 import com.adealink.weparty.profile.relation.viewmodel.RELATIONSHIP_TABS
 import com.adealink.weparty.profile.relation.viewmodel.RelationShipTab
@@ -118,13 +119,13 @@ class RelationShipActivity : BaseActivity() {
 
     override fun observeViewModel() {
         super.observeViewModel()
-        viewModel.followCountLD.observe(this) {
-            binding.tlTab.getTabAt(0)?.let { tab ->
+        viewModel.fansCountLD.observe(this) {
+            binding.tlTab.getTabAt(RelationShipTab.FANS.index)?.let { tab ->
                 updateCount(tab, it)
             }
         }
-        viewModel.fansCountLD.observe(this) {
-            binding.tlTab.getTabAt(1)?.let { tab ->
+        viewModel.followCountLD.observe(this) {
+            binding.tlTab.getTabAt(RelationShipTab.FOLLOW.index)?.let { tab ->
                 updateCount(tab, it)
             }
         }
@@ -147,13 +148,13 @@ class RelationShipActivity : BaseActivity() {
             return when (tab.type) {
                 RelationShipTab.FANS -> {
                     getCompatString(
-                        R.string.profile_follow_list_title,
-                        followCount?.toString() ?: ""
+                        R.string.profile_fans_list_title,
+                        fansCount?.toString() ?: ""
                     )
                 }
 
                 RelationShipTab.FOLLOW -> {
-                    getCompatString(R.string.profile_fans_list_title, fansCount?.toString() ?: "")
+                    getCompatString(R.string.profile_follow_list_title, followCount?.toString() ?: "")
                 }
             }
         }

+ 8 - 8
module/profile/src/main/java/com/adealink/weparty/profile/relation/data/RelationShipData.kt

@@ -40,13 +40,13 @@ data class FollowListRes(
 data class FollowData(
     @SerializedName("userNo") val uid: String,
     @GsonNullable
-    @SerializedName("nickname") var nickName: String? = null,
+    @SerializedName("nickname") val nickName: String? = null,
     @GsonNullable
-    @SerializedName("avatar") var avatar: String? = null,
+    @SerializedName("avatar") val avatar: String? = null,
     @GsonNullable
-    @SerializedName("gender") var gender: Int? = null,
+    @SerializedName("gender") val gender: Int? = null,
     @GsonNullable
-    @SerializedName("age") var age: Int? = null,
+    @SerializedName("age") val age: Int? = null,
     @GsonNullable
     @SerializedName("relateion") var followStatus: Int? = null
 )
@@ -67,13 +67,13 @@ data class FansListRes(
 data class FansData(
     @SerializedName("userNo") val uid: String,
     @GsonNullable
-    @SerializedName("nickname") var nickName: String? = null,
+    @SerializedName("nickname") val nickName: String? = null,
     @GsonNullable
-    @SerializedName("avatar") var avatar: String? = null,
+    @SerializedName("avatar") val avatar: String? = null,
     @GsonNullable
-    @SerializedName("gender") var gender: Int? = null,
+    @SerializedName("gender") val gender: Int? = null,
     @GsonNullable
-    @SerializedName("age") var age: Int? = null,
+    @SerializedName("age") val age: Int? = null,
     @GsonNullable
     @SerializedName("relateion") var followStatus: Int? = null
 )

+ 13 - 11
module/profile/src/main/java/com/adealink/weparty/profile/relation/viewmodel/FollowViewModel.kt

@@ -73,38 +73,39 @@ class FollowViewModel : BaseViewModel(), IFollowViewModel {
         return liveData
     }
 
-    override fun follow(uid: String): LiveData<Rlt<Any>> {
-        val liveData = OnceMutableLiveData<Rlt<Any>>()
+    override fun follow(uid: String): LiveData<Rlt<FollowStatus>> {
+        val liveData = OnceMutableLiveData<Rlt<FollowStatus>>()
         viewModelScope.launch {
             val rlt = followHttpService.follow(FollowReq(uid, true))
             when (rlt) {
                 is Rlt.Failed -> {
-                    //ntd.
+                    liveData.send(rlt)
                 }
 
                 is Rlt.Success -> {
-                    onFollowStatusChanged(uid, true)
+                    val nextStatus = onFollowStatusChanged(uid, true)
+                    liveData.send(Rlt.Success(nextStatus))
                 }
             }
-            liveData.send(rlt)
         }
         return liveData
     }
 
-    override fun unFollow(uid: String): LiveData<Rlt<Any>> {
-        val liveData = OnceMutableLiveData<Rlt<Any>>()
+    override fun unFollow(uid: String): LiveData<Rlt<FollowStatus>> {
+        val liveData = OnceMutableLiveData<Rlt<FollowStatus>>()
         viewModelScope.launch {
             val rlt = followHttpService.follow(FollowReq(uid, false))
             when (rlt) {
                 is Rlt.Failed -> {
-                    //ntd.
+                    liveData.send(rlt)
                 }
 
                 is Rlt.Success -> {
-                    onFollowStatusChanged(uid, false)
+                    val nextStatus = onFollowStatusChanged(uid, false)
+                    liveData.send(Rlt.Success(nextStatus))
                 }
             }
-            liveData.send(rlt)
+
         }
         return liveData
     }
@@ -139,7 +140,7 @@ class FollowViewModel : BaseViewModel(), IFollowViewModel {
         }
     }
 
-    private fun onFollowStatusChanged(uid: String, follow: Boolean) {
+    private fun onFollowStatusChanged(uid: String, follow: Boolean): FollowStatus {
         val currentStatus = followStatusMap[uid]
         val nextStatus = when (currentStatus) {
             FollowStatus.NONE, null -> {
@@ -176,6 +177,7 @@ class FollowViewModel : BaseViewModel(), IFollowViewModel {
         }
         followStatusMap[uid] = nextStatus
         isFollowLD.send(followStatusMap)
+        return nextStatus
     }
 
 

+ 1 - 1
module/profile/src/main/java/com/adealink/weparty/profile/relation/viewmodel/RelationShipTab.kt

@@ -37,5 +37,5 @@ val FANS_TAB = Tab(
 
 
 val RELATIONSHIP_TABS = listOf(
-    FOLLOW_TAB, FANS_TAB
+    FANS_TAB, FOLLOW_TAB
 )

+ 9 - 0
module/profile/src/main/java/com/adealink/weparty/profile/search/SearchActivity.kt

@@ -82,6 +82,13 @@ class SearchActivity : BaseActivity(),
             topMargin = this@SearchActivity.statusBarHeight()
         }
 
+        binding.ivBack.onClick {
+            finish()
+        }
+        binding.ivClearInput.onClick {
+            binding.etSearchInput.setText(null)
+        }
+
         historyAdapter.register(SearchHistoryViewBinder(this))
         binding.rvHistory.layoutManager =
             FlexboxLayoutManager(binding.rvHistory.context, FlexDirection.ROW, FlexWrap.WRAP)
@@ -195,6 +202,7 @@ class SearchActivity : BaseActivity(),
         if (keyword.isNullOrEmpty()) {
             return
         }
+        historyList.remove(keyword)
         historyList.add(0, keyword)
         updateHistoryList(historyList, commit)
     }
@@ -216,6 +224,7 @@ class SearchActivity : BaseActivity(),
             }
         }
         isInputEmpty.observe(this) {
+            binding.ivClearInput.show(!it)
             binding.tvSearch.isEnabled = !it
             if (it) {
                 binding.clSearchResult.gone()

+ 13 - 2
module/profile/src/main/res/layout/activity_user_search.xml

@@ -48,7 +48,7 @@
                 android:id="@+id/et_search_input"
                 android:layout_width="0dp"
                 android:layout_height="0dp"
-                android:layout_marginStart="8dp"
+                android:layout_marginHorizontal="8dp"
                 android:background="@null"
                 android:gravity="start|center_vertical"
                 android:hint="@string/profile_search_hint"
@@ -60,10 +60,21 @@
                 android:textColorHint="@color/color_FF86909C"
                 android:textSize="12sp"
                 app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintEnd_toStartOf="@id/iv_clear_input"
                 app:layout_constraintStart_toEndOf="@id/iv_search_input"
                 app:layout_constraintTop_toTopOf="parent" />
 
+            <androidx.appcompat.widget.AppCompatImageView
+                android:id="@+id/iv_clear_input"
+                android:layout_width="16dp"
+                android:layout_height="16dp"
+                android:visibility="gone"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toTopOf="parent"
+                app:srcCompat="@drawable/common_clear_input_ic"
+                tools:visibility="gone" />
+
         </androidx.constraintlayout.widget.ConstraintLayout>
 
         <androidx.appcompat.widget.AppCompatTextView

+ 1 - 0
module/profile/src/main/res/layout/item_relationship_fans.xml

@@ -37,6 +37,7 @@
         android:id="@+id/v_gender"
         style="@style/CommonGenderView"
         android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp"
         app:layout_constraintBottom_toBottomOf="@id/tv_user_name"
         app:layout_constraintEnd_toStartOf="@id/right_barrier"
         app:layout_constraintStart_toEndOf="@id/tv_user_name"

+ 1 - 0
module/profile/src/main/res/layout/item_relationship_follow.xml

@@ -37,6 +37,7 @@
         android:id="@+id/v_gender"
         style="@style/CommonGenderView"
         android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp"
         app:layout_constraintBottom_toBottomOf="@id/tv_user_name"
         app:layout_constraintEnd_toStartOf="@id/right_barrier"
         app:layout_constraintStart_toEndOf="@id/tv_user_name"

+ 1 - 1
module/profile/src/main/res/values-in/strings.xml

@@ -66,7 +66,7 @@
     <string name="profile_edit_talent_voice_delete_record">Hapus dan rekam ulang</string>
     <string name="profile_follow_list_title">%s Diikuti</string>
     <string name="profile_fans_list_title">%s Penggemar</string>
-    <string name="profile_playmate_charm_star">Kesan yang baik</string>
+    <string name="profile_playmate_charm_star">Kesan Baik</string>
     <string name="profile_edit_interest">Learn more about you</string>
     <string name="profile_edit_interest_tips">Select to find more compatible friends</string>
     <string name="profile_edit_not_save_tips">Perubahan tidak tersimpan, konfirmasi keluar?</string>