후원랭킹 전체보기 후원랭킹 활성화 스위치 - 클릭 리스너 추가
This commit is contained in:
parent
d35b920470
commit
71cd52d30a
|
@ -192,7 +192,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
|
|||
viewModel { ProfileUpdateViewModel(get()) }
|
||||
viewModel { NicknameUpdateViewModel(get()) }
|
||||
viewModel { MemberTagViewModel(get()) }
|
||||
viewModel { UserProfileDonationAllViewModel(get()) }
|
||||
viewModel { UserProfileDonationAllViewModel(get(), get()) }
|
||||
viewModel { AudioContentCurationViewModel(get()) }
|
||||
viewModel { AudioContentNewAllViewModel(get()) }
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ data class GetDonationAllResponse(
|
|||
val accumulatedCansLastWeek: Int,
|
||||
@SerializedName("accumulatedCansThisMonth")
|
||||
val accumulatedCansThisMonth: Int,
|
||||
@SerializedName("isVisibleDonationRank")
|
||||
val isVisibleDonationRank: Boolean,
|
||||
@SerializedName("totalCount")
|
||||
val totalCount: Int,
|
||||
@SerializedName("userDonationRanking")
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.View
|
|||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.common.Constants
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
|
@ -118,6 +119,9 @@ class UserProfileDonationAllViewActivity : BaseActivity<ActivityUserProfileLiveA
|
|||
if (SharedPreferenceManager.userId == userId) {
|
||||
binding.llTotal.visibility = View.VISIBLE
|
||||
binding.llVisibleDonationRanking.visibility = View.VISIBLE
|
||||
binding.ivVisibleDonationRank.setOnClickListener {
|
||||
viewModel.onClickToggleVisibleDonationRank()
|
||||
}
|
||||
} else {
|
||||
binding.llTotal.visibility = View.GONE
|
||||
binding.llVisibleDonationRanking.visibility = View.GONE
|
||||
|
@ -147,5 +151,15 @@ class UserProfileDonationAllViewActivity : BaseActivity<ActivityUserProfileLiveA
|
|||
adapter.items.addAll(it.userDonationRanking)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
viewModel.isVisibleDonationRank.observe(this) {
|
||||
binding.ivVisibleDonationRank.setImageResource(
|
||||
if (it) {
|
||||
R.drawable.btn_toggle_on_big
|
||||
} else {
|
||||
R.drawable.btn_toggle_off_big
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,12 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
|||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.explorer.ExplorerRepository
|
||||
import kr.co.vividnext.sodalive.mypage.profile.ProfileUpdateRequest
|
||||
import kr.co.vividnext.sodalive.user.UserRepository
|
||||
|
||||
class UserProfileDonationAllViewModel(
|
||||
private val repository: ExplorerRepository
|
||||
private val repository: ExplorerRepository,
|
||||
private val memberRepository: UserRepository
|
||||
) : BaseViewModel() {
|
||||
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
|
@ -25,6 +28,10 @@ class UserProfileDonationAllViewModel(
|
|||
val donationLiveData: LiveData<GetDonationAllResponse>
|
||||
get() = _donationLiveData
|
||||
|
||||
private var _isVisibleDonationRank = MutableLiveData<Boolean>()
|
||||
val isVisibleDonationRank: LiveData<Boolean>
|
||||
get() = _isVisibleDonationRank
|
||||
|
||||
private var isLast = false
|
||||
private var page = 1
|
||||
private val size = 10
|
||||
|
@ -51,6 +58,7 @@ class UserProfileDonationAllViewModel(
|
|||
} else {
|
||||
isLast = true
|
||||
}
|
||||
_isVisibleDonationRank.postValue(it.data.isVisibleDonationRank)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
|
@ -78,4 +86,43 @@ class UserProfileDonationAllViewModel(
|
|||
isLast = false
|
||||
getCreatorProfileDonationRanking(userId)
|
||||
}
|
||||
|
||||
fun onClickToggleVisibleDonationRank() {
|
||||
val nowStateVisibleDonationRank = _isVisibleDonationRank.value!!
|
||||
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
memberRepository.updateProfile(
|
||||
request = ProfileUpdateRequest(
|
||||
email = SharedPreferenceManager.email,
|
||||
isVisibleDonationRank = !nowStateVisibleDonationRank
|
||||
),
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (it.success) {
|
||||
_isVisibleDonationRank.postValue(!nowStateVisibleDonationRank)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
_isLoading.value = false
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/btn_toggle_on_big" />
|
||||
tools:src="@drawable/btn_toggle_on_big" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in New Issue