Android Open Source - Save-the-Planet Tickable






From Project

Back to project page Save-the-Planet.

License

The source code is released under:

Copyright (c) 2002 JSON.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software ...

If you think the Android project Save-the-Planet 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 com.karolmajta.stp.models;
//from   w  w  w  .  j  av a 2 s.  c  o  m
/**
 * Basic implementation of {@link ITickable} providing default
 * (and probably the most expected) behavior. {@link Tickable}
 * will start ignoring calls to {@link Tickable#tick(long)} after
 * {@link Tickable#ignoreTicks(boolean)} was called with
 * true, and will stop ignoring them after called with false.
 * 
 * @author Karol Majta
 *
 */
public abstract class Tickable implements ITickable {
  private boolean ignore;
  
  public Tickable() {
    ignore = false;
  }
  
  /**
   * Overwrite this method to provide specific behavior when calls to
   * {@link Tickable#tick(long)} are generated.
   * 
   * @param dt Time in milliseconds since this object was last ticked.
   *     Notice that these intervals are between calls to
   *     {@link Tickable#tick(long)}, not {@link Tickable#onTick(long)}.
   *     This might be important when calling
   *     {@link Tickable#ignoreTicks(boolean)} provided argument can
   *     not be used as to calculate the length of ignore-period. 
   */
  protected abstract void onTick(long dt);
  
  /**
   * Will call {@link Tickable#onTick(long)} if
   * {@link Tickable#ignoresTicks()} returns false, else will
   * do nothing.
   */
  @Override
  public final void tick(long dt) {
    if(!ignoresTicks()){
      onTick(dt);
    }
  }

  /**
   * Will always affect value returned by
   * {@link Tickable#ignoresTicks()}
   */
  @Override
  public final void ignoreTicks(boolean flag) {
    ignore = flag;
  }
  
  /**
   * Will always return the last value passed to
   * {@link Tickable#ignoreTicks(boolean)}
   */
  @Override
  public final boolean ignoresTicks() {
    return ignore;
  }
}




Java Source Code List

com.karolmajta.procprox.DragDetector.java
com.karolmajta.procprox.Drag.java
com.karolmajta.procprox.FontManager.java
com.karolmajta.procprox.IEventFilter.java
com.karolmajta.procprox.TapDetector.java
com.karolmajta.procprox.Tap.java
com.karolmajta.procprox.excepiton.FontNotCreatedException.java
com.karolmajta.stp.LoadingScreenActivity.java
com.karolmajta.stp.MainMenuActivity.java
com.karolmajta.stp.exception.NoDeferredException.java
com.karolmajta.stp.exception.NoTasksInProgressQueueException.java
com.karolmajta.stp.exception.STPException.java
com.karolmajta.stp.exception.UnboundViewException.java
com.karolmajta.stp.models.ICanCollide.java
com.karolmajta.stp.models.IPConstants.java
com.karolmajta.stp.models.IProgress.java
com.karolmajta.stp.models.ITask.java
com.karolmajta.stp.models.ITickable.java
com.karolmajta.stp.models.MainMenuItemBall.java
com.karolmajta.stp.models.MainMenuObstacleBall.java
com.karolmajta.stp.models.ObstacleManager.java
com.karolmajta.stp.models.SyncProgress.java
com.karolmajta.stp.models.SyncTask.java
com.karolmajta.stp.models.Tickable.java
com.karolmajta.stp.models.Viewport.java
com.karolmajta.stp.views.FancyTextView.java
com.karolmajta.stp.views.IDrawable.java
com.karolmajta.stp.views.MainMenuItemBallDebugView.java
com.karolmajta.stp.views.MainMenuItemBallView.java
com.karolmajta.stp.views.MainMenuObstacleBallDebugView.java
com.karolmajta.stp.views.MainMenuObstacleBallView.java
com.karolmajta.stp.views.ObstacleManagerView.java
com.karolmajta.stp.views.ProgressDebugView.java
com.karolmajta.stp.views.ProgressView.java
com.karolmajta.stp.views.View.java