run postDelayed in background thread

This commit is contained in:
Daniel Gultsch 2019-05-08 14:11:28 +02:00
parent 6785d8c69f
commit 5bedde7913

View file

@ -23,6 +23,8 @@ import android.widget.TextView;
import java.lang.ref.WeakReference;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
@ -46,6 +48,8 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti
private final Sensor proximitySensor;
private final PendingItem<WeakReference<ImageButton>> pendingOnClickView = new PendingItem<>();
private final ExecutorService executor = Executors.newSingleThreadExecutor();
private final Handler handler = new Handler();
public AudioPlayer(MessageAdapter adapter) {
@ -87,7 +91,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti
audioPlayer.setTag(message);
if (init(ViewHolder.get(audioPlayer), message)) {
this.audioPlayerLayouts.addWeakReferenceTo(audioPlayer);
this.stopRefresher(true);
executor.execute(()-> this.stopRefresher(true));
} else {
this.audioPlayerLayouts.removeWeakReferenceTo(audioPlayer);
}