diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerApi.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerApi.kt index 52550e8c..7d303e3b 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerApi.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerApi.kt @@ -48,6 +48,7 @@ interface ExplorerApi { @Path("id") id: Long, @Query("page") page: Int, @Query("size") size: Int, + @Query("period") period: String?, @Header("Authorization") authHeader: String ): Single> diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerRepository.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerRepository.kt index 82e57ec5..754f3581 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerRepository.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerRepository.kt @@ -80,12 +80,14 @@ class ExplorerRepository( id: Long, page: Int, size: Int, + donationRankingPeriod: String?, token: String ): Single> { return api.getCreatorProfileDonationRanking( id = id, page = page - 1, size = size, + period = donationRankingPeriod, authHeader = token ) } diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/DonationRankingPeriod.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/DonationRankingPeriod.kt new file mode 100644 index 00000000..5b6cc353 --- /dev/null +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/DonationRankingPeriod.kt @@ -0,0 +1,12 @@ +package kr.co.vividnext.sodalive.explorer.profile.donation + +import androidx.annotation.Keep +import com.google.gson.annotations.SerializedName + +@Keep +enum class DonationRankingPeriod { + @SerializedName("WEEKLY") + WEEKLY, + @SerializedName("CUMULATIVE") + CUMULATIVE +} diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/GetDonationAllResponse.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/GetDonationAllResponse.kt index 54ceabe6..8b80bf0c 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/GetDonationAllResponse.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/GetDonationAllResponse.kt @@ -16,6 +16,8 @@ data class GetDonationAllResponse( val isVisibleDonationRank: Boolean, @SerializedName("totalCount") val totalCount: Int, + @SerializedName("donationRankingPeriod") + val donationRankingPeriod: DonationRankingPeriod? = null, @SerializedName("userDonationRanking") val userDonationRanking: List, ) diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/UserProfileDonationAllViewActivity.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/UserProfileDonationAllViewActivity.kt index 15adb328..abcb4bb8 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/UserProfileDonationAllViewActivity.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/donation/UserProfileDonationAllViewActivity.kt @@ -7,6 +7,7 @@ import android.view.View import android.widget.Toast import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.google.android.material.tabs.TabLayout import kr.co.vividnext.sodalive.R import kr.co.vividnext.sodalive.base.BaseActivity import kr.co.vividnext.sodalive.common.Constants @@ -27,15 +28,19 @@ class UserProfileDonationAllViewActivity : BaseActivity 0) { bindData() - viewModel.getCreatorProfileDonationRanking(userId) + if (!isCreator) { + viewModel.getCreatorProfileDonationRanking(userId) + } } else { Toast.makeText( applicationContext, @@ -120,15 +125,26 @@ class UserProfileDonationAllViewActivity : BaseActivity get() = _isVisibleDonationRank + private val _selectedDonationRankingPeriod = MutableLiveData() + val selectedDonationRankingPeriod: LiveData + get() = _selectedDonationRankingPeriod + private var isLast = false private var page = 1 private val size = 10 + private var currentRankingPeriod: DonationRankingPeriod? = null - fun getCreatorProfileDonationRanking(userId: Long) { + fun getCreatorProfileDonationRanking(userId: Long, period: DonationRankingPeriod? = null) { if (!_isLoading.value!! && !isLast) { + if (period != null) { + currentRankingPeriod = period + } _isLoading.value = true + val requestPeriod = period ?: currentRankingPeriod compositeDisposable.add( repository.getCreatorProfileDonationRanking( id = userId, page = page, size = size, + donationRankingPeriod = requestPeriod?.name, token = "Bearer ${SharedPreferenceManager.token}" ) .subscribeOn(Schedulers.io()) @@ -54,6 +64,12 @@ class UserProfileDonationAllViewModel( .subscribe( { if (it.success && it.data != null) { + it.data.donationRankingPeriod?.let { donationRankingPeriod -> + _selectedDonationRankingPeriod.postValue(donationRankingPeriod) + if (currentRankingPeriod == null) { + currentRankingPeriod = donationRankingPeriod + } + } if (it.data.userDonationRanking.isNotEmpty()) { page += 1 _donationLiveData.postValue(it.data!!) @@ -87,10 +103,10 @@ class UserProfileDonationAllViewModel( } } - fun refresh(userId: Long) { + fun refresh(userId: Long, period: DonationRankingPeriod? = null) { page = 1 isLast = false - getCreatorProfileDonationRanking(userId) + getCreatorProfileDonationRanking(userId, period) } fun onClickToggleVisibleDonationRank() { @@ -135,4 +151,45 @@ class UserProfileDonationAllViewModel( ) ) } + + fun updateDonationRankingPeriod(period: DonationRankingPeriod) { + _isLoading.value = true + compositeDisposable.add( + memberRepository.updateProfile( + request = ProfileUpdateRequest( + email = SharedPreferenceManager.email, + donationRankingPeriod = period + ), + token = "Bearer ${SharedPreferenceManager.token}" + ) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe( + { + if (it.success) { + _selectedDonationRankingPeriod.postValue(period) + } else { + if (it.message != null) { + _toastLiveData.postValue(it.message) + } else { + _toastLiveData.postValue( + SodaLiveApplicationHolder.get() + .getString(R.string.common_error_unknown) + ) + } + } + + _isLoading.value = false + }, + { + _isLoading.value = false + it.message?.let { message -> Logger.e(message) } + _toastLiveData.postValue( + SodaLiveApplicationHolder.get() + .getString(R.string.common_error_unknown) + ) + } + ) + ) + } } diff --git a/app/src/main/java/kr/co/vividnext/sodalive/mypage/profile/ProfileUpdateRequest.kt b/app/src/main/java/kr/co/vividnext/sodalive/mypage/profile/ProfileUpdateRequest.kt index 1fe658a0..19247e7a 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/mypage/profile/ProfileUpdateRequest.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/mypage/profile/ProfileUpdateRequest.kt @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.mypage.profile import androidx.annotation.Keep import com.google.gson.annotations.SerializedName +import kr.co.vividnext.sodalive.explorer.profile.donation.DonationRankingPeriod import kr.co.vividnext.sodalive.user.Gender @Keep @@ -19,5 +20,6 @@ data class ProfileUpdateRequest( @SerializedName("websiteUrl") val websiteUrl: String? = null, @SerializedName("blogUrl") val blogUrl: String? = null, @SerializedName("isVisibleDonationRank") val isVisibleDonationRank: Boolean? = null, + @SerializedName("donationRankingPeriod") val donationRankingPeriod: DonationRankingPeriod? = null, @SerializedName("container") val container: String = "aos" ) diff --git a/app/src/main/res/layout/activity_user_profile_live_all.xml b/app/src/main/res/layout/activity_user_profile_live_all.xml index b6062400..86cab9d2 100644 --- a/app/src/main/res/layout/activity_user_profile_live_all.xml +++ b/app/src/main/res/layout/activity_user_profile_live_all.xml @@ -1,6 +1,7 @@ + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index e720b21c..4fbbcfc3 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -810,6 +810,8 @@ All items %1$s %2$s + Weekly + Cumulative Community Create post After posting, your post will appear here\nand be visible in the community. diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index d937e1c3..155009ce 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -810,6 +810,8 @@ %1$s %2$s + 週間 + 累計 コミュニティ 投稿作成 投稿するとここに表示され、\nコミュニティに公開されます。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b789f29e..07a8b4e4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -809,6 +809,8 @@ 전체 %1$s %2$s + 주간 + 누적 커뮤니티 게시물 등록 게시 후에 게시물이 여기에 표시되고\n커뮤니티에 공개됩니다.