스팀 앱 - 개발 중: 사용자 히스토리 화면을 보여주는데 필요한 AccountHistoryItemListAdapter 클래스 개발 중

스팀 앱 - 개발 중: 사용자 히스토리 화면을 보여주는데 필요한 AccountHistoryItemListAdapter 클래스 개발 중

2024. 07. 28 (일) | Written by @dorian-mobileapp

작업 내용

히스토리 리스트를 보여주기 위해 필요한 어댑터 클래스 AccountHistoryItemListAdapter를 만들고 있습니다. 예전에 작성했던 PostItemListAdapter를 베이스로 가져와서 작업하면 되므로 힘든 작업은 아닙니다. 그런데 한가지 추가로 작업할게 남았습니다. 타임스탬프를 사용자가 이해할 수 있는 시간으로 바꿔주는 것입니다. 이게 예전에는 구현이 안되었네요. 다른 API에서는 타임스탬프 대신 시간 형태의 텍스트를 줬기 때문입니다. 이 작업은 내일 하도록 하겠습니다.

class AccountHistoryItemListAdapter() : RecyclerView.Adapter<AccountHistoryItemListAdapter.AccountHistoryItemListViewHolder>() {

    private val accountHistoryItemList = mutableListOf<AccountHistoryItem>()

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountHistoryItemListViewHolder {
        return AccountHistoryItemListViewHolder(LayoutAccountHistoryItemBinding.inflate(
            LayoutInflater.from(parent.context),
            parent,
            false
        ))
    }

    override fun onBindViewHolder(holder: AccountHistoryItemListViewHolder, position: Int) {
        try {
            val post = accountHistoryItemList[position]
            holder.bind(post)
        }
        catch (e: IndexOutOfBoundsException) {
            e.printStackTrace()
        }
    }

    override fun getItemCount(): Int = accountHistoryItemList.size

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    fun setList(list: List<AccountHistoryItem>) {
        this.accountHistoryItemList.apply {
            clear()
            addAll(list)
        }
        notifyDataSetChanged()
    }

    inner class AccountHistoryItemListViewHolder(
        val binding: LayoutAccountHistoryItemBinding
    ) : RecyclerView.ViewHolder(binding.root) {
        fun bind(accountHistoryItem: AccountHistoryItem) {
            binding.apply {
                textHistoryItemContent.text = accountHistoryItem.content.toString()
                textHistoryItemTime.text = accountHistoryItem.timestamp    // convert timestamp to formatted string
            }
        }
    }

}

Layout provided by Steemit Enhancer hommage by ayogom


Posted through the ECblog app (https://blog.etain.club)
Sort:  

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)

The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.

안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.

[광고] STEEM 개발자 커뮤니티에 참여 하시면, 다양한 혜택을 받을 수 있습니다.


안녕하세요.
이 글은 SteemitKorea팀(@ayogom)님께서 저자이신 @dorian-mobileapp님을 응원하는 글입니다.
소정의 보팅을 해드렸습니다 ^^ 항상 좋은글 부탁드립니다
SteemitKorea팀에서는 보다 즐거운 steemit 생활을 위해 노력하고 있습니다.
이 글은 다음날 다시 한번 포스팅을 통해 소개 될 예정입니다. 감사합니다!

Upvoted! Thank you for supporting witness @jswit.

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.029
BTC 62497.97
ETH 2428.72
USDT 1.00
SBD 2.65