nativescript-keyframes
Version:
Easily use the Facebook Keyframes library in your NativeScript app.
54 lines • 2.01 kB
JavaScript
;
var image_1 = require("ui/image");
var fs = require("file-system");
var appPath = fs.knownFolders.currentApp().path;
var KeyframesView = (function (_super) {
__extends(KeyframesView, _super);
function KeyframesView() {
_super.apply(this, arguments);
}
Object.defineProperty(KeyframesView.prototype, "android", {
get: function () {
return this._android;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyframesView.prototype, "_nativeView", {
get: function () {
return this._android;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyframesView.prototype, "source", {
set: function (value) {
this._source = value;
},
enumerable: true,
configurable: true
});
KeyframesView.prototype._createUI = function () {
this._android = new android.widget.ImageView(this._context);
if (!this._androidViewId) {
this._androidViewId = android.view.View.generateViewId();
}
this._android.setId(this._androidViewId);
var src = appPath + (this._source.indexOf("/") === 0 ? "" : "/") + this._source;
if (!fs.File.exists(src)) {
console.log("Keyframe source not found at " + src + "; showing an empty image");
return;
}
var fis = new java.io.FileInputStream(src);
var kfImage = com.facebook.keyframes.deserializers.KFImageDeserializer.deserialize(fis);
var kfDrawable = new com.facebook.keyframes.KeyframesDrawableBuilder()
.withImage(kfImage)
.build();
kfDrawable.startAnimation();
this._android.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
this._android.setImageDrawable(kfDrawable);
};
return KeyframesView;
}(image_1.Image));
exports.KeyframesView = KeyframesView;
//# sourceMappingURL=keyframes.android.js.map