Closed efeint01 closed 1 year ago
any help?
Where did you call speedTo
function?
hi thank you reply. i was think this repo is dead but its alive. here is my codes
public class DashGaugeAdapter extends RecyclerView.Adapter<DashGaugeAdapter.ViewHolder> {
ArrayList<DashGaugeItem> arrayList;
public DashGaugeAdapter(ArrayList<DashGaugeItem> arrayList) {
this.arrayList = arrayList;
}
@NonNull
@Override
public DashGaugeAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new DashGaugeAdapter.ViewHolder(RowDashGaugeCardItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
@Override
public void onBindViewHolder(@NonNull DashGaugeAdapter.ViewHolder holder, int position) {
DashGaugeItem model = arrayList.get(position);
holder.binding.titleTw.setText(model.getTitle());
holder.binding.speedView.setUnit(model.getUnit()); //Set UNIT
holder.binding.speedView.realSpeedPercentTo(model.getValue());; //When the adapter is updated, the animation of the old data ends and cannot reach the speed I want
}
@Override
public int getItemCount() {
return arrayList.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
RowDashGaugeCardItemBinding binding;
public ViewHolder(RowDashGaugeCardItemBinding binding) {
super(binding.getRoot());
this.binding = binding;
// first remove all old sections.
binding.speedView.clearSections();
binding.speedView.addSections(new Section(0f, .1f, Color.LTGRAY)
, new Section(.1f, .4f, Color.YELLOW)
, new Section(.4f, .75f, Color.BLUE)
, new Section(.75f, .9f, Color.RED));
// be aware, we didn't add Section(.9f, 1f, ..) because we need it empty.
}
}
}
Before running the animation, you should re-initiate the start point by calling setSpeedAt()
and pass the start speed value.
it's working! i just setsetSpeedAt(0)
beforerealSpeedPercentTo()
thank you for awesome library!
When I add new data, whenever I use the adapter.notifydatasetchanged() method, the animation of the old data ends and the value cannot reach the place I set.