robinhood / spark

A simple Android sparkline chart view.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Notify an item changed in the data set instead of all item

wilik16 opened this issue · comments

commented

Is there a method to notify the adapter to update only for specific new data, which works like RecyclerView.Adapter.notifyItemChanged(int position) ?
If I call adapter.notifyDataSetChanged(); after adding a new data to the data set, the view will be refreshed completely and the animation will start from the first index of the data set instead of only the last inserted data (I enabled the animation changes).
Thank you.

We don't currently have any more granular animation than just animating the entire line's appearance.

Are you appending new points to the end of your data set, and want to animate just the appearance of that segment? Or are you changing points in the middle of your data set? I think the former would be fairly easy to make work, but the latter would be quite difficult to do generically.

commented

I see.
Yes exactly, I'm appending new points to the end of the data set.and just want to animate only the new added points.

@wilik16 sorry for forgetting about this for so long!

This animation would only make sense under very narrow circumstances. You'd have to have set a manual bounds around your before and after data, and those manual bounds would need to be the exact same for both before and after. Otherwise the graph will snap sharply to the left at the beginning of the animation, and then the rest of the path would animate in.

I don't think supporting this in Spark itself makes sense, but you're always welcome to fork for your own use-case.