I have may own class "Torrent" which contains some data about my uTorrent downloads on dedicated PC. ArrayList<Torrent> torrents
is updating in background every second.
So, I have a RecyclerView.Adapter like known pattern.
Please, explain me, WHY this code is working perfectly:
@Override
public void onBindViewHolder(final MyViewHolder holder,int position){
...
// Update ETA textView
holder.tvEta.setText(String.format(Locale.getDefault(),"%d h %d min %d s",torrents.get(position).getEta()/3600,(torrents.get(position).getEta()%3600)/60,torrents.get(position).getEta()%60));
...
}
But in this case NOT WORKING? It just update first value on start and not changing more:
@Override
public void onBindViewHolder(final MyViewHolder holder,int position){
...
// Update ETA textView
int secs = torrents.get(position).getEta();
int hours = secs / 3600;
int minutes = (secs % 3600) / 60;
int seconds = secs % 60;
holder.tvEta.setText(Locale.getDefault(), String.format("%d h %d min %d s", hours, minutes, seconds));
...
}