improved status details reload
This commit is contained in:
parent
70b79d5019
commit
1c7bea07b1
|
@ -1 +1 @@
|
||||||
9ae153916806db7a16fffd9b76ef03d7ff4077a8
|
175c0b448173e3f9431a19d761e24270cb3a1c62
|
||||||
|
|
|
@ -1001,8 +1001,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
|
|
||||||
val interactUsersAdapter = itemView.countsUsers.adapter as CountsUsersAdapter
|
val interactUsersAdapter = itemView.countsUsers.adapter as CountsUsersAdapter
|
||||||
if (statusActivity != null) {
|
if (statusActivity != null) {
|
||||||
interactUsersAdapter.setUsers(statusActivity.retweeters)
|
updateStatusActivity(statusActivity)
|
||||||
interactUsersAdapter.setCounts(statusActivity)
|
|
||||||
} else {
|
} else {
|
||||||
interactUsersAdapter.setUsers(null)
|
interactUsersAdapter.setUsers(null)
|
||||||
interactUsersAdapter.setCounts(status)
|
interactUsersAdapter.setCounts(status)
|
||||||
|
@ -1145,6 +1144,12 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
status, item)
|
status, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun updateStatusActivity(activity: StatusActivity) {
|
||||||
|
val adapter = itemView.countsUsers.adapter as CountsUsersAdapter
|
||||||
|
adapter.setUsers(activity.retweeters)
|
||||||
|
adapter.setCounts(activity)
|
||||||
|
}
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
// menuBar.setOnMenuItemClickListener(this);
|
// menuBar.setOnMenuItemClickListener(this);
|
||||||
itemView.menuBar.setOnMenuItemClickListener(this)
|
itemView.menuBar.setOnMenuItemClickListener(this)
|
||||||
|
@ -1501,7 +1506,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
|
|
||||||
override var statusClickListener: StatusClickListener? = null
|
override var statusClickListener: StatusClickListener? = null
|
||||||
private var recyclerView: RecyclerView? = null
|
private var recyclerView: RecyclerView? = null
|
||||||
private var statusViewHolder: DetailStatusViewHolder? = null
|
private var detachedStatusViewHolder: DetailStatusViewHolder? = null
|
||||||
|
|
||||||
override val itemCounts = ItemCounts(ITEM_TYPES_SUM)
|
override val itemCounts = ItemCounts(ITEM_TYPES_SUM)
|
||||||
|
|
||||||
|
@ -1535,7 +1540,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
}
|
}
|
||||||
field = value
|
field = value
|
||||||
val statusIndex = getIndexStart(ITEM_IDX_STATUS)
|
val statusIndex = getIndexStart(ITEM_IDX_STATUS)
|
||||||
notifyItemChanged(statusIndex)
|
notifyItemChanged(statusIndex, value)
|
||||||
}
|
}
|
||||||
var statusAccount: AccountDetails? = null
|
var statusAccount: AccountDetails? = null
|
||||||
internal set
|
internal set
|
||||||
|
@ -1692,8 +1697,8 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder? {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder? {
|
||||||
when (viewType) {
|
when (viewType) {
|
||||||
VIEW_TYPE_DETAIL_STATUS -> {
|
VIEW_TYPE_DETAIL_STATUS -> {
|
||||||
if (statusViewHolder != null) {
|
if (detachedStatusViewHolder != null) {
|
||||||
return statusViewHolder
|
return detachedStatusViewHolder
|
||||||
}
|
}
|
||||||
val view = inflater.inflate(R.layout.header_status_compact, parent, false)
|
val view = inflater.inflate(R.layout.header_status_compact, parent, false)
|
||||||
val cardView = view.findViewById(R.id.compact_card)
|
val cardView = view.findViewById(R.id.compact_card)
|
||||||
|
@ -1720,6 +1725,29 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int, payloads: List<Any>) {
|
||||||
|
var handled = false
|
||||||
|
when (holder.itemViewType) {
|
||||||
|
VIEW_TYPE_DETAIL_STATUS -> {
|
||||||
|
holder as DetailStatusViewHolder
|
||||||
|
payloads.forEach { it ->
|
||||||
|
when (it) {
|
||||||
|
is StatusActivity -> {
|
||||||
|
holder.updateStatusActivity(it)
|
||||||
|
}
|
||||||
|
is ParcelableStatus -> {
|
||||||
|
holder.displayStatus(statusAccount, status, statusActivity,
|
||||||
|
translationResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (handled) return
|
||||||
|
super.onBindViewHolder(holder, position, payloads)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
when (holder.itemViewType) {
|
when (holder.itemViewType) {
|
||||||
VIEW_TYPE_DETAIL_STATUS -> {
|
VIEW_TYPE_DETAIL_STATUS -> {
|
||||||
|
@ -1758,14 +1786,14 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
|
|
||||||
override fun onViewDetachedFromWindow(holder: ViewHolder?) {
|
override fun onViewDetachedFromWindow(holder: ViewHolder?) {
|
||||||
if (holder is DetailStatusViewHolder) {
|
if (holder is DetailStatusViewHolder) {
|
||||||
statusViewHolder = holder as DetailStatusViewHolder?
|
detachedStatusViewHolder = holder as DetailStatusViewHolder?
|
||||||
}
|
}
|
||||||
super.onViewDetachedFromWindow(holder)
|
super.onViewDetachedFromWindow(holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewAttachedToWindow(holder: ViewHolder?) {
|
override fun onViewAttachedToWindow(holder: ViewHolder?) {
|
||||||
if (holder === statusViewHolder) {
|
if (holder === detachedStatusViewHolder) {
|
||||||
statusViewHolder = null
|
detachedStatusViewHolder = null
|
||||||
}
|
}
|
||||||
super.onViewAttachedToWindow(holder)
|
super.onViewAttachedToWindow(holder)
|
||||||
}
|
}
|
||||||
|
@ -1868,12 +1896,19 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setStatus(status: ParcelableStatus, account: AccountDetails?): Boolean {
|
fun setStatus(status: ParcelableStatus, account: AccountDetails?): Boolean {
|
||||||
val old = this.status
|
val oldStatus = this.status
|
||||||
|
val oldAccount = this.statusAccount
|
||||||
|
val changed = oldStatus != status && oldAccount != account
|
||||||
this.status = status
|
this.status = status
|
||||||
statusAccount = account
|
this.statusAccount = account
|
||||||
notifyDataSetChanged()
|
if (changed) {
|
||||||
updateItemDecoration()
|
notifyDataSetChanged()
|
||||||
return !CompareUtils.objectEquals(old, status)
|
updateItemDecoration()
|
||||||
|
} else {
|
||||||
|
val statusIndex = getIndexStart(ITEM_IDX_STATUS)
|
||||||
|
notifyItemChanged(statusIndex, status)
|
||||||
|
}
|
||||||
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateItemDecoration() {
|
fun updateItemDecoration() {
|
||||||
|
|
Loading…
Reference in New Issue