-
-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Payload processing refactoring #337
Conversation
fun CharSequence.applyBoldSpan() = SpannableString(this).apply { | ||
setSpan(StyleSpan(Typeface.BOLD), 0, this.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be ok to name it .bold()
?
It could be called as "${headerItem.name}: ".bold()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
|
||
internal class TransactionHeadersAdapter : RecyclerView.Adapter<TransactionHeadersAdapter.HeaderViewHolder>() { | ||
|
||
private val headers = arrayListOf<HttpHeader>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generaly speaking, I don't get why we should use arrayListOf
instead of mutableListOf
.
private val headerAdapter by lazy { TransactionHeadersAdapter() } | ||
private val bodyAdapter by lazy { TransactionBodyAdapter() } | ||
private val imageAdapter by lazy { TransactionImageAdapter() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 adapter are not yet called, is it normal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a draft PR, it is not finalized as well as not meant for review.
Looks like RecyclerView update isn't a priority for Google now, because 1.2.0 is still in alpha. Closing till we have a stable |
📄 Context
ConcatAdapter seems like a very suitable component for Chucker and its payload RecyclerView. Having 3 separate adapters for each part of payload (headers, text body or image body) can help us to incorporate lots of improvements, like #324 or #195 much easier.
For example, we could get rid of having all headers formatted as a single String with HTML markup as it is done now (this code is already in PR) and use just raw names and values, which gives us more flexibility like being able to set spans however we need it.
I came to this idea after doing some work on search improvements for #195. Moreover, as we already discussed in some PRs as a side topic we need to move payload processing for output into a ViewModel.
My intention here is to have 3 lazily initialised adapters which we will add into parent only if there is a corresponding content (like add
ImageAdapter
only if there is an image in a payload).Also, I am going to switch to something similar to MVI approach to have states which view observes and renders (loading, data, empty).
This PR is in early preview, so no need for review. However, feedback is welcome.
I made it visible to everyone, since it might help some contributors to see where this part of the library is heading and to not produce too much conflicts.
📝 Changes
PayloadAdapter
to be a newMergeAdapter
to be continued...
📎 Related PR
Will add later