daimajia / daimajia/AndroidSwipeLayout
SwipeLayout as ListView item: SeekBar updating multiple time with recycled child views
- Lingua principale
- Java
- Stelle
- 12.4k
- Fork
- 2.6k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Hello,
I am using this project in my new app which shows a list of tracks with a play button and a SeekBar progress. I am able to get the tracks playing but I got an issue with updating the SeekBar.
- I use a Runnable and a Handler to update the SeekBar.
- When I hit play, the SeekBar of that child view, moving correctly, but the child at its recycled position got updated too. For example, I have a list of 10 items, with 5 visible items only. When 1st track's SeekBar got updating, the 6th track was also updated. The same thing happening with 11th or 16th... positions if I have bigger list.
Any suggestion to how I could get it updated properly?
**child_item.xml**
``` xml
```
**ListViewAdapter.java**
``` java
@Override
public void fillValues(int position, View convertView) {
ImageButton imageButton = (ImageButton) convertView.findViewById(R.id.buttonPlayPause);
TextView t = (TextView)convertView.findViewById(R.id.songName);
SeekBar seekbar = (SeekBar) convertView.findViewById(R.id.progressBar);
String url = adapterData[position];
MediaPlayer mp = mpUtils.getMediaPlayer(url);
imageButton.setTag(R.id.TAG_MEDIAPLAYER, mp);
imageButton.setBackgroundResource(R.drawable.ic_media_play);
Runnable updateProgress = new UpdateSongTime(mp,seekbar);
imageButton.setOnClickListener(new playButtonClicked(position,updateProgress));
t.setText((position + 1) + ".");
}
private class UpdateSongTime implements Runnable {
MediaPlayer mediaPlayer;
SeekBar seekBar;
double startTime = 0;
public UpdateSongTime(MediaPlayer mp, SeekBar sb){
this.mediaPlayer = mp;
this.seekBar = sb;
}
public void run() {
startTime = mediaPlayer.getCurrentPosition();
seekBar.setProgress((int)startTime);
myHandler.postDelayed(this, 100);
}
};
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia in ListViewAdapter.java con fillValues e UpdateSongTime, quindi esamina come child_item.xml associa progressBar nelle righe riciclate di ListView. Riproduci il problema con più elementi rispetto alle righe visibili; il lavoro è completato quando gli aggiornamenti dell’avanzamento influiscono solo sulla traccia prevista e le righe riciclate mantengono lo stato corretto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, java
- Ambito
- mobile
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100