Android Open Source - TileView Animator






From Project

Back to project page TileView.

License

The source code is released under:

MIT License

If you think the Android project TileView 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.qozix.animation;
/* w w w .  j  a v a 2  s.  c o m*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.qozix.animation.easing.EasingEquation;
import com.qozix.animation.easing.Linear;

import android.os.Handler;
import android.os.Message;

public class Animator {

  private double ellapsed;
  private double startTime;
  private double duration = 500;

  private HashMap<String, Double> properties = new HashMap<String, Double>();
  private HashMap<String, Double> values = new HashMap<String, Double>();
  
  private ArrayList<AnimationListener> listeners = new ArrayList<AnimationListener>();
  private EasingEquation ease = Linear.EaseNone;

  public void setAnimationEase(EasingEquation e) {
    if(e == null || !( e instanceof EasingEquation)){
      e = Linear.EaseNone;
    }
    ease = e;
  }

  public void addAnimationListener(AnimationListener l) {
    listeners.add(l);
  }
  
  public void removeAnimationListener(AnimationListener l){
    listeners.remove(l);
  }

  public double getDuration() {
    return duration;
  }

  public void setDuration(double time) {
    duration = time;
  }

  public HashMap<String, Double> getProperties() {
    return properties;
  }

  public void setProperties(HashMap<String, Double> p) {
    properties = p;
  }
  
  public void addProperties(HashMap<String, Double> p){
    properties.putAll(p);
  }
  
  public void addProperty(String s, Double d){
    properties.put(s, d);
  }

  public void start() {
    values.putAll(properties);
    ellapsed = 0;
    startTime = System.currentTimeMillis();
    handler.sendEmptyMessage(0);
    for(AnimationListener l : listeners){
      l.onAnimationStart();
    }
  }

  private Handler handler = new Handler() {
    @Override
    public void handleMessage(final Message message) {
      ellapsed = System.currentTimeMillis() - startTime;
      for(Map.Entry<String, Double> e : values.entrySet()) {
        String key = e.getKey();
        Double value = e.getValue();
        Double originalValue = properties.get(key);
        Double computedValue = ease.compute(ellapsed, originalValue, originalValue - value, duration);
        e.setValue(computedValue);
      }
      for(AnimationListener l : listeners){
        l.onAnimationProgress(values);
      }
      if (ellapsed >= duration) {
        if (hasMessages(0)) {
          removeMessages(0);
        }
        for(AnimationListener l : listeners){
          l.onAnimationComplete();
        }
      } else {
        sendEmptyMessage(0);
      }

    }
  };

}




Java Source Code List

com.qozix.animation.AnimationListener.java
com.qozix.animation.Animator.java
com.qozix.animation.TweenHandler.java
com.qozix.animation.TweenListener.java
com.qozix.animation.Tween.java
com.qozix.animation.easing.EasingEquation.java
com.qozix.animation.easing.Linear.java
com.qozix.animation.easing.Strong.java
com.qozix.layouts.AnchorLayout.java
com.qozix.layouts.FixedLayout.java
com.qozix.layouts.ScalingLayout.java
com.qozix.layouts.StaticLayout.java
com.qozix.layouts.TranslationLayout.java
com.qozix.layouts.ZoomPanLayout.java
com.qozix.os.AsyncTask.java
com.qozix.tileview.TileView.java
com.qozix.tileview.detail.DetailLevelEventListener.java
com.qozix.tileview.detail.DetailLevelPatternParserDefault.java
com.qozix.tileview.detail.DetailLevelPatternParser.java
com.qozix.tileview.detail.DetailLevelSet.java
com.qozix.tileview.detail.DetailLevelSetupListener.java
com.qozix.tileview.detail.DetailLevel.java
com.qozix.tileview.detail.DetailManager.java
com.qozix.tileview.geom.PositionManager.java
com.qozix.tileview.graphics.BitmapDecoderAssets.java
com.qozix.tileview.graphics.BitmapDecoderHttp.java
com.qozix.tileview.graphics.BitmapDecoder.java
com.qozix.tileview.hotspots.HotSpotEventListener.java
com.qozix.tileview.hotspots.HotSpotManager.java
com.qozix.tileview.hotspots.HotSpot.java
com.qozix.tileview.markers.CalloutManager.java
com.qozix.tileview.markers.MarkerEventListener.java
com.qozix.tileview.markers.MarkerManager.java
com.qozix.tileview.paths.DrawablePath.java
com.qozix.tileview.paths.PathHelper.java
com.qozix.tileview.paths.PathManager.java
com.qozix.tileview.samples.SampleManager.java
com.qozix.tileview.tiles.TileCache.java
com.qozix.tileview.tiles.TileManager.java
com.qozix.tileview.tiles.TileRenderHandler.java
com.qozix.tileview.tiles.TileRenderListener.java
com.qozix.tileview.tiles.TileRenderTask.java
com.qozix.tileview.tiles.TileTransitionListener.java
com.qozix.tileview.tiles.Tile.java
com.qozix.tileview.tiles.selector.TileSetSelectorByRange.java
com.qozix.tileview.tiles.selector.TileSetSelectorClosest.java
com.qozix.tileview.tiles.selector.TileSetSelectorMinimalUpScale.java
com.qozix.tileview.tiles.selector.TileSetSelector.java
com.qozix.utils.ViewCurator.java
com.qozix.widgets.Scroller.java