Skip to content

Hyperloop

Michael Gangolf edited this page Feb 18, 2018 · 6 revisions

Lottie and Hyperloop

Lottie can be used in Hyperloop, too:

Android example:

  • create a new Hyperloop project
  • place the lottie-release.aar into app/platform/android/ (get it from maven.org)
  • put an animation json in app/assets/animation.json
var LottieAnimationView = require('com.airbnb.lottie.LottieAnimationView');
var Animator = require('android.animation.Animator');
var ValueAnimator = require('android.animation.ValueAnimator');
var ScaleType = require('android.widget.ImageView.ScaleType');
var lottieView = new LottieAnimationView(Ti.Android.currentActivity);
var animation = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, '/animation.json').read().text;

$.index.add(lottieView);
lottieView.addAnimatorListener(new Animator.AnimatorListener({
	onAnimationStart: function() {
		console.log("start");
	},
	onAnimationEnd: function() {
		console.log("end");
	},
	onAnimationRepeat: function() {
		console.log("repeat");
	}
}));

lottieView.addAnimatorUpdateListener(new ValueAnimator.AnimatorUpdateListener({
	onAnimationUpdate: function(ani) {
		console.log("Percentage", lottieView.getProgress().toFixed(2));
	}
}));
lottieView.setAnimationFromJson(animation);
lottieView.setScaleType(ScaleType.CENTER_INSIDE);
lottieView.loop(true);
lottieView.playAnimation();

$.index.open();
Clone this wiki locally