Convert AccountViewHolder from Java to Kotlin (#3044)
* Convert AccountViewHolder from Java to Kotlin Use view binding in the converted code, which requires small changes in code that calls constructors. Pass showBotOverlays as a parameter, rather than having the code reach in to the shared preferences, fixing a layering violation. This affects callers and classes derived from AccountAdapter. * Use 2-arg getString * Simplify setting bot badge indicator - Specify the drawable in the XML - Use visible() to set visibility - Rename ID to account_bot_badge to make it clearer that this is all it is for * Use lateinit to avoid needing !! later
This commit is contained in:
parent
a21f2fadf9
commit
ee765a3117
13 changed files with 116 additions and 91 deletions
|
|
@ -95,17 +95,18 @@ class AccountListFragment : Fragment(R.layout.fragment_account_list), AccountAct
|
|||
val pm = PreferenceManager.getDefaultSharedPreferences(view.context)
|
||||
val animateAvatar = pm.getBoolean(PrefKeys.ANIMATE_GIF_AVATARS, false)
|
||||
val animateEmojis = pm.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false)
|
||||
val showBotOverlay = pm.getBoolean(PrefKeys.SHOW_BOT_OVERLAY, true)
|
||||
|
||||
adapter = when (type) {
|
||||
Type.BLOCKS -> BlocksAdapter(this, animateAvatar, animateEmojis)
|
||||
Type.MUTES -> MutesAdapter(this, animateAvatar, animateEmojis)
|
||||
Type.BLOCKS -> BlocksAdapter(this, animateAvatar, animateEmojis, showBotOverlay)
|
||||
Type.MUTES -> MutesAdapter(this, animateAvatar, animateEmojis, showBotOverlay)
|
||||
Type.FOLLOW_REQUESTS -> {
|
||||
val headerAdapter = FollowRequestsHeaderAdapter(accountManager.activeAccount!!.domain, arguments?.getBoolean(ARG_ACCOUNT_LOCKED) == true)
|
||||
val followRequestsAdapter = FollowRequestsAdapter(this, animateAvatar, animateEmojis)
|
||||
val followRequestsAdapter = FollowRequestsAdapter(this, animateAvatar, animateEmojis, showBotOverlay)
|
||||
binding.recyclerView.adapter = ConcatAdapter(headerAdapter, followRequestsAdapter)
|
||||
followRequestsAdapter
|
||||
}
|
||||
else -> FollowAdapter(this, animateAvatar, animateEmojis)
|
||||
else -> FollowAdapter(this, animateAvatar, animateEmojis, showBotOverlay)
|
||||
}
|
||||
if (binding.recyclerView.adapter == null) {
|
||||
binding.recyclerView.adapter = adapter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue