Android Open Source - EnklawaPlayer Sleep Timer

From Project

Back to project page EnklawaPlayer.


The source code is released under:

GNU General Public License

If you think the Android project EnklawaPlayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package macbury.pod.extensions;
/* w  w w. ja va  2  s .c o m*/
import android.os.Handler;

import macbury.pod.managers.App;

 * Created by macbury on 23.09.14.
public class SleepTimer extends Thread {

  private final SleepTimerListener listener;
  private final int delay;
  private final Handler mainHandler;
  private final Runnable listenerTickRunnable;
  private boolean running;

  public SleepTimer(int delay, SleepTimerListener listener) {
    this.mainHandler          = new Handler(App.current().getMainLooper());
    this.listener             = listener;
    this.delay                = delay;
    this.running              = true;
    this.listenerTickRunnable = new Runnable() {
      public void run() {
        if (running)

  public void run() {
    while (running) {
      try {
      } catch (InterruptedException e) {
        running = false;

  public void kill() {
    this.running = false;

  public interface SleepTimerListener {
    public void onSleepTimerTick(SleepTimer timer);

Java Source Code List