Exemplo n.º 1
0
  public void onCklick(View v) {
    if (task.isCancelled()) {
      task = new Task();
      task.link(this);
      task.execute();

    } else {
      task.execute();
    }
  }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    task = (Task) getLastCustomNonConfigurationInstance();
    if (task == null) {
      task = new Task();
      Log.d(TAG, "task = new Task() = " + task.hashCode());
    }
    task.link(this);
  }
Exemplo n.º 3
0
  /**
   * @param task
   * @param delay A delay in addition to the default duration of the timeout
   */
  public void schedule(Task task, long delay) {
    synchronized (_lock) {
      if (task._timestamp != 0) {
        task.unlink();
        task._timestamp = 0;
      }
      task._timeout = this;
      task._expired = false;
      task._delay = delay;
      task._timestamp = _now + delay;

      Task last = _head._prev;
      while (last != _head) {
        if (last._timestamp <= task._timestamp) break;
        last = last._prev;
      }
      last.link(task);
    }
  }