캔 충전/사용 내역 UI/API 추가
This commit is contained in:
parent
03de8eba86
commit
3b235a8495
|
@ -33,6 +33,7 @@
|
|||
<activity android:name=".user.signup.SignUpActivity" />
|
||||
<activity android:name=".settings.terms.TermsActivity" />
|
||||
<activity android:name=".user.find_password.FindPasswordActivity" />
|
||||
<activity android:name=".mypage.can.status.CanStatusActivity" />
|
||||
|
||||
<activity
|
||||
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
|
||||
|
|
|
@ -13,6 +13,9 @@ import kr.co.vividnext.sodalive.main.MainViewModel
|
|||
import kr.co.vividnext.sodalive.mypage.MyPageViewModel
|
||||
import kr.co.vividnext.sodalive.mypage.auth.AuthApi
|
||||
import kr.co.vividnext.sodalive.mypage.auth.AuthRepository
|
||||
import kr.co.vividnext.sodalive.mypage.can.CanApi
|
||||
import kr.co.vividnext.sodalive.mypage.can.CanRepository
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.CanStatusViewModel
|
||||
import kr.co.vividnext.sodalive.network.TokenAuthenticator
|
||||
import kr.co.vividnext.sodalive.settings.event.EventApi
|
||||
import kr.co.vividnext.sodalive.settings.event.EventRepository
|
||||
|
@ -72,6 +75,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
|
|||
single { ApiBuilder().build(get(), EventApi::class.java) }
|
||||
single { ApiBuilder().build(get(), LiveRecommendApi::class.java) }
|
||||
single { ApiBuilder().build(get(), AuthApi::class.java) }
|
||||
single { ApiBuilder().build(get(), CanApi::class.java) }
|
||||
}
|
||||
|
||||
private val viewModelModule = module {
|
||||
|
@ -82,6 +86,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
|
|||
viewModel { MainViewModel(get()) }
|
||||
viewModel { LiveViewModel(get(), get(), get()) }
|
||||
viewModel { MyPageViewModel(get(), get()) }
|
||||
viewModel { CanStatusViewModel(get()) }
|
||||
}
|
||||
|
||||
private val repositoryModule = module {
|
||||
|
@ -91,6 +96,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
|
|||
factory { EventRepository(get()) }
|
||||
factory { LiveRecommendRepository(get()) }
|
||||
factory { AuthRepository(get()) }
|
||||
factory { CanRepository(get()) }
|
||||
}
|
||||
|
||||
private val moduleList = listOf(
|
||||
|
|
|
@ -19,6 +19,7 @@ import kr.co.vividnext.sodalive.extensions.moneyFormat
|
|||
import kr.co.vividnext.sodalive.mypage.auth.Auth
|
||||
import kr.co.vividnext.sodalive.mypage.auth.AuthVerifyRequest
|
||||
import kr.co.vividnext.sodalive.mypage.auth.BootpayResponse
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.CanStatusActivity
|
||||
import kr.co.vividnext.sodalive.settings.notification.MemberRole
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
|
@ -46,7 +47,14 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
|||
|
||||
binding.ivEdit.setOnClickListener {}
|
||||
|
||||
binding.tvTotalCoin.setOnClickListener {}
|
||||
binding.llTotalCoin.setOnClickListener {
|
||||
startActivity(
|
||||
Intent(
|
||||
requireActivity(),
|
||||
CanStatusActivity::class.java
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
binding.tvChargeCoin.setOnClickListener {}
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can
|
||||
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.GetCanStatusResponse
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.charge.GetCanChargeStatusResponseItem
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.use.GetCanUseStatusResponseItem
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.Query
|
||||
|
||||
interface CanApi {
|
||||
@GET("/can/status")
|
||||
fun getCanStatus(
|
||||
@Query("container") container: String = "aos",
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<GetCanStatusResponse>>
|
||||
|
||||
@GET("/can/status/use")
|
||||
fun getCanUseStatus(
|
||||
@Query("timezone") timezone: String,
|
||||
@Query("page") page: Int,
|
||||
@Query("size") size: Int,
|
||||
@Query("container") container: String = "aos",
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<List<GetCanUseStatusResponseItem>>>
|
||||
|
||||
@GET("/can/status/charge")
|
||||
fun getCanChargeStatus(
|
||||
@Query("timezone") timezone: String,
|
||||
@Query("page") page: Int,
|
||||
@Query("size") size: Int,
|
||||
@Query("container") container: String = "aos",
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<List<GetCanChargeStatusResponseItem>>>
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can
|
||||
|
||||
import java.util.TimeZone
|
||||
|
||||
class CanRepository(private val api: CanApi) {
|
||||
fun getCanStatus(token: String) = api.getCanStatus(authHeader = token)
|
||||
|
||||
fun getCanUseStatus(
|
||||
page: Int,
|
||||
pageSize: Int,
|
||||
token: String
|
||||
) = api.getCanUseStatus(
|
||||
timezone = TimeZone.getDefault().id,
|
||||
page = page - 1,
|
||||
size = pageSize,
|
||||
authHeader = token
|
||||
)
|
||||
|
||||
fun getCanChargeStatus(
|
||||
page: Int,
|
||||
pageSize: Int,
|
||||
token: String
|
||||
) = api.getCanChargeStatus(
|
||||
timezone = TimeZone.getDefault().id,
|
||||
page = page - 1,
|
||||
size = pageSize,
|
||||
authHeader = token
|
||||
)
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
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.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityCanStatusBinding
|
||||
import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
import kr.co.vividnext.sodalive.main.MainActivity
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.charge.CanChargeStatusFragment
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.use.CanUseStatusFragment
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class CanStatusActivity : BaseActivity<ActivityCanStatusBinding>(
|
||||
ActivityCanStatusBinding::inflate
|
||||
) {
|
||||
|
||||
private val viewModel: CanStatusViewModel by inject()
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
onClickBackButton()
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var loadingDialog: LoadingDialog
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
bindData()
|
||||
viewModel.getCanStatus()
|
||||
}
|
||||
|
||||
override fun setupView() {
|
||||
binding.toolbar.tvBack.text = "코인내역"
|
||||
binding.toolbar.tvBack.setOnClickListener { onClickBackButton() }
|
||||
binding.llChargeCoin.setOnClickListener {}
|
||||
|
||||
loadingDialog = LoadingDialog(this, layoutInflater)
|
||||
|
||||
val tabs = binding.tabs
|
||||
tabs.addTab(tabs.newTab().setText("충전내역").setTag("charge_status"))
|
||||
tabs.addTab(tabs.newTab().setText("사용내역").setTag("use_status"))
|
||||
|
||||
changeFragment("charge_status")
|
||||
|
||||
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||
val tag = tab.tag as String
|
||||
changeFragment(tag)
|
||||
}
|
||||
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) {
|
||||
}
|
||||
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun changeFragment(tag: String) {
|
||||
val fragmentManager = supportFragmentManager
|
||||
val fragmentTransaction = fragmentManager.beginTransaction()
|
||||
|
||||
val currentFragment = fragmentManager.primaryNavigationFragment
|
||||
if (currentFragment != null) {
|
||||
fragmentTransaction.hide(currentFragment)
|
||||
}
|
||||
|
||||
var fragment = fragmentManager.findFragmentByTag(tag)
|
||||
if (fragment == null) {
|
||||
fragment = if (tag == "charge_status") {
|
||||
CanChargeStatusFragment(viewModel)
|
||||
} else {
|
||||
CanUseStatusFragment(viewModel)
|
||||
}
|
||||
|
||||
fragmentTransaction.add(R.id.container, fragment, tag)
|
||||
} else {
|
||||
fragmentTransaction.show(fragment)
|
||||
}
|
||||
|
||||
fragmentTransaction.setPrimaryNavigationFragment(fragment)
|
||||
fragmentTransaction.setReorderingAllowed(true)
|
||||
fragmentTransaction.commitNow()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun bindData() {
|
||||
viewModel.totalCoinLiveData.observe(this) {
|
||||
binding.tvTotalCoin.text = it.moneyFormat()
|
||||
}
|
||||
|
||||
viewModel.paidCoinLiveData.observe(this) {
|
||||
binding.tvPaidCoin.text = it.moneyFormat()
|
||||
}
|
||||
|
||||
viewModel.rewardCoinLiveData.observe(this) {
|
||||
binding.tvRewardCoin.text = it.moneyFormat()
|
||||
}
|
||||
|
||||
viewModel.toastLiveData.observe(this) {
|
||||
it?.let { Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show() }
|
||||
}
|
||||
|
||||
viewModel.isLoading.observe(this) {
|
||||
if (it) {
|
||||
loadingDialog.show(screenWidth)
|
||||
} else {
|
||||
loadingDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onClickBackButton() {
|
||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.orhanobut.logger.Logger
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
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.mypage.can.CanRepository
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.charge.GetCanChargeStatusResponseItem
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.use.GetCanUseStatusResponseItem
|
||||
|
||||
class CanStatusViewModel(private val repository: CanRepository) : BaseViewModel() {
|
||||
private val _totalCoinLiveData = MutableLiveData<Int>()
|
||||
val totalCoinLiveData: LiveData<Int>
|
||||
get() = _totalCoinLiveData
|
||||
|
||||
private val _paidCoinLiveData = MutableLiveData<Int>()
|
||||
val paidCoinLiveData: LiveData<Int>
|
||||
get() = _paidCoinLiveData
|
||||
|
||||
private val _rewardCoinLiveData = MutableLiveData<Int>()
|
||||
val rewardCoinLiveData: LiveData<Int>
|
||||
get() = _rewardCoinLiveData
|
||||
|
||||
private val _coinUseStatusLiveData = MutableLiveData<List<GetCanUseStatusResponseItem>>()
|
||||
val coinUseStatusLiveData: LiveData<List<GetCanUseStatusResponseItem>>
|
||||
get() = _coinUseStatusLiveData
|
||||
|
||||
private val _coinChargeStatusLiveData = MutableLiveData<List<GetCanChargeStatusResponseItem>>()
|
||||
val coinChargeStatusLiveData: LiveData<List<GetCanChargeStatusResponseItem>>
|
||||
get() = _coinChargeStatusLiveData
|
||||
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
get() = _toastLiveData
|
||||
|
||||
private var _isLoading = MutableLiveData(false)
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private val pageSize = 20
|
||||
private var canUsesPage = 1
|
||||
|
||||
fun getCanStatus() {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.getCanStatus("Bearer ${SharedPreferenceManager.token}")
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
_isLoading.value = false
|
||||
if (it.success && it.data != null) {
|
||||
_totalCoinLiveData.postValue(it.data.chargeCan + it.data.rewardCan)
|
||||
_paidCoinLiveData.postValue(it.data.chargeCan)
|
||||
_rewardCoinLiveData.postValue(it.data.rewardCan)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun getCoinUseStatus() {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.getCanUseStatus(
|
||||
canUsesPage,
|
||||
pageSize,
|
||||
"Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
_isLoading.value = false
|
||||
if (it.success && it.data != null) {
|
||||
_coinUseStatusLiveData.postValue(it.data!!)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun getCanChargeStatus() {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.getCanChargeStatus(
|
||||
canUsesPage,
|
||||
pageSize,
|
||||
"Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
_isLoading.value = false
|
||||
if (it.success && it.data != null) {
|
||||
_coinChargeStatusLiveData.postValue(it.data!!)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class GetCanStatusResponse(
|
||||
@SerializedName("chargeCan")
|
||||
val chargeCan: Int,
|
||||
@SerializedName("rewardCan")
|
||||
val rewardCan: Int
|
||||
)
|
|
@ -0,0 +1,37 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status.charge
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.databinding.ItemCanChargeStatusBinding
|
||||
|
||||
class CanChargeStatusAdapter : RecyclerView.Adapter<CanChargeStatusAdapter.ViewHolder>() {
|
||||
|
||||
val items = mutableListOf<GetCanChargeStatusResponseItem>()
|
||||
|
||||
inner class ViewHolder(
|
||||
private val binding: ItemCanChargeStatusBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item: GetCanChargeStatusResponseItem) {
|
||||
binding.tvTitle.text = item.coinTitle
|
||||
binding.tvDate.text = item.date
|
||||
binding.tvChargeMethod.text = item.chargeMethod
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder(
|
||||
ItemCanChargeStatusBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: CanChargeStatusAdapter.ViewHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.count()
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status.charge
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.base.BaseFragment
|
||||
import kr.co.vividnext.sodalive.databinding.FragmentCanStatusBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.CanStatusViewModel
|
||||
|
||||
class CanChargeStatusFragment(
|
||||
private val viewModel: CanStatusViewModel
|
||||
) : BaseFragment<FragmentCanStatusBinding>(
|
||||
FragmentCanStatusBinding::inflate
|
||||
) {
|
||||
|
||||
private lateinit var adapter: CanChargeStatusAdapter
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
setupView()
|
||||
bindData()
|
||||
viewModel.getCanChargeStatus()
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun setupView() {
|
||||
val recyclerView = binding.rvCoinStatus
|
||||
adapter = CanChargeStatusAdapter()
|
||||
|
||||
recyclerView.layoutManager = LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
|
||||
recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
|
||||
when (parent.getChildAdapterPosition(view)) {
|
||||
0 -> {
|
||||
outRect.top = 13.3f.dpToPx().toInt()
|
||||
outRect.bottom = 6.7f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
adapter.itemCount - 1 -> {
|
||||
outRect.top = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 13.3f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
else -> {
|
||||
outRect.top = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 6.7f.dpToPx().toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun bindData() {
|
||||
viewModel.coinChargeStatusLiveData.observe(viewLifecycleOwner) {
|
||||
adapter.items.addAll(it)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
viewModel.toastLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let { Toast.makeText(requireContext(), it, Toast.LENGTH_LONG).show() }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status.charge
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class GetCanChargeStatusResponseItem(
|
||||
@SerializedName("coinTitle")
|
||||
val coinTitle: String,
|
||||
@SerializedName("date")
|
||||
val date: String,
|
||||
@SerializedName("chargeMethod")
|
||||
val chargeMethod: String
|
||||
)
|
|
@ -0,0 +1,37 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status.use
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.databinding.ItemCanUseStatusBinding
|
||||
|
||||
class CanUseStatusAdapter : RecyclerView.Adapter<CanUseStatusAdapter.ViewHolder>() {
|
||||
|
||||
val items = mutableListOf<GetCanUseStatusResponseItem>()
|
||||
|
||||
inner class ViewHolder(
|
||||
private val binding: ItemCanUseStatusBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item: GetCanUseStatusResponseItem) {
|
||||
binding.tvTitle.text = item.title
|
||||
binding.tvDate.text = item.date
|
||||
binding.tvCoin.text = "${item.can}"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder(
|
||||
ItemCanUseStatusBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.count()
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status.use
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.base.BaseFragment
|
||||
import kr.co.vividnext.sodalive.databinding.FragmentCanStatusBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.CanStatusViewModel
|
||||
|
||||
class CanUseStatusFragment(
|
||||
private val viewModel: CanStatusViewModel
|
||||
) : BaseFragment<FragmentCanStatusBinding>(
|
||||
FragmentCanStatusBinding::inflate
|
||||
) {
|
||||
|
||||
private lateinit var adapter: CanUseStatusAdapter
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
setupView()
|
||||
bindData()
|
||||
viewModel.getCoinUseStatus()
|
||||
}
|
||||
|
||||
private fun setupView() {
|
||||
val recyclerView = binding.rvCoinStatus
|
||||
adapter = CanUseStatusAdapter()
|
||||
|
||||
recyclerView.layoutManager = LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
|
||||
recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
|
||||
when (parent.getChildAdapterPosition(view)) {
|
||||
0 -> {
|
||||
outRect.top = 13.3f.dpToPx().toInt()
|
||||
outRect.bottom = 6.7f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
adapter.itemCount - 1 -> {
|
||||
outRect.top = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 13.3f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
else -> {
|
||||
outRect.top = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 6.7f.dpToPx().toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun bindData() {
|
||||
viewModel.coinUseStatusLiveData.observe(viewLifecycleOwner) {
|
||||
adapter.items.addAll(it)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
viewModel.toastLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let { Toast.makeText(requireContext(), it, Toast.LENGTH_LONG).show() }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package kr.co.vividnext.sodalive.mypage.can.status.use
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class GetCanUseStatusResponseItem(
|
||||
@SerializedName("title")
|
||||
val title: String,
|
||||
@SerializedName("date")
|
||||
val date: String,
|
||||
@SerializedName("can")
|
||||
val can: Int
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/color_80d8ff" />
|
||||
<corners android:radius="10dp" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/color_80d8ff" />
|
||||
</shape>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/color_111111" />
|
||||
<corners android:radius="16.7dp" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/color_111111" />
|
||||
</shape>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/color_222222" />
|
||||
<corners
|
||||
android:topLeftRadius="16.7dp"
|
||||
android:topRightRadius="16.7dp" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/color_222222" />
|
||||
</shape>
|
|
@ -0,0 +1,203 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout 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="match_parent"
|
||||
android:background="@color/black">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/detail_toolbar" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_above="@+id/fl_charge_coin"
|
||||
android:layout_below="@+id/toolbar">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="13.3dp"
|
||||
android:layout_marginTop="13.3dp"
|
||||
android:background="@drawable/bg_round_corner_16_7_222222"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="16.7dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_total_coin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="6.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="18.3sp"
|
||||
app:drawableStartCompat="@drawable/ic_can"
|
||||
tools:text="23,000" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20.3dp"
|
||||
android:gravity="center">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_payment_coin_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:fontFamily="@font/gmarket_sans_light"
|
||||
android:text="결제 코인"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tv_payment_coin_title"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="6.7dp"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_paid_coin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="16.7sp"
|
||||
tools:text="20,000" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="캔"
|
||||
android:textColor="@color/color_bbbbbb"
|
||||
android:textSize="10.7sp"
|
||||
tools:ignore="SmallSp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="26.7dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/color_88909090" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_reward_coin_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:fontFamily="@font/gmarket_sans_light"
|
||||
android:text="리워드 캔"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tv_reward_coin_title"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="6.7dp"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_reward_coin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="16.7sp"
|
||||
tools:text="20,000" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="캔"
|
||||
android:textColor="@color/color_bbbbbb"
|
||||
android:textSize="10.7sp"
|
||||
tools:ignore="SmallSp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
app:tabIndicatorColor="@color/color_80d8ff"
|
||||
app:tabIndicatorHeight="1.3dp"
|
||||
app:tabSelectedTextColor="@color/color_eeeeee"
|
||||
app:tabTextAppearance="@style/tabText"
|
||||
app:tabTextColor="@color/color_777777" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_charge_coin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/bg_top_round_corner_16_7_222222">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_charge_coin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="13.3dp"
|
||||
android:layout_marginVertical="13.7dp"
|
||||
android:background="@drawable/bg_round_corner_10_80d8ff"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_can" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:gravity="center"
|
||||
android:text="충전하기"
|
||||
android:textColor="@color/color_1313bc"
|
||||
android:textSize="18.3sp" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_coin_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
|
@ -166,6 +166,7 @@
|
|||
android:padding="13.3dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_total_coin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?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"
|
||||
android:background="@drawable/bg_round_corner_16_7_111111"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
android:paddingTop="13.3dp"
|
||||
android:paddingBottom="6.7dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="13.3sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="50코인" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
tools:text="2021.07.22 | 21:02:45" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_charge_method"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="15.3sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="신용카드" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,50 @@
|
|||
<?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"
|
||||
android:background="@drawable/bg_round_corner_16_7_111111"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
android:paddingTop="13.3dp"
|
||||
android:paddingBottom="6.7dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="13.3sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="[후원] 상남자" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
tools:text="2021.07.22 | 21:02:45" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_coin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="6.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="15.3sp"
|
||||
app:drawableEndCompat="@drawable/ic_can"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="300" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -29,4 +29,6 @@
|
|||
<color name="color_88909090">#88909090</color>
|
||||
<color name="color_339970ff">#339970FF</color>
|
||||
<color name="color_7fe2e2e2">#7FE2E2E2</color>
|
||||
<color name="color_80d8ff">#80DFFF</color>
|
||||
<color name="color_1313bc">#1313BC</color>
|
||||
</resources>
|
||||
|
|
|
@ -22,4 +22,8 @@
|
|||
<item name="colorControlNormal">@color/color_9970ff</item>
|
||||
<item name="colorControlActivated">@color/color_9970ff</item>
|
||||
</style>
|
||||
|
||||
<style name="tabText" parent="@android:style/TextAppearance.Widget.TabWidget">
|
||||
<item name="android:fontFamily">@font/gmarket_sans_medium</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue