Don't use notifyDataSetChanged in TimelineFragment (#2334)

This commit is contained in:
Konrad Pozniak 2022-02-25 18:57:40 +01:00 committed by GitHub
parent f7dfffa762
commit c592dfef78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,6 +38,7 @@ import com.keylesspalace.tusky.AccountListActivity
import com.keylesspalace.tusky.AccountListActivity.Companion.newIntent import com.keylesspalace.tusky.AccountListActivity.Companion.newIntent
import com.keylesspalace.tusky.BaseActivity import com.keylesspalace.tusky.BaseActivity
import com.keylesspalace.tusky.R import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.adapter.StatusBaseViewHolder
import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.EventHub
import com.keylesspalace.tusky.appstore.PreferenceChangedEvent import com.keylesspalace.tusky.appstore.PreferenceChangedEvent
import com.keylesspalace.tusky.appstore.StatusComposedEvent import com.keylesspalace.tusky.appstore.StatusComposedEvent
@ -406,7 +407,7 @@ class TimelineFragment :
val oldMediaPreviewEnabled = adapter.mediaPreviewEnabled val oldMediaPreviewEnabled = adapter.mediaPreviewEnabled
if (enabled != oldMediaPreviewEnabled) { if (enabled != oldMediaPreviewEnabled) {
adapter.mediaPreviewEnabled = enabled adapter.mediaPreviewEnabled = enabled
adapter.notifyDataSetChanged() adapter.notifyItemRangeChanged(0, adapter.itemCount)
} }
} }
} }
@ -452,7 +453,7 @@ class TimelineFragment :
talkBackWasEnabled = a11yManager?.isEnabled == true talkBackWasEnabled = a11yManager?.isEnabled == true
Log.d(TAG, "talkback was enabled: $wasEnabled, now $talkBackWasEnabled") Log.d(TAG, "talkback was enabled: $wasEnabled, now $talkBackWasEnabled")
if (talkBackWasEnabled && !wasEnabled) { if (talkBackWasEnabled && !wasEnabled) {
adapter.notifyDataSetChanged() adapter.notifyItemRangeChanged(0, adapter.itemCount)
} }
startUpdateTimestamp() startUpdateTimestamp()
} }
@ -470,7 +471,7 @@ class TimelineFragment :
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.autoDispose(this, Lifecycle.Event.ON_PAUSE) .autoDispose(this, Lifecycle.Event.ON_PAUSE)
.subscribe { .subscribe {
adapter.notifyDataSetChanged() adapter.notifyItemRangeChanged(0, adapter.itemCount, listOf(StatusBaseViewHolder.Key.KEY_CREATED))
} }
} }
} }