android-diffutils

Why is the drag animation being repeated in RecyclerView?

可紊 提交于 2021-01-29 05:16:03
问题 The bounty expires in 6 days . Answers to this question are eligible for a +50 reputation bounty. gig6 wants to draw more attention to this question. I am using the ItemTouchHelper class to support drag and drop in my RecyclerView. While I am dragging an item around it visually updates (swaps rows) as expected. Once I drop the item, another **visual** drag occurs. For example (see diagram below) if I drag item "a" from index 0 to index 3, the correct list shows that item "b" is now at index 0

RecyclerView / DiffUtils animation when dataset change without full refresh

↘锁芯ラ 提交于 2020-04-10 05:23:34
问题 I would like two things : To not reload / refresh the adapter when i delete an item inside RecyclerView (no use of notifyDatasetChanged ). To do so i am using DiffUtils which works perfectly fine. But i also would like to keep the DefaultItemAnimator of the RecyclerView which has apparently no effect with DiffUtils. So my question is : How can i remove / update an item without refreshing all the dataset AND keep a similar animation to the DefaultItemAnimator ? I know many posts gives answers

RecyclerView / DiffUtils animation when dataset change without full refresh

人盡茶涼 提交于 2020-04-10 05:23:13
问题 I would like two things : To not reload / refresh the adapter when i delete an item inside RecyclerView (no use of notifyDatasetChanged ). To do so i am using DiffUtils which works perfectly fine. But i also would like to keep the DefaultItemAnimator of the RecyclerView which has apparently no effect with DiffUtils. So my question is : How can i remove / update an item without refreshing all the dataset AND keep a similar animation to the DefaultItemAnimator ? I know many posts gives answers

DiffUtil ItemCallback areContentsTheSame() always returns true after updating an item on the ListAdapter

人盡茶涼 提交于 2020-02-21 13:53:46
问题 While using a ListAdapter I noticed that after updating an item the DiffUtil.ItemCallback areContentsTheSame() method was always returning true. Debugging the code I realized that the old and the new item were exactly the same (the old state disappeared). Therefore the ListAdapter onBindViewHolder() method wasn't being called to update the respective row on the list (only the order of the items changed with a nice animation). Checking other questions on Stackoverflow looks like it's a common

DiffUtil ItemCallback areContentsTheSame() always returns true after updating an item on the ListAdapter

本小妞迷上赌 提交于 2020-02-21 13:49:51
问题 While using a ListAdapter I noticed that after updating an item the DiffUtil.ItemCallback areContentsTheSame() method was always returning true. Debugging the code I realized that the old and the new item were exactly the same (the old state disappeared). Therefore the ListAdapter onBindViewHolder() method wasn't being called to update the respective row on the list (only the order of the items changed with a nice animation). Checking other questions on Stackoverflow looks like it's a common

Using Recyclerview with DiffUtil.ItemCallback doesn't scroll to top?

帅比萌擦擦* 提交于 2020-01-15 09:55:08
问题 I do search of items and every time I fetch from server When I search "o" it works and then "ot" it works again and as a result of "o" search I have let's say 20 items and in case "ot" I have 10 items which are part of that 20 items and I do remove t in EditText it shows 20 items only the recyclerview scroll indicator is in the middle Here is my Code for diffUtil ListAdapter<Asset, SearchAdapter.ViewHolder>(object : DiffUtil.ItemCallback<Asset>() { override fun areItemsTheSame(oldItem: Asset,

Using Recyclerview with DiffUtil.ItemCallback doesn't scroll to top?

≡放荡痞女 提交于 2020-01-15 09:54:11
问题 I do search of items and every time I fetch from server When I search "o" it works and then "ot" it works again and as a result of "o" search I have let's say 20 items and in case "ot" I have 10 items which are part of that 20 items and I do remove t in EditText it shows 20 items only the recyclerview scroll indicator is in the middle Here is my Code for diffUtil ListAdapter<Asset, SearchAdapter.ViewHolder>(object : DiffUtil.ItemCallback<Asset>() { override fun areItemsTheSame(oldItem: Asset,

RecyclerView scroll to top with AsyncListDiffer not working

a 夏天 提交于 2020-01-04 01:53:04
问题 I am using RecyclerView with AsyncListDiffer (calculates and animates differences between old and new items, all on background thread). I have a button to sort the list. After I sort it and re-set it to RecyclerView using mDiffer.submitList(items); I also call recyclerView.scrollToPosition(0) or ( smoothScrollToPosition(0) ), but it has no effect. I think this behaviour is expected, as AsyncListDiffer is probably still calculating differences at the time that scrollToPosition(0) is called, so

ListAdapter not refreshing RecyclerView if I submit the same list with different item order

风流意气都作罢 提交于 2019-12-22 10:32:19
问题 I am using a RecyclerView with ListAdapter (which uses AsyncListDiffer to calculate and animate changes when list is replaced). The problem is that if I submit() some list, then re-order that list, and submit() again, nothing happens. How do I force ListAdapter to evaluate this new list, even though it is "the same" (but order has changed)? New findings: I checked source code of submitList() and in the beggining there is a check: public void submitList(@Nullable final List<T> newList) { final

android Change background color of odd rows in RecyclerView when using DiffUtil

橙三吉。 提交于 2019-12-11 19:13:40
问题 I have a RecyclerView and Every odd row has a different background color. I try to add DiffUtil to speed up the updates like this: import android.content.Context import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.asdf.android.R import com.asdf.android.network.model.trade.MarketTradeItem import kotlinx.android