Giter Club home page Giter Club logo

nativescript-fresco's Introduction

NativeScript Fresco

A NativeScript Plugin for Android apps.


This plugin is deprecated. Feel free to use the Image Plugin for efficiently displaying images on Android and iOS in your NativeScript app. If you already have an app that use the Fresco Plugin, read the migrate-to-image doc for initial guidance.


What is nativescript-fresco?

nativescript-fresco is a NativeScript plugin that exposes the Fresco library used for efficiently displaying images on Android. More information about what Fresco is and how it works is available on its official website here.

The nativescript-fresco plugin enables NativeScript developers to use the FrescoDrawee class which is extends the traditional Android ImageView component and adds the smart Fresco image management algorithms. The plugin exposes the drawee as a NativeScript view so you basically put it in the XML definition of your page and provide the URI to the image you would like to use.

How to use nativescript-fresco?

In vanila NativeScript

From npm

  1. Go to the root folder of your {N} application where you would like to install the plugin and type tns plugin add nativescript-fresco.
  2. Initialize nativescript-fresco in the launch event of your {N} application by using the following code:

From local repo?

  1. Clone the repository and go to the root directory on your computer.
  2. Use tsc to transpile the .ts sources: tsc -p.
  3. Go to the root folder of your {N} application where you would like to install the plugin and type tns plugin add <path-to-fresco-repo-dir>.
  4. Initialize nativescript-fresco in the launch event of your {N} application by using the following code:

JavaScript:

var application = require("application");
var fresco = require("nativescript-fresco");

if (application.android) {
    application.on("launch", function () {
        fresco.initialize();
    });
}

TypeScript:

import application = require("application");
import fresco = require("nativescript-fresco");

if (application.android) {
    application.on("launch", () => {
        fresco.initialize();
    });
}

When working with "downsampling" you will need to pass a configuration to the initialize function:

fresco.initialize({ isDownsampleEnabled: true });

Use fresco in the XML definition of the page as follows:

<Page
    xmlns="http://www.nativescript.org/tns.xsd" 
    xmlns:nativescript-fresco="nativescript-fresco">
    <nativescript-fresco:FrescoDrawee width="250" height="250"
                                      imageUri="<uri-to-a-photo-from-the-web-or-a-local-resource>"/>
</Page>

In NativeScript + Angular 2

  1. Import the TNSFrescoModule from nativescript-fresco/angular and add it to the imports of your initial @NgModule, like shown here.
  2. As described above make sure to initialize the nativescript-fresco plugin in the launch event of your {N} application.

Examples

You can refer the demo-angular folder of the repo for runnable {N} project that demonstrates the nativescript-fresco plugin with all of its features in action.

Migrating from 3.x.x to 4.x.x

  • If you are using the AnimatedImage class you can continue to cast to this type just note that it is now an interface rather than a class
  • If you are using the IAnimatedImage interface simply change all of your references to be AnimatedImage
  • If you are using the IImageInfo interface simply change all of your references to be ImageInfo
  • If you are using the IError interface simply change all of your references to be FrescoError

Features

Native Fresco library typings

If you find yourself in the need to access directly the native library of the nativescript-fresco plugin you can import the android.d.ts from the plugin in your references.d.ts:

/// <reference path="./node_modules/nativescript-fresco/android.d.ts" />

As documented by the Fresco library setting the height and width are mandatory, more details on this topic could be found here. So the first this you should do when declaring the FrescoDrawee is set its width and height attributes or set only one of them and set the FrescoDrawee's aspectRatio. The width and height of the FrescoDrawee in your {N} application supports percentages which makes it possible to declare for example width="50%" and aspectRatio="1.33" achieving exactly 50% width with dynamically calculated height based on the aspect ration of the loaded image from the imageUri.

Basic attributes

  • imageUri

String value used for the image URI. You can use this property to set the image to be loaded from remote location (http, https), from the resources and local files of your {N} application.

<nativescript-fresco:FrescoDrawee imageUri="https://docs.nativescript.org/angular/img/cli-getting-started/angular/chapter0/NativeScript_logo.png"/>
  • placeholderImageUri

String value used for the placeholder image URI. You can use this property to set a placeholder image loaded from the local and resources files of your {N} application.

*Note: Currently there are limitations on how many different Images can be set to as 'placeholderImage' before OutOfMemoryError is thrown. For best results its recommended to use a single image for all placeholderImageUri of your FrescoDrawee instances.

<nativescript-fresco:FrescoDrawee placeholderImageUri="~/placeholder.jpg"/>
  • failureImageUri

String value used for the failure image URI. You can use this property to set a failure image loaded from the local and resources files of your {N} application that will be shown if the loading of the imageUri is not successful.

<nativescript-fresco:FrescoDrawee failureImageUri="~/failure.jpg"/>

Advanced optional attributes

There are a couple of optional attributes that could be set on the FrescoDrawee instance to achieve advanced behaviors:

  • backgroundUri

String value used for the background image URI. Using this property has similar effect as the placeholderImageUri but the image is stretched to the size of the FrescoDrawee.

*Note: Currently there are limitations on how many different Images can be set to as 'background' before OutOfMemoryError is thrown. For best results its recommended to use a single image for all backgroundUri of your FrescoDrawee instances.

<nativescript-fresco:FrescoDrawee backgroundUri="~/image.jpg"/>
  • actualImageScaleType

String value used by FrescoDrawee image scale type. This property can be set to:

'center' - Performs no scaling.

'centerCrop' - Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.

'centerInside' - Scales the child so that it fits entirely inside the parent.

'fitCenter' - Scales the child so that it fits entirely inside the parent.

'fitStart' - Scales the child so that it fits entirely inside the parent.

'fitEnd' - Scales the child so that it fits entirely inside the parent.

'fitXY' - Scales width and height independently, so that the child matches the parent exactly.

'focusCrop' - Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.

<nativescript-fresco:FrescoDrawee actualImageScaleType="centerInside"/>
  • fadeDuration

Number value used for the fade-in duration. This value is in milliseconds.

<nativescript-fresco:FrescoDrawee fadeDuration="3000"/>
  • blurRadius

Number value greater than zero, used as input for the blur function. Larger value means slower processing. For example a value of 10 means that each pixel in the image will be blurred using all adjacent pixels up to a distance of 10.

<nativescript-fresco:FrescoDrawee blurRadius="25"/>
  • blurDownSampling

Number value greater than zero, used to scale the image before applying the blur function. Larger value means faster processing. For example a value of 2 means that the image will be scaled by a factor of two before applying blur.

<nativescript-fresco:FrescoDrawee blurDownSampling="2"/>
  • aspectRatio

Number value used as the aspect ratio of the image. This property is useful when you are working with different aspect ratio images and want to have a fixed Width or Height. The ratio of an image is calculated by dividing its width by its height.

Note: In some layout scenarios it is necessary to set the verticalAlignment of the FrescoDrawee to 'top' or 'bottom' in order to "anchor" the drawee and achieve dynamic sizing.

<nativescript-fresco:FrescoDrawee aspectRatio="1.33" verticalAlignment="top"/>
  • decodeWidth (downsampling) - make sure to enable downsample (isDownsampleEnabled) in the initialize function of the plugin otherwise this property is disregarded.

Number value used as the downsampled width of the fresco drawable.

<nativescript-fresco:FrescoDrawee decodeWidth="100"/>
  • decodeHeight (downsampling) - make sure to enable downsample (isDownsampleEnabled) in the initialize function of the plugin otherwise this property is disregarded.

Number value used as the downsampled width of the fresco drawable.

<nativescript-fresco:FrescoDrawee decodeHeight="100"/>
  • progressiveRenderingEnabled

Boolean value used for enabling or disabling the streaming of progressive JPEG images. This property is set to 'false' by default. Setting this property to 'true' while loading JPEG images not encoded in progressive format will lead to a standard loading of those images.

<nativescript-fresco:FrescoDrawee progressiveRenderingEnabled="true"/>
  • showProgressBar

Boolean value used for showing or hiding the progress bar.

<nativescript-fresco:FrescoDrawee showProgressBar="true"/>
  • progressBarColor

String value used for setting the color of the progress bar. You can set it to hex values ("#FF0000") and/or predefined colors ("green").

<nativescript-fresco:FrescoDrawee progressBarColor="blue"/>
  • roundAsCircle

Boolean value used for determining if the image will be rounded as a circle. Its default value is false. If set to true the image will be rounder to a circle.

<nativescript-fresco:FrescoDrawee roundAsCircle="true"/>
  • roundedCornerRadius

Number value used as radius for rounding the image's corners.

<nativescript-fresco:FrescoDrawee roundedCornerRadius="50"/>
  • roundBottomRight

Boolean value used for determining if the image's bottom right corner will be rounded. The roundedCornerRadius is used as the rounding radius.

<nativescript-fresco:FrescoDrawee roundBottomRight="true"/>
  • roundBottomLeft

Boolean value used for determining if the image's bottom left corner will be rounded. The roundedCornerRadius is used as the rounding radius.

<nativescript-fresco:FrescoDrawee roundBottomLeft="true"/>
  • roundTopLeft

Boolean value used for determining if the image's top left corner will be rounded. The roundedCornerRadius is used as the rounding radius.

<nativescript-fresco:FrescoDrawee roundTopLeft="true"/>
  • roundTopRight

Boolean value used for determining if the image's top right corner should be rounded. The roundedCornerRadius is used as the rounding radius.

<nativescript-fresco:FrescoDrawee roundTopRight="true"/>
  • autoPlayAnimations

Boolean value used for enabling the automatic playing of animated images. Note that rounding of such images is not supported and will be ignored.

<nativescript-fresco:FrescoDrawee autoPlayAnimations="true"/>
  • tapToRetryEnabled

Boolean value used for enabling/disabling a tap to retry action for the download of the FrescoDrawee image.

<nativescript-fresco:FrescoDrawee tapToRetryEnabled="true"/>

Events

  • finalImageSet - arguments FinalEventData

This event is fired after the final image has been set. When working with animated images you could use this event to start the animation by calling the FinalEventData.animatable.start() function.

<nativescript-fresco:FrescoDrawee finalImageSet="onFinalImageSet"/>

JavaScript:

function onFinalImageSet(args) {
    var frescoEventData = args;
    var drawee = frescoEventData.object;
}
exports.onFinalImageSet = onFinalImageSet;

TypeScript:

import {FrescoDrawee, FinalEventData } from "nativescript-fresco";

export function onFinalImageSet(args: FinalEventData) {
    var drawee = args.object as FrescoDrawee;
}
  • failure - arguments FailureEventData

This event is fired after the fetch of the final image failed.

<nativescript-fresco:FrescoDrawee failure="onFailure"/>

JavaScript:

function onFailure(args) {
    var drawee = args.object;
}
exports.onFailure = onFailure;

TypeScript:

import {FrescoDrawee, FailureEventData } from "nativescript-fresco";

export function onFailure(args: FailureEventData) {
    var drawee = args.object as FrescoDrawee;
}
  • intermediateImageSet - arguments IntermediateEventData

This event is fired after any intermediate image has been set.

<nativescript-fresco:FrescoDrawee intermediateImageSet="onIntermediateImageSet"/>

JavaScript:

function onIntermediateImageSet(args) {
    var drawee = args.object;
}
exports.onIntermediateImageSet = onIntermediateImageSet;

TypeScript:

import {FrescoDrawee, IntermediateEventData } from "nativescript-fresco";

export function onIntermediateImageSet(args: IntermediateEventData) {
    var drawee = args.object as FrescoDrawee;
}
  • intermediateImageFailed - arguments FailureEventData

This event is fired after the fetch of the intermediate image failed.

<nativescript-fresco:FrescoDrawee intermediateImageFailed="onIntermediateImageFailed"/>

JavaScript:

function intermediateImageFailed(args) {
    var drawee = args.object;
}
exports.intermediateImageFailed = intermediateImageFailed;

TypeScript:

import {FrescoDrawee, FailureEventData } from "nativescript-fresco";

export function intermediateImageFailed(args: FailureEventData) {
    var drawee = args.object as FrescoDrawee;
}
  • submit - arguments EventData

This event is fired before the image request is submitted.

<nativescript-fresco:FrescoDrawee submit="onSubmit"/>

JavaScript:

function onSubmit(args) {
    var drawee = args.object;
}
exports.onSubmit = onSubmit;

TypeScript:

import {FrescoDrawee, EventData } from "nativescript-fresco";

export function onSubmit(args: EventData) {
    var drawee = args.object as FrescoDrawee;
}
  • release - arguments EventData

This event is fired after the controller released the fetched image.

<nativescript-fresco:FrescoDrawee release="onRelease"/>

JavaScript:

function onRelease(args) {
    var drawee = args.object;
}
exports.onRelease = onRelease;

TypeScript:

import {FrescoDrawee, EventData } from "nativescript-fresco";

export function onRelease(args: EventData) {
    var drawee = args.object as FrescoDrawee;
}

Event arguments

All events exposed by 'nativescript-fresco' provide additional information to their handlers that is needed to properly handle them. Here's a brief description of the event arguments coming with each of the events:

  • FinalEventData

Instances of this class are provided to the handlers of the finalImageSet.

import {FrescoDrawee, FinalEventData, ImageInfo, AnimatedImage } from "nativescript-fresco";

export function onFinalImageSet(args: FinalEventData) {
    var info: ImageInfo  = args.imageInfo;
    var animatable: AnimatedImage = args.animatable;
    var quality: number = info.getQualityInfo().getQuality();
    var isFullQuality: boolean = info.getQualityInfo().isOfFullQuality();
    var isOfGoodEnoughQuality: boolean = info.getQualityInfo().isOfGoodEnoughQuality();
}
  • FailureEventData

Instances of this class are provided to the handlers of the failure and intermediateImageFailed.

import {FrescoDrawee, FailureEventData, FrescoError } from "nativescript-fresco";

export function onFailure(args: FailureEventData) {
    var error: FrescoError = args.error;
    var message: string = error.getMessage();
    var type: string = error.getErrorType();
    var fullError: string = error.toString();
}
  • IntermediateEventData

Instances of this class are provided to the handlers of the intermediateImageSet.

import {FrescoDrawee, IntermediateEventData, ImageInfo } from "nativescript-fresco";

export function onIntermediateImageSet(args: IntermediateEventData) {
    var info: ImageInfo  = args.imageInfo;
    var quality: number = info.getQualityInfo().getQuality();
    var isFullQuality: boolean = info.getQualityInfo().isOfFullQuality();
    var isOfGoodEnoughQuality: boolean = info.getQualityInfo().isOfGoodEnoughQuality();}
  • EventData

Instances of this class are provided to the handlers of the release and submit.

import {FrescoDrawee, EventData } from "nativescript-fresco";

export function onSubmit(args: EventData) {
    var drawee = args.object as FrescoDrawee;
}

Cache

The nativescript-fresco {N} plugin has built-in cache mechanism which handles managing the images in the memory. There are two types of cache mechanisms memory and disk, you can manually manage both of them with the following functionality.

'Refresh' the 'imageUri'

Not so rarely you may have a scenario where the actual image on your remote service from the imageUri of the FrescoDrawee has changed but the {N} app already has an image in its internal cache. In such scenario you can easily 'refresh' the imageUri by calling the updateImageUri():

// 'drawee' is the instance the 'FrescoDrawee' in the project.
drawee.updateImageUri();

Clear everything from the cache

Managing the caches in nativescript-fresco is done via the ImagePipeline. In order to get the reference of the ImagePipeline simply call the getImagePipeline() function:

var frescoModel = require("nativescript-fresco");

var imagePipeLine = frescoModel.getImagePipeline();
  • Clear both the memory and disk caches
imagePipeLine.clearCaches();
  • Clear the memory cache
imagePipeLine.clearMemoryCaches();
  • Clear the disk cache
imagePipeLine.clearDiskCaches();

Evict all images with a specific URI from the cache

If clearing the entire cache is not what you desired, you can clear only the images linked with a specific URI (imageUri). Evicting is done again via the ImagePipeline:

var frescoModel = require("nativescript-fresco");

var imagePipeLine = frescoModel.getImagePipeline();
  • Evict URI from both the memory and disk caches
imagePipeLine.evictFromCache("<uri-to-a-photo-from-the-web>");
  • Evict URI from the memory cache
imagePipeLine.evictFromMemoryCache("<uri-to-a-photo-from-the-web>");
  • Evict URI from the disk cache
imagePipeLine.evictFromDiskCache("<uri-to-a-photo-from-the-web>");

Manually shut down the native Fresco library

In very very rare occasions the native Android Fresco library may experience strange memory leak issues, in such scenarios as a last resort you may want to "shut down" the library forcing all of the managed memory to possibly be released. You can do that by calling the shutDown function exposed by the nativescript-fresco module, one good application lifecycle event to call it inside may be in the exit event of the application:

import * as app from "application";
import * as frescoModule from "nativescript-fresco";

if (app.android) {
    app.on(app.exitEvent, (args) => {
        frescoModule.shutDown();
    });
}

Sample Screenshots

All of the images are sample images for showcasing purposes.

Sample 1 - Placeholder image Sample 2 - Transition (fade-in animation)
Placeholder image sample Transition sample
Sample 3 - Image shown successfully from imageUri Sample 4 - 'Failure' image shown
Successfully shown image sample Successfully shown image sample

Contribute

We love PRs! Check out the contributing guidelines. If you want to contribute, but you are not sure where to start - look for issues labeled help wanted.

Get Help

Please, use github issues strictly for reporting bugs or requesting features. For general questions and support, check out Stack Overflow or ask our experts in NativeScript community Slack channel.

nativescript-fresco's People

Contributors

dimitartodorov avatar elena-p avatar etabakov avatar ignaciolarranaga avatar lini avatar mintyweazel avatar nsplugins avatar oluwaseye avatar sis0k0 avatar tbozhikov avatar tgpetrov avatar triniwiz avatar vladimiramiorkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-fresco's Issues

Loading multiple camera album photos fail

I am trying to load a listView which items have a thumbnail of a photo taken with the camera and stored in the device. The first image loads correctly, but all other photos fail to render and i get the "Pool hard cap violation?" error.
Before i tried the fresco plugin i was trying to get a smaller image with the following snippet:

let thumbImage = android.media.ThumbnailUtils.extractThumbnail(android.graphics.BitmapFactory.decodeFile(path), thumbsize, thumbsize);

It worked for 2 or 3 images before crashing with the "Out of Memory"* exception. But i had to load them to the Image compnent as with imageSource.setNativeSource(), since i created the bitmap manually, and i cannot set this with the FrescoDrawee component.

How to use gif images?

trying to show a gif but it only display the first frame.
I use the fresco library with react native and it works but with this one nothing...
<FrescoDrawee #drawee verticalAlignment="center" aspectRatio="2" imageUri="https://media2.giphy.com/media/3oKIPvQWkVBKRkPYJy/giphy.gif"></FrescoDrawee>

Thanks

Rounded corner radius doesn't work on Angular project

Round as circle work like a charm, but when I try to set the rounded corner radius, nothing happens. I've tryed to put the rounded style on css, but doesn't work too if I'm using the Fresco Drawee (works with Image).

Can't build the demo app

I wanted to see the demo app in action, but it doesn't build. Might be something missing on my end here. I have no problem building Telerik's NS UI app or my own stuff. I don't use Angular though, but I would expect the demo app to install dependencies.

mini:Projects sergei$ git clone https://github.com/NativeScript/nativescript-fresco.git
Cloning into 'nativescript-fresco'...
remote: Counting objects: 794, done.
remote: Total 794 (delta 0), reused 0 (delta 0), pack-reused 794
Receiving objects: 100% (794/794), 4.15 MiB | 4.00 MiB/s, done.
Resolving deltas: 100% (427/427), done.
mini:Projects sergei$ cd nativescript-fresco/demo/
mini:demo sergei$ tns run android
npm WARN prepublish-on-install As of npm@5, prepublish scripts will run only for npm publish.
npm WARN prepublish-on-install (In npm@4 and previous versions, it also runs for npm install.)
npm WARN prepublish-on-install See the deprecation note in npm help scripts for more information.

[email protected] prepublish /Users/sergei/Projects/nativescript-fresco
npm run ngc

[email protected] ngc /Users/sergei/Projects/nativescript-fresco
ngc

sh: ngc: command not found

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node@6/6.10.3/bin/node" "/usr/local/bin/npm" "run" "ngc"
npm ERR! node v6.10.3
npm ERR! npm v4.2.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] ngc: ngc
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] ngc script 'ngc'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the nativescript-fresco package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ngc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs nativescript-fresco
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls nativescript-fresco
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR! /Users/sergei/.npm/_logs/2017-06-03T21_26_54_620Z-debug.log
npm ERR! addLocal Could not install /Users/sergei/Projects/nativescript-fresco
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node@6/6.10.3/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.10.3
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! [email protected] prepublish: npm run ngc
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prepublish script 'npm run ngc'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the nativescript-fresco package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run ngc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs nativescript-fresco
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls nativescript-fresco
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/sergei/.npm/_logs/2017-06-03T21_26_59_527Z-debug.log
Unable to install dependencies. Make sure your package.json is valid and all dependencies are correct. Error is: Command npm failed with exit code 1
mini:demo sergei$

Question: Can the plugin support ImageSource from nativescript?

Will fresco cache the same image and only load once? For example, if I have listivew that has repeater fresco image with same link or resource image, will fresco load only once? One good example is the placeholderImageUri or failureImageUri.

If fresco not cache same image url, might be it makes sense to have the plugin to support ImageSource.
Is it possible for the plugin supporting ImageSource currently?

App crashes on initilization

I've inserted the following lines in my

app.js

var fresco = require("nativescript-fresco");

if(application.android){
application.onLaunch = function(intent){
fresco.initialize();}
}

However , as soon as I start the app I get the following stacktrace:

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 
Fail to load module: /data/data/org.nativescript.haloose/files/app/app.js

TypeError: Cannot read property 'AnimatedDrawable' of undefined
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'', file:'/data/data/org.nativescript.haloose/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 35, column: 43
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'/data/data/org.nativescript.haloose/files/app/app.js', line: 4, column: 14
    Frame: function:'require', file:'', line: 1, column: 266

This is very weird because it was working before. After a reinstall of the app however, I got the error above.
What is causing this?

Fresco for background images?

Hi, I was wondering if I need to use Fresco for full screen background images on the app.
I converted all my other images to the fresco tag and I'm still getting memory crashes so I'm assuming maybe it has to do with the background images. How can I use fresco for this?

Currently I'm just using CSS like this..
Page {
background-color: #212121;
background-image: ~/images/background.jpg;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}

3.0.2 version breaks build, 1.0.16 works fine

When upgraded to 3.0.2:

Found peer TypeScript 2.1.6
node_modules/nativescript-fresco/index.d.ts(1,29): error TS2306: File 'D:/www/test/node_modules/tns-core-modules/ui/core/view.d.ts' is not a module.

NS: 2.5.3

package.json:

  "dependencies": {
    "@angular/common": "4.0.2",
    "@angular/compiler": "4.0.2",
    "@angular/core": "4.0.2",
    "@angular/forms": "4.0.2",
    "@angular/http": "4.0.2",
    "@angular/platform-browser": "4.0.2",
    "@angular/platform-browser-dynamic": "4.0.2",
    "@angular/router": "4.0.2",
    "nativescript-angular": "1.5.2",
    "nativescript-angular-snapshot": "1.5.2-5.5.372.32",
    "nativescript-camera": "0.0.8",
    "nativescript-fresco": "3.0.2",
    "nativescript-geolocation": "0.0.19",
    "nativescript-gif": "1.0.9",
    "nativescript-google-maps-sdk": "1.4.3",
    "nativescript-imagepicker": "^2.5.1",
    "nativescript-phone": "1.3.0",
    "nativescript-vibrate": "1.1.2",
    "nativescript-webview-interface": "^1.4.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.3.0",
    "tns-core-modules": "2.5.2"
  },

Memory leak when backgroundImage is set

EDIT: DELETED ORIGINAL ISSUE

In original issue I had stated that the issue is in getDrawableFromResource method, but probably I had messed up the things there and getDrawableFromResource is not creating any issue regarding memory leak.

The memory leak occurs only when we set backgroundUri to some image in file system like ~/images/placeholder-img.jpg. In this case for each FrescoDrawee instance where we have set backgroundUri to the mentioned path, it will create bitmap images for all that instances. Which I think is fine to handle the scenarios where we want to have different background images.

SOLUTION:
If we need to use same backgroundImage for all the FrescroDrawee, we need to put that image in App_Resources/Android/drawable-xxxx folder and set backgroundUri to the resourceName like res://placeholder_img. This way it will only create one bitmap and that will be shared across all the drawables for backgroundImage of FrescoDrawee.

Angular AoT + webpack support

From @ignaciolarranaga on January 12, 2017 12:16

I added the plugin to my app and the npm android start-android-bundle stared throwing this error:

ERROR in Unexpected value 'NSFRESCO_DIRECTIVES' declared by the module 'MainModule'

ERROR in ./main.aot.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in '/Users/ignacio/Workspaces/DuenoVende/hezea-app/app'
 @ ./main.aot.ts 2:0-60

ERROR in ../~/nativescript-angular/router/ns-module-factory-loader.js
Module not found: TypeError: Cannot convert undefined or null to object
 @ ../~/nativescript-angular/router/ns-module-factory-loader.js 23:15-40
 @ ../~/nativescript-angular/router.js
 @ ./vendor.ts

ERROR in ../~/nativescript-angular/router/ns-module-factory-loader.js
Module not found: TypeError: Cannot convert undefined or null to object
 @ ../~/nativescript-angular/router/ns-module-factory-loader.js 29:27-46
 @ ../~/nativescript-angular/router.js
 @ ./vendor.ts

I follow the instructions on the plugin to modify my app (that was actually starting correctly):

  • Import the NSFRESCO_DIRECTIVES from nativescript-fresco/angular and add it to the declarations of your initial @NgModule, like shown here.
  • As described above make sure to initialize the nativescript-fresco plugin in the launch event of your {N} application.

To reproduce may be the best is with the nativescript-alfresco demo app, but there are some additional issues with webpack to solve there.

Here is my code:

import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { Http } from "@angular/http";
import { TranslateModule, TranslateLoader, TranslateStaticLoader } from "ng2-translate";
import { NativeScriptModule } from "nativescript-angular/platform";
import { NativeScriptFormsModule } from "nativescript-angular/forms"
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { NativeScriptHttpModule } from "nativescript-angular/http";
import { NSFRESCO_DIRECTIVES } from 'nativescript-fresco/angular';

import { ActionBarModule } from "../../components";
import { PropertyComponent } from "./property/property.component";
import { MainPage } from "./main.component";

@NgModule({
    schemas: [ NO_ERRORS_SCHEMA ],
    imports: [
        NativeScriptModule,
        NativeScriptFormsModule,
        NativeScriptRouterModule,
        NativeScriptRouterModule.forChild([ { path: "", component: MainPage } ]),
        TranslateModule,

        ActionBarModule,
    ],
    declarations: [ NSFRESCO_DIRECTIVES, MainPage, PropertyComponent ]
})
export class MainModule {}

It is a lazy loaded module. The initialization of fresco is in the main component.

Copied from original issue: NativeScript/nativescript-dev-webpack#53

FrescoDrawee causing Image not to load on iOS

I am loading the FrescoDrawee inside the android tag and it works great, but when i try and run iOS the images don't show up and i get an undefined error.

<ios>
      <Image col="0" row="0" [src]='story.thumbnail | processThumbnail' stretch="aspectFill" loadMode="async" class="thumbnail" (doubleTap)="onDoubleTap()" ></Image>
</ios>
<android>            
     <FrescoDrawee [imageUri]='story.thumbnail' aspectRatio="1" width="100%" class="thumbnail"></FrescoDrawee>
</android>

CONSOLE ERROR file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:344:22: Error: Uncaught (in promise): Error: Error in pages/list/list.swipe.1.html:14:24 caused by: undefined is not a constructor (evaluating 'new viewClass()')

If I remove the FrescoDrawee tag from inside the android tag the iOS view loads fine with the image.

error in com.facebook.drawee

Hello i'm receiving this error

cannot read property 'drawee' of undefined

in this code

if (applicationModule.android) {
    applicationModule.onLaunch = function (intent) {
        com.facebook.drawee.backends.pipeline.Fresco.initialize(applicationModule.android.context);
    };
}

Applications that use this plugin has stopped on start

Hi,

I reproduce the problem on my application and the Fresco Sample.
On Android (tested on the android SDK simulator with a nexus 5 configuration).

When the application start
Then I see the following system error "Unfortunately, {N} Fresco sample has stopped"

TNS Info for Fresco Sample :

MacBook-Pro-de-Marc:frescoSample marcbuils$ tns info
All NativeScript components versions information
│ Component        │ Current version │ Latest version │ Information      │
│ nativescript     │ 2.2.1           │ 2.2.1          │ Up to date       │
│ tns-core-modules │ 2.2.0           │ 2.2.1          │ Update available │
│ tns-android      │ 2.2.0           │ 2.2.0          │ Up to date       │
│ tns-ios          │                 │ 2.2.1          │ Not installed    │

TNS info for a custom test app :

MacBook-Pro-de-Marc:demo marcbuils$ tns info
All NativeScript components versions information
│ Component        │ Current version │ Latest version │ Information   │
│ nativescript     │ 2.2.1           │ 2.2.1          │ Up to date    │
│ tns-core-modules │ 2.2.1           │ 2.2.1          │ Up to date    │
│ tns-android      │ 2.2.0           │ 2.2.0          │ Up to date    │
│ tns-ios          │                 │ 2.2.1          │ Not installed │

Best Regards,
Marc

imageUrl can't use image from local

I am using v1.0.7 (not 1.0.8 as 1.0.8 required addition angular module which I am not using angular, Can you make angular as optional or separate version).

The local image works on ie placeholderImageUrl but NOT imageUrl.

WORK:

    <fresco:FrescoDrawee width="250" height="250"
          placeholderImageUri="~/images/noone.jpg"/>

NOT WORK

    <fresco:FrescoDrawee width="250" height="250"
         imageUri="~/images/noone.jpg"/>

TypeError: Cannot read property 'AnimatedDrawable' of undefined

VanillaJS nativescript project

app.js

var application = require("application");
application.start({ moduleName: "pages/home/home" });
var fresco = require("nativescript-fresco");
if (application.android) {
    application.onLaunch = function (intent) {
        fresco.initialize();
    };
}

home.xml

<page
  xmlns="http://schemas.nativescript.org/tns.xsd"
  xmlns:drawer="nativescript-telerik-ui/sidedrawer"
  xmlns:widgets="shared/widgets"
  xmlns:statusbar="nativescript-statusbar"
   xmlns="http://www.nativescript.org/tns.xsd"
   xmlns:nativescript-fresco="nativescript-fresco"
  loaded="pageLoaded">

<nativescript-fresco:FrescoDrawee row="0" height="160" imageUri="http://demo.megathe.me/pear/wp-content/uploads/2017/03/person24.jpg" />

Need some help. Here's the Exception from the plugin

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 

Error calling module function 

Error calling module function 

TypeError: Cannot read property 'AnimatedDrawable' of undefined
File: "file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js, line: 92, column: 42

StackTrace: 
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 92, column: 43
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/app.js', line: 2, column: 14
	Frame: function:'require', file:'', line: 1, column: 266


TypeError: Cannot read property 'AnimatedDrawable' of undefined
File: "<unknown>, line: 1, column: 265

StackTrace: 
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 92, column: 43
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/app.js', line: 2, column: 14
	Frame: function:'require', file:'', line: 1, column: 266


TypeError: Cannot read property 'AnimatedDrawable' of undefined
File: "<unknown>, line: 1, column: 265

StackTrace: 
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 92, column: 43
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/app.js', line: 2, column: 14
	Frame: function:'require', file:'', line: 1, column: 266


	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5364)
	at android.app.ActivityThread.-wrap2(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6077)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: com.tns.NativeScriptException: 

Error calling module function 

Error calling module function 

TypeError: Cannot read property 'AnimatedDrawable' of undefined
File: "file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js, line: 92, column: 42

StackTrace: 
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 92, column: 43
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/app.js', line: 2, column: 14
	Frame: function:'require', file:'', line: 1, column: 266


TypeError: Cannot read property 'AnimatedDrawable' of undefined
File: "<unknown>, line: 1, column: 265

StackTrace: 
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 92, column: 43
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/app.js', line: 2, column: 14
	Frame: function:'require', file:'', line: 1, column: 266


TypeError: Cannot read property 'AnimatedDrawable' of undefined
File: "<unknown>, line: 1, column: 265

StackTrace: 
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 92, column: 43
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'file:///data/data/org.nativescript.MyApp/files/app/app.js', line: 2, column: 14
	Frame: function:'require', file:'', line: 1, column: 266


	at com.tns.Runtime.runModule(Native Method)
	at com.tns.Runtime.runModule(Runtime.java:521)
	at com.tns.Runtime.run(Runtime.java:513)
	at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361)
	... 8 more

Question about best practice for IOS

Hi! Thank you for this amazing plug in.
It's solves so many issues for my app.

I was wondering what other developers use when developing for IOS.
I mean, I now have these tags for all the images for android. But what do you do when you are ready to develop for IOS? Do I need to have *ngIF statements on all of them for android and use default Image tags for IOS? What are other developers doing to replace Fresco?

Could not resolve com.facebook.fresco:fresco:0.9.0+.

Could not resolve all dependencies for configuration ':_F0F1F2F3F4F5DebugApkCopy'.

Could not resolve com.facebook.fresco:fresco:0.9.0+.
Required by:
project :
> Could not resolve com.facebook.fresco:fresco:0.9.0+.
> Failed to list versions for com.facebook.fresco:fresco.
> Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/fresco/fresco/maven-metadata.xml.
> Could not GET 'https://jcenter.bintray.com/com/facebook/fresco/fresco/maven-metadata.xml'. Received status code 403 from server: Forbidden

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    Command ./gradlew failed with exit code 1

Got this issue while running in Nativescript application for android.
For iOS it's working fine.
Even when I tried creating a new project and add this plugin getting same issue.

Will be really helpful if somebody can help on this.

TypeError: Cannot read property 'imagepipeline' of undefined

tns plugin add nativescript-fresco on sample-gorceries,
webpaking... ok,
npm run start-android-bundle, the app crash on init :

package.json

{
  "name": "Groceries",
  "version": "1.0.0",
  "description": "A NativeScript-built iOS and Android app for managing grocery lists",
  "repository": {
    "type": "git",
    "url": "https://github.com/nativescript/sample-Groceries.git"
  },
  "keywords": [
    "NativeScript"
  ],
  "author": "TJ VanToll <[email protected]> (https://www.tjvantoll.com/)",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/nativescript/sample-Groceries/issues"
  },
  "homepage": "https://github.com/nativescript/sample-Groceries/groceries",
  "nativescript": {
    "id": "org.nativescript.groceries",
    "tns-android": {
      "version": "3.1.1"
    },
    "tns-ios": {
      "version": "3.1.0"
    }
  },
  "scripts": {
    "tslint": "tslint -p tsconfig.json",
    "ns-bundle": "ns-bundle",
    "publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
    "generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
    "start-android-bundle": "npm run ns-bundle --android --run-app",
    "start-ios-bundle": "npm run ns-bundle --ios --run-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  },
  "dependencies": {
    "@angular/common": "~4.1.3",
    "@angular/compiler": "~4.1.3",
    "@angular/core": "~4.1.3",
    "@angular/forms": "~4.1.3",
    "@angular/http": "~4.1.3",
    "@angular/platform-browser": "~4.1.3",
    "@angular/router": "~4.1.3",
    "email-validator": "^1.0.7",
    "nativescript-angular": "next",
    "nativescript-fresco": "^3.0.4",
    "nativescript-iqkeyboardmanager": "1.0.1",
    "nativescript-social-share": "~1.3.2",
    "nativescript-unit-test-runner": "^0.3.3",
    "reflect-metadata": "^0.1.8",
    "rxjs": "^5.4.0",
    "tns-core-modules": "next",
    "zone.js": "^0.8.11"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~4.1.3",
    "@ngtools/webpack": "~1.4.0",
    "babel-traverse": "6.24.1",
    "babel-types": "6.24.1",
    "babylon": "6.17.0",
    "codelyzer": "^3.0.1",
    "copy-webpack-plugin": "~4.0.1",
    "extract-text-webpack-plugin": "~2.1.0",
    "filewalker": "^0.1.3",
    "jasmine-core": "^2.6.2",
    "karma": "^1.7.0",
    "karma-jasmine": "^1.0.2",
    "karma-nativescript-launcher": "^0.4.0",
    "lazy": "1.0.11",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-dev-typescript": "^0.4.5",
    "nativescript-dev-webpack": "next",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.0.2",
    "tslint": "^5.4.2",
    "typescript": "~2.3.4",
    "webpack": "~2.6.1",
    "webpack-bundle-analyzer": "^2.8.2",
    "webpack-sources": "~1.0.1"
  }
}
app.module.ts

import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptHttpModule } from "nativescript-angular/http";
import { NativeScriptRouterModule } from "nativescript-angular/router";

import { authProviders, appRoutes } from "./app.routing";
import { AppComponent } from "./app.component";
import { setStatusBarColors, BackendService, LoginService } from "./shared";

import { LoginModule } from "./login/login.module";
import { GroceriesModule } from "./groceries/groceries.module";


import { TNSFrescoModule } from "nativescript-fresco/angular";

import * as frescoModule from "nativescript-fresco";
import * as applicationModule from "application";


applicationModule.on("launch", () => {
  if (applicationModule.android) {
    frescoModule.initialize();
  }
});


setStatusBarColors();

@NgModule({
  providers: [
    BackendService,
    LoginService,
    authProviders
  ],
  imports: [
    NativeScriptModule,
    NativeScriptHttpModule,
    NativeScriptRouterModule,
    NativeScriptRouterModule.forRoot(appRoutes),
    LoginModule,
    GroceriesModule,
    TNSFrescoModule
  ],
  declarations: [
      AppComponent,
  ],
  bootstrap: [AppComponent],
  schemas: [NO_ERRORS_SCHEMA]
})
export class AppModule { }



application.onExit, unable to destroy activity failed?

Hi Team,
Great work was done. application.onLaunch initialized fresco library. it is facing below issue when application.onExit / backNavigation to exit . Unable to destroy activity and it was crashed immediately.

Nativescript 3.0 failed to find module ui/core/proxy

hi there,

I'm in the process of upgrading my app to Nativescript 3.0 rc and run into this issue. It seems the ui/core/proxy module has been removed and nativescript-fresco is using it. Any plans to update the module to make it compatible with Nativescript 3.0?

Thank you very much in advanced.

Enable acquiring base64 from an image

I didn't see this anywhere in code. I wish to send an image to server and I am going to use base64 format. Nativescripts' imageSource object has a method toBase64String. Currently, there are still image memory leaks the moment I initialise an imageSource object to get base64 data.
Since fresco cleans after itself I thought I would get base64 from fresco object, but there is no such functionality.

onHiddenChanged failed

When I am navigating back to a page that contains a listview with fresco handling images I get this error.

com.tns.NativeScriptException: 
Calling js method onHiddenChanged failed

TypeError: Cannot read property 'setImageURI' of undefined
File: "/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/nativescript-fresco/fresco/fresco.js, line: 19, column: 21

StackTrace: 
Frame: function:'FrescoDrawee._clearAndroidReference', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/nativescript-fresco/fresco/fresco.js', line: 19, column: 22
Frame: function:'View._onDetached', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 191, column: 14
Frame: function:'eachChild', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 185, column: 23
Frame: function:'LayoutBase._eachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/layouts/layout-base.js', line: 139, column: 22
Frame: function:'View._onDetached', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 188, column: 18
Frame: function:'eachChild', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 185, column: 23
Frame: function:'LayoutBase._eachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/layouts/layout-base.js', line: 139, column: 22
Frame: function:'View._onDetached', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 188, column: 18
Frame: function:'View._removeViewCore', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 150, column: 14
Frame: function:'View._removeView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 948, column: 14
Frame: function:'LayoutBase.removeChild', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/layouts/layout-base.js', line: 52, column: 14
Frame: function:'LayoutBase.removeChildren', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/layouts/layout-base.js', line: 59, column: 18
Frame: function:'Repeater.refresh', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/repeater/repeater.js', line: 96, column: 30
Frame: function:'Repeater.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/repeater/repeater.js', line: 82, column: 18
Frame: function:'eachChild', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 606, column: 23
Frame: function:'LayoutBase._eachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/layouts/layout-base.js', line: 139, column: 22
Frame: function:'View._loadEachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 18
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 599, column: 14
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 102, column: 35
Frame: function:'eachChild', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 606, column: 23
Frame: function:'LayoutBase._eachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/layouts/layout-base.js', line: 139, column: 22
Frame: function:'View._loadEachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 18
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 599, column: 14
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 102, column: 35
Frame: function:'eachChild', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 606, column: 23
Frame: function:'ContentView._eachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/content-view/content-view.js', line: 65, column: 13
Frame: function:'View._loadEachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 18
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 599, column: 14
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 102, column: 35
Frame: function:'ScrollView.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/scroll-view/scroll-view-common.js', line: 40, column: 35
Frame: function:'eachChild', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 606, column: 23
Frame: function:'TabView._eachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/tab-view/tab-view-common.js', line: 237, column: 26
Frame: function:'View._loadEachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 18
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 599, column: 14
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 102, column: 35
Frame: function:'eachChild', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 606, column: 23
Frame: function:'ContentView._eachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/content-view/content-view.js', line: 65, column: 13
Frame: function:'Page._eachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/page/page-common.js', line: 246, column: 41
Frame: function:'View._loadEachChildView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 18
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 599, column: 14
Frame: function:'View.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 102, column: 35
Frame: function:'Page.onLoaded', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/page/page-common.js', line: 44, column: 35
Frame: function:'View._addViewCore', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 924, column: 18
Frame: function:'View._addViewCore', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view.js', line: 146, column: 39
Frame: function:'View._addView', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/core/view-common.js', line: 912, column: 14
Frame: function:'onFragmentShown', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/frame/frame.js', line: 124, column: 11
Frame: function:'android.app.Fragment.extend.onHiddenChanged', file:'/data/data/com.smarpsocial.smarpshare/files/app/tns_modules/ui/frame/frame.js', line: 71, column: 17

at com.tns.Platform.callJSMethodNative(Native Method)
at com.tns.Platform.dispatchCallJSMethodNative(Platform.java:812)
at com.tns.Platform.callJSMethod(Platform.java:711)
at com.tns.Platform.callJSMethod(Platform.java:690)
at com.tns.Platform.callJSMethod(Platform.java:680)
at com.tns.gen.android.app.Fragment_ftns_modules_ui_frame_frame_l34_c42__.onHiddenChanged(android.app.Fragment.java)
at android.app.FragmentManagerImpl.showFragment(FragmentManager.java:1308)
at android.app.BackStackRecord.popFromBackStack(BackStackRecord.java:1636)
at android.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1639)
at android.app.FragmentManagerImpl$3.run(FragmentManager.java:585)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

[Question] Not displaying the image

Hi,
I am using this plugin to resolve the memory issues but the images are not displaying.
Here is my code.

XML :

<android>
       <nativescript-fresco:FrescoDrawee imageUri="{{ filePath }}" width="{{ itemWidth }}" failureImageUri="res://layer19" placeholderImageUri="res://dress"/>
</android>

sample filePath looks like : https://dummy-url/123456/0.jpg

if (application.android) {
    application.on("launch", function () {
        fresco.initialize();
    });
}

Package.json :

{
	"description": "NativeScript Application",
	"license": "SEE LICENSE IN <your-license-filename>",
	"readme": "NativeScript Application",
	"repository": "<fill-your-repository-here>",
	"nativescript": {
		"tns-ios": {
			"version": "3.4.0"
		},
		"tns-android": {
			"version": "3.2.0"
		}
	},
	"dependencies": {
                     .... 
                     .... 
		"nativescript-fresco": "^3.0.6"
                     .... 
                     .... 
	}

P.S: I am including namespace in XML and the variables are initializing properly. I am not getting any errors.
am I making any mistakes here?
Thanks.

Feature Request: Expose Ability to Clear Caches

The Fresco website talks about the ability to clear the library's cache, either for an individual URL, or just to clear the entire cache for all URLs at once: http://frescolib.org/docs/caching.html

I did a search through the nativescript-fresco code for "cache", however, and I don't see anywhere where that functionality is exposed. Could you please enlighten me if it's possible to do this under the current version? If not, I would like to request this as an enhancement request.

Here's my situation: I have a ListView component which is showing the user several images, but they also have the ability to click a button and take a photo with their camera which is uploaded to the server and then needs to replace one of the shown images. The trick is that the new photo will have the same URL as the old one, since the image name is based off of the ID of the item being shown. (eg. https://myserver.com/stuff/items/24.jpg)

Any help appreciated. Thanks!

Error after upgrading to NativeScript 2.5

nativescript-fresco worked great for me with NativeScript 2.4. But after I upgraded to NativeScript 2.5 I get this error when I try to build my application:

node_modules/nativescript-fresco/references.d.ts(1,1): error TS6053: File '/my-project-folder/node_modules/nativescript-fresco/node_modules/tns-core-modules/tns-core-modules.d.ts' not found.

Changing the first line in nativescript-fresco's references.d.ts from:

/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" />

to

/// <reference path="../tns-core-modules/tns-core-modules.d.ts" />

seems to fix the issue.

Question

Hello
First i wont to apologize for my wooden English skills.
I dont known what i doing wrong but radCalendar is not showing in my app
Here is my Code

<ActionBar title="Terminarz"></ActionBar> <FlexboxLayout flexDirection="column" class="page"> <StackLayout flexgrow="1"> <radCalendar id="calendar"></radCalendar> </StackLayout> <bottomMenu></bottomMenu> </FlexboxLayout>

`import { NgModule, NO_ERRORS_SCHEMA, NgModuleFactoryLoader } from '@angular/core';
import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
import { MenuService } from './services/MenuService';
import { AppRoutingModule } from './app.routing';
import { AppComponent } from './app.component';
import { CommonModule } from '@angular/common';
import { MainComponent } from './routers/main/main';
import { TerminarzComponent } from './routers/terminarz/terminarz';
import { CrmComponent } from './routers/crm/crm';
import { BottomMenu } from './components/BottomMenu/bottomMenu';
import { MenuItem } from './components/BottomMenu/MenuItem/MenuItem';
import { TNSFontIconModule } from 'nativescript-ngx-fonticon';
import { TestComponent } from './routers/test/test';
import { NativeScriptRouterModule, NSModuleFactoryLoader } from 'nativescript-angular/router';
import { NativeScriptUICalendarModule } from 'nativescript-pro-ui/calendar/angular';
import { NativeScriptUIListViewModule } from 'nativescript-pro-ui/listview/angular';
import { NativeScriptFormsModule } from 'nativescript-angular/forms';

import { NativeScriptHttpModule } from 'nativescript-angular/http';
import { TNSFrescoModule } from 'nativescript-fresco/angular';
import * as applicationModule from 'tns-core-modules/application';
import * as frescoModule from 'nativescript-fresco';

if (applicationModule.android) {
applicationModule.on('launch', () => {
frescoModule.initialize();
});
}

@NgModule({
bootstrap: [
AppComponent
],
imports: [
NativeScriptModule,
AppRoutingModule,
CommonModule,
NativeScriptHttpModule,
NativeScriptUIListViewModule,
NativeScriptFormsModule,
TNSFrescoModule,
NativeScriptRouterModule,
TNSFontIconModule.forRoot({
'fa': './fonts/font-awesome.css'
})
],
declarations: [
AppComponent,
MainComponent,
TerminarzComponent,
CrmComponent,
BottomMenu,
MenuItem,
TestComponent
],
providers: [
MenuService,
{ provide: NgModuleFactoryLoader, useClass: NSModuleFactoryLoader }
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class AppModule { }`
##################

i see only a empty space i dont recive any errors on console

Binding the path to imageUri not working.!!

Hi,
I am trying to display the images which are returned by the nativescript-imagepicker, so I am binding the path to imageUri like this
<ns-fresco:FrescoDrawee width="{{ itemWidth }}" imageUri="{{ filePath }}"/>
my filePath looks like this "/storage/emulated/0/DCIM/Camera/IMG_20171215.jpg"

What mistake I am doing here ??

Thanks.

Getting a Typescript error setting up with Angular

Hi!
I'm falling the example here:
https://github.com/NativeScript/nativescript-fresco/blob/master/demo/app/app.module.ts#L23

and then I'm getting an error

Left hand side of assignment expression cannot be a constant or a read only property

when I add this..

if (applicationModule.android) {
    applicationModule.onLaunch = function (intent) {
        frescoModule.initialize();
    };
}

I double checked to make sure I'm adding all the imports as shown...
What can be causing this?

[Question]: It's possible to cache web images?

I'm not sure if it's working for web images. On my app, I get a model that contains several images, for example:

{ "name": "John Doe", "gallery": [ // multiple urls ] ... }

But every time I open the application, the image loads again. If I load the application without connection, the images are not displayed. Is it something wrong that I'm doing or a possible issue of the plugin?

JS: ERROR Error: com.facebook.imagepipeline.request.ImageRequestBuilder$BuilderException

i started facing this issue lately the fresco loads the images just fine but i see this in my Terminal

JS: ERROR Error: com.facebook.imagepipeline.request.ImageRequestBuilder$BuilderException: Invalid request builder: Resource URI must not be empty
JS: com.facebook.imagepipeline.request.ImageRequestBuilder.validate(ImageRequestBuilder.java:277)
JS: com.facebook.imagepipeline.request.ImageRequestBuilder.build(ImageRequestBuilder.java:253)
JS: com.tns.Runtime.callJSMethodNative(Native Method)
JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
JS: com.tns.Runtime.callJSMethod(Runtime.java:957)
JS: com.tns.Runtime.callJSMethod(Runtime.java:941)
JS: com.tns.Runtime.callJSMethod(Runtime.java:933)
JS: com.tns.gen.com.telerik.widget.list.ListViewAdapter_frnal_ts_helpers_l58_c38__ListViewAdapter.onBindViewHolder(com.telerik.widget.list.ListViewAdapter.java)

i dont know how to get rid of it
any suggestions?

Images not loaded or loading too slow

Happens on on HTC one mini 2 - Android 4.4.2. Works well on Nexus 7 (Android 6.0.1)
See it in SDK Examples - ListView -> Item Layouts -> Linear/Grid
https://github.com/telerik/nativescript-ui-samples

"nativescript": {
        "id": "org.nativescript.sdk",
        "tns-android": {
            "version": "2.1.1"
        },
        "tns-ios": {
            "version": "2.1.0"
        }
    },
    "dependencies": {
        "nativescript-fresco": "^1.0.3",
        "nativescript-telerik-ui-pro": "1.2.0",
        "tns-core-modules": "2.1.0"
    },
    "devDependencies": {
        "babel-traverse": "6.9.0",
        "babel-types": "6.9.0",
        "babylon": "6.8.0",
        "filewalker": "0.1.2",
        "lazy": "1.0.11",
        "nativescript-dev-typescript": "^0.3.2",
        "typescript": "^1.8.10"
    }

Fresco package issue

See the image:
snip20161203_1

Any reason that's happening? I'm going through plugins to remove junk for release builds and stumbled on that today. I know it's not needed so I remove but just FYI it's happening and I didn't think it was right so curious if I'm missing something 😄

iOS support

Thank you for the awesome plugin. Any chance iOS support will be added any time soon?

Cannot read property 'imagepipeline' of undefined File: "<unknown>, line: 1, column: 265

Can't get the app startup.

Platform: Windows
>tns info
All NativeScript components versions information
┌──────────────────┬─────────────────┬────────────────┬───────────────┐
│ Component        │ Current version │ Latest version │ Information   │
│ nativescript     │ 2.1.0           │ 2.1.0          │ Up to date    │
│ tns-core-modules │ 2.1.0           │ 2.1.0          │ Up to date    │
│ tns-android      │ 2.1.1           │ 2.1.1          │ Up to date    │
│ tns-ios          │                 │ 2.1.0          │ Not installed │
└──────────────────┴─────────────────┴────────────────┴───────────────┘

Steps:

tns create demo-fresco
cd demo-fresco
tns platform add android
tns plugin add nativescript-fresco

After adding below and run /> tns livesync android --watch got below exception.

var application = require("application");
var fresco = require("nativescript-fresco");

if (application.android) {
    application.onLaunch = function (intent) {
        fresco.initialize();
    };
}

ERROR


--------- beginning of /dev/log/main
D/AndroidRuntime( 5636):
D/AndroidRuntime( 5636): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 5636): CheckJNI is OFF
D/dalvikvm( 5636): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 5636): Added shared lib libjavacore.so 0x0
D/dalvikvm( 5636): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 5636): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 5636): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 5636): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/cutils-trace( 5636): Error opening trace file: No such file or directory (2)
E/memtrack( 5636): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 5636): failed to load memtrack module: -2
D/AndroidRuntime( 5636): Calling main entry com.android.commands.pm.Pm
D/AndroidRuntime( 5636): Shutting down VM
D/dalvikvm( 5636): GC_CONCURRENT freed 241K, 31% free 558K/804K, paused 0ms+0ms, total 1ms
D/AndroidRuntime( 5655):
D/AndroidRuntime( 5655): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 5655): CheckJNI is OFF
D/dalvikvm( 5655): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 5655): Added shared lib libjavacore.so 0x0
D/dalvikvm( 5655): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 5655): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 5655): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
E/cutils-trace( 5655): Error opening trace file: No such file or directory (2)
D/dalvikvm( 5655): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 5655): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 5655): failed to load memtrack module: -2
D/AndroidRuntime( 5655): Calling main entry com.android.commands.am.Am
--------- beginning of /dev/log/system
I/ActivityManager(  808): Force stopping org.nativescript.demofresco appid=10068 user=0: from pid 5655
I/ActivityManager(  808): Killing 5605:org.nativescript.demofresco/u0a68 (adj 0): stop org.nativescript.demofresco
W/ActivityManager(  808): Force removing ActivityRecord{529da1c4 u0 org.nativescript.demofresco/com.tns.ErrorReportActivity t54}: app died, no saved state
W/InputDispatcher(  808): channel '52ad734c org.nativescript.demofresco/com.tns.ErrorReportActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
E/InputDispatcher(  808): channel '52ad734c org.nativescript.demofresco/com.tns.ErrorReportActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
W/InputDispatcher(  808): Attempted to unregister already unregistered input channel '52ad734c org.nativescript.demofresco/com.tns.ErrorReportActivity (server)'
I/WindowState(  808): WIN DEATH: Window{52ad734c u0 org.nativescript.demofresco/com.tns.ErrorReportActivity}
D/AndroidRuntime( 5655): Shutting down VM
D/dalvikvm( 5655): GC_CONCURRENT freed 92K, 15% free 544K/640K, paused 0ms+0ms, total 1ms
W/EGL_xap ( 5132): eglSurfaceAttrib not implemented
W/Binder  ( 1037): Caught a RuntimeException from the binder stub implementation.
W/Binder  ( 1037): java.lang.NullPointerException
W/Binder  ( 1037):      at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
W/Binder  ( 1037):      at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
W/Binder  ( 1037):      at android.os.Binder.execTransact(Binder.java:404)
W/Binder  ( 1037):      at dalvik.system.NativeStart.run(Native Method)
W/InputMethodManagerService(  808): Got RemoteException sending setActive(false) notification to pid 5605 uid 10068
D/AndroidRuntime( 5667):
D/AndroidRuntime( 5667): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 5667): CheckJNI is OFF
D/dalvikvm( 5667): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 5667): Added shared lib libjavacore.so 0x0
D/dalvikvm( 5667): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 5667): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 5667): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
E/cutils-trace( 5667): Error opening trace file: No such file or directory (2)
D/dalvikvm( 5667): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 5667): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 5667): failed to load memtrack module: -2
D/AndroidRuntime( 5667): Calling main entry com.android.commands.am.Am
I/ActivityManager(  808): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=org.nativescript.demofresco/com.tns.NativeScriptActivity} from pid 5667
D/dalvikvm(  808): GC_FOR_ALLOC freed 555K, 22% free 9360K/11976K, paused 10ms, total 10ms
D/dalvikvm(  808): GC_FOR_ALLOC freed 428K, 23% free 9309K/11976K, paused 11ms, total 11ms
D/AndroidRuntime( 5667): Shutting down VM
D/dalvikvm( 5667): GC_CONCURRENT freed 94K, 15% free 576K/676K, paused 0ms+0ms, total 1ms
D/dalvikvm( 5678): Late-enabling CheckJNI
I/ActivityManager(  808): Start proc org.nativescript.demofresco for activity org.nativescript.demofresco/com.tns.NativeScriptActivity: pid=5678 uid=10068 gids={50068, 1028, 1015, 3003}
D/dalvikvm( 5678): Trying to load lib /data/app-lib/org.nativescript.demofresco-1/libNativeScript.so 0xa5073b88
D/dalvikvm( 5678): Added shared lib /data/app-lib/org.nativescript.demofresco-1/libNativeScript.so 0xa5073b88
I/TNS.Native( 5678): NativeScript Runtime Version 2.1.1, commit bce725184f249812c73163957aa50aa9339edddb
D/TNS.Native( 5678): JNI_ONLoad
D/TNS.Native( 5678): JNI_ONLoad END
D/dalvikvm( 5678): GC_CONCURRENT freed 281K, 12% free 2941K/3336K, paused 2ms+0ms, total 4ms
D/TNS.Native( 5678): V8 version 4.7.80
D/TNS.Native( 5678): lenNodes=57624, lenNames=655053, lenValues=728804
D/TNS.Native( 5678): time=1
D/TNS.Java( 5678): Enabling NativeScript Debugger Agent
D/dalvikvm( 5678): GC_CONCURRENT freed 295K, 12% free 3034K/3440K, paused 2ms+1ms, total 8ms
D/AndroidRuntime( 5678): Shutting down VM
W/dalvikvm( 5678): threadid=1: thread exiting with uncaught exception (group=0xa4d92b20)
W/System.err( 5678): java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
W/System.err( 5678): Fail to load module: /data/data/org.nativescript.demofresco/files/app/app.js
W/System.err( 5678): TypeError: Cannot read property 'imagepipeline' of undefined
W/System.err( 5678): File: "<unknown>, line: 1, column: 265
W/System.err( 5678): StackTrace:
W/System.err( 5678):    Frame: function:'', file:'/data/data/org.nativescript.demofresco/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 35, column: 15
W/System.err( 5678):    Frame: function:'require', file:'', line: 1, column: 266
W/System.err( 5678):    Frame: function:'', file:'/data/data/org.nativescript.demofresco/files/app/app.js', line: 2, column: 14
W/System.err( 5678):    Frame: function:'require', file:'', line: 1, column: 266
W/System.err( 5678):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4347)
W/System.err( 5678):    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
W/System.err( 5678):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
W/System.err( 5678):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 5678):    at android.os.Looper.loop(Looper.java:136)
W/System.err( 5678):    at android.app.ActivityThread.main(ActivityThread.java:5017)
W/System.err( 5678):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 5678):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 5678):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
W/System.err( 5678):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
W/System.err( 5678):    at dalvik.system.NativeStart.main(Native Method)
W/System.err( 5678): Caused by: com.tns.NativeScriptException:
W/System.err( 5678): Fail to load module: /data/data/org.nativescript.demofresco/files/app/app.js
W/System.err( 5678): TypeError: Cannot read property 'imagepipeline' of undefined
W/System.err( 5678): File: "<unknown>, line: 1, column: 265
W/System.err( 5678): StackTrace:
W/System.err( 5678):    Frame: function:'', file:'/data/data/org.nativescript.demofresco/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 35, column: 15
W/System.err( 5678):    Frame: function:'require', file:'', line: 1, column: 266
W/System.err( 5678):    Frame: function:'', file:'/data/data/org.nativescript.demofresco/files/app/app.js', line: 2, column: 14
W/System.err( 5678):    Frame: function:'require', file:'', line: 1, column: 266
W/System.err( 5678):    at com.tns.Runtime.runModule(Native Method)
W/System.err( 5678):    at com.tns.Runtime.runModule(Runtime.java:241)
W/System.err( 5678):    at com.tns.Runtime.run(Runtime.java:235)
W/System.err( 5678):    at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
W/System.err( 5678):    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
W/System.err( 5678):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
W/System.err( 5678):    ... 10 more
I/ActivityManager(  808): START u0 {flg=0x14008000 cmp=org.nativescript.demofresco/com.tns.ErrorReportActivity (has extras)} from pid -1
D/dalvikvm(  808): GC_FOR_ALLOC freed 399K, 23% free 9320K/11976K, paused 9ms, total 9ms
D/dalvikvm(  808): GC_FOR_ALLOC freed 378K, 23% free 9317K/11976K, paused 15ms, total 15ms
I/Process ( 5678): Sending signal. PID: 5678 SIG: 9
I/ActivityManager(  808): Process org.nativescript.demofresco (pid 5678) has died.
D/dalvikvm( 5702): Late-enabling CheckJNI
I/ActivityManager(  808): Start proc org.nativescript.demofresco for activity org.nativescript.demofresco/com.tns.ErrorReportActivity: pid=5702 uid=10068 gids={50068, 1028, 1015, 3003}
D/dalvikvm( 5702): Trying to load lib /data/app-lib/org.nativescript.demofresco-1/libNativeScript.so 0xa50749d8
D/dalvikvm( 5702): Added shared lib /data/app-lib/org.nativescript.demofresco-1/libNativeScript.so 0xa50749d8
I/TNS.Native( 5702): NativeScript Runtime Version 2.1.1, commit bce725184f249812c73163957aa50aa9339edddb
D/TNS.Native( 5702): JNI_ONLoad
D/TNS.Native( 5702): JNI_ONLoad END
D/libEGL  ( 5702): loaded /system/lib/egl/libEGL_xap.so
D/eglCodecCommon( 5702): TcpStream::connect() - management hostname is 10.71.34.101
D/eglCodecCommon( 5702): TcpStream::connect() - connecting host: 10.71.34.1
D/        ( 5702): HostConnection::get() New Host Connection established 0xb88d15f0, tid 5702
D/libEGL  ( 5702): loaded /system/lib/egl/libGLESv1_CM_xap.so
D/libEGL  ( 5702): loaded /system/lib/egl/libGLESv2_xap.so
W/EGL_xap ( 5702): eglSurfaceAttrib not implemented
E/OpenGLRenderer( 5702): Getting MAX_TEXTURE_SIZE from GradienCache
E/OpenGLRenderer( 5702): MAX_TEXTURE_SIZE: 8192
E/OpenGLRenderer( 5702): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
E/OpenGLRenderer( 5702): MAX_TEXTURE_SIZE: 8192
D/OpenGLRenderer( 5702): Enabling debug mode 0
I/ActivityManager(  808): Displayed org.nativescript.demofresco/com.tns.ErrorReportActivity: +600ms (total +1s557ms)

Any idea? How to resolve this?

Fresco Images opactiy cannot be animated

I use to be able to do this..

<Image #element class="mark" width="40" height="40"></Image>

@ViewChild("element") element: ElementRef;
element.nativeElement.animate({
                    opacity: 1,
                    duration: 200
                }); 

Since switching these image tags to fresco, this no longer works.

Also noticed I am no longer able to change the opacity of Fresco tags with CSS as well.
Is there a solution to this?

how to load phone storage image?

Hi, i'm using this plugin to display storage image,but it's didn't work.

i used android cursor to query the phone data ,and get the images path like

/storage/sdcard0/Pictures/JPEG_20160711_170452_490755041.jpg

but the ui is showing failureImageUri

i also try to set the image as

file:///storage/sdcard0/Pictures/JPEG_20160711_170452_490755041.jpg

it's still show failureImageUri

so how can i change to display correct images?

image json e.x

{"text":"/Screenshot_2016-05-11-19-19-  
23.png","uri":"/storage/sdcard0/Pictures/Screenshots/Screenshot_2016-05-11-19-19-
23.png","imgUri":{}}

html

<RadListView [items]="imageList">
            <template tkListItemTemplate let-item="item" class="m-t-20">
                <GridLayout class="gridLayoutStyle" rows="*,20" columns="*">
                    <!--<Image row="0"  [src]="item.uri"></Image>-->
                    <FrescoDrawee #drawee verticalAlignment="center" placeholderImageUri="~/images/good.png" aspectRatio="2" width="94" height="94"
                       [imageUri]="item.uri" failureImageUri="~/images/error.png"></FrescoDrawee>
                    <Label row="1" [text]="item.text"></Label>
                </GridLayout>
            </template>
            <ListViewGridLayout tkListViewLayout scrollDirection="Vertical" spanCount="3"></ListViewGridLayout>
        </RadListView>

best wishes~

error in used

hi,i install this plugin,but when use this, this error show:
Error calling module function
TypeError: view_1.Property is not a constructor
File: "file:///data/data/..../tns_modules/naticescript-fresco/nativescript-fresco-common.js,line 52,column 36"

App exit with fresco lib, when load more than 3 images

In my app I have fresco LIB but when images from camera are too bigs and load more than 3 images the app crashes/exits with no error, just closes the app

any idea??

nativescript │ 2.5.4
tns-core-modules │ 2.5.2
tns-android │ 2.5.0
nativescript-fresco │ ^1.0.16 │

onRelease called when .get() is null

When stacking RadListView inside a ListView (for the purpose of having multiple rows, with multiple columns, scrollable separately, but all images loaded dynamically when in-view: like Netflix), it sometimes happens that onRelease can get called when .get() is null

Here's an example stack trace:

com.tns.NativeScriptException: 
Calling js method onRelease failed

TypeError: Cannot read property 'notify' of null
File: \"/data/data/org.nativescript.stremio/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js, line: 282, column: 34

StackTrace: 

Frame: function:'com.facebook.drawee.controller.ControllerListener.onRelease', file:'/data/data/org.nativescript.stremio/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 282, column: 35



at com.tns.Runtime.callJSMethodNative(Native Method)

at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)

at com.tns.Runtime.callJSMethodImpl(Runtime.java:726)

at com.tns.Runtime.callJSMethod(Runtime.java:712)

at com.tns.Runtime.callJSMethod(Runtime.java:693)

at com.tns.Runtime.callJSMethod(Runtime.java:683)

at com.tns.gen.com.facebook.drawee.controller.ControllerListener.onRelease(ControllerListener.java:47)

at com.facebook.drawee.controller.AbstractDraweeController.releaseFetch(AbstractDraweeController.java:188)

at com.facebook.drawee.controller.AbstractDraweeController.release(AbstractDraweeController.java:167)

at com.facebook.drawee.components.DeferredReleaser$1.run(DeferredReleaser.java:67)

at android.os.Handler.handleCallback(Handler.java:739)

at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:135)

at android.app.ActivityThread.main(ActivityThread.java:5257)

at java.lang.reflect.Method.invoke(Native Method)

at java.lang.reflect.Method.invoke(Method.java:372)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)

TypeError: Cannot read property 'base' of undefined

System.err: File: "file:///data/data/com.domain.project/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js, line: 92, column: 37
System.err:
System.err: StackTrace:
System.err:     Frame: function:'', file:'file:///data/data/com.domain.project/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 92, column: 38
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.domain.project/files/app/tns_modules/nativescript-fresco/angular/nativescript-fresco.module.js', line: 6, column: 10
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.domain.project/files/app/tns_modules/nativescript-fresco/angular/index.js', line: 6, column: 10
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.domain.project/files/app/app.module.js', line: 13, column: 17
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.domain.project/files/app/main.js', line: 5, column: 20
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:
System.err:
System.err: TypeError: Cannot read property 'base' of undefined
System.err: File: "<unknown>, line: 1, column: 265 ....

app.module.ts

import { TNSFrescoModule } from "nativescript-fresco/angular";
import application = require("application");
import fresco = require("nativescript-fresco");

if (application.android) {
    application.on("launch", () => {
        fresco.initialize();
    });
}

...

imports: [
    NativeScriptModule
    AppRoutingModule,
    TNSFrescoModule
  ],
"tns-android": {
      "version": "3.4.1"
   }
"dependencies": {
    "@angular/animations": "~5.0.0",
    "@angular/common": "~5.0.0",
    "@angular/compiler": "~5.0.0",
    "@angular/core": "~5.0.0",
    "@angular/forms": "~5.0.0",
    "@angular/http": "~5.0.0",
    "@angular/platform-browser": "~5.0.0",
    "@angular/platform-browser-dynamic": "~5.0.0",
    "@angular/router": "~5.0.0",
    "email-validator": "^1.1.1",
    "font-awesome": "^4.7.0",
    "nativescript-angular": "5.0.0",
    "nativescript-bitmap-factory": "^1.7.1",
    "nativescript-camera": "^3.2.1",
    "nativescript-fresco": "^3.0.6",
    "nativescript-google-maps-sdk": "^2.4.3",
    "nativescript-google-maps-utils": "^0.1.3",
    "nativescript-google-places": "0.0.3",
    "nativescript-imagepicker": "^4.0.1",
    "nativescript-plugin-firebase": "^5.1.4",
    "nativescript-pro-ui": "^3.3.0",
    "nativescript-theme-core": "1.0.4",
    "reflect-metadata": "0.1.10",
    "rxjs": "^5.5.0",
    "tns-core-modules": "^3.4.0",
    "tns-platform-declarations": "^3.4.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "lazy": "1.0.11",
    "nativescript-dev-sass": "^1.3.5",
    "nativescript-dev-typescript": "0.5.1",
    "typescript": "~2.4.2"
  }

Make the plugin compatible with Angular 2 out of the box

Currently you need to manually register the "FrescoDrawee" tag with the nativescript-angular/element-registry like so:

import * as elementRegistryModule from 'nativescript-angular/element-registry';

elementRegistryModule.registerElement("FrescoDrawee", () => frescoModule.FrescoDrawee);

aspectRatio doesn't work on NS 3.0

Hello @VladimirAmiorkov @ginev @sis0k0 @rbasniak,

I upgraded my project to NS3.0 and after that, all my seems to be rendered with height="1" (like a squeezed pancake :) ).

It is easy to recreate this issue in a blank project NS3.0 Angular Project.

To do so, create a new NS project:
tns create HelloWorld --template nativescript-template-ng-tutorial

Add the Fresco Plugin:
tns plugin add nativescript-fresco

Add the base code:
app.module.ts

...
import { TNSFrescoModule } from "nativescript-fresco/angular";
import * as frescoModule from "nativescript-fresco";
import * as applicationModule from "application";

if (applicationModule.android) {
    applicationModule.on("launch", () => {
        frescoModule.initialize();
    });
}
...

Just for records:
Here is the untouched package.json.

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.teste2",
    "tns-android": {
      "version": "3.0.1"
    }
  },
  "dependencies": {
    "@angular/animations": "~4.1.0",
    "@angular/common": "~4.1.0",
    "@angular/compiler": "~4.1.0",
    "@angular/core": "~4.1.0",
    "@angular/forms": "~4.1.0",
    "@angular/http": "~4.1.0",
    "@angular/platform-browser": "~4.1.0",
    "@angular/router": "~4.1.0",
    "nativescript-angular": "~3.0.0",
    "nativescript-fresco": "^3.0.2",
    "nativescript-theme-core": "~1.0.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.3.0",
    "tns-core-modules": "~3.0.0",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "~0.4.0",
    "typescript": "~2.2.1"
  }
}

Add the sample test code with some FrescoDrawee variations
app.component.ts

import { Component } from "@angular/core";

@Component({
  selector: "my-app",
  template: `
    <ActionBar title="My App"></ActionBar>
    <StackLayout>
        <Label text="Stacklayout"></Label>
        <FrescoDrawee #drawee verticalAlignment="center" aspectRatio="2" imageUri="~/images/apple.jpg"></FrescoDrawee>
        <Label text="GridLayout"></Label>
        <GridLayout rows="100">
            <FrescoDrawee row="0" #drawee verticalAlignment="center" aspectRatio="2" imageUri="~/images/apple.jpg"></FrescoDrawee>
        </GridLayout>
        <Label text="width:'50"></Label>
        <FrescoDrawee #drawee verticalAlignment="center" width="50" aspectRatio="2" imageUri="~/images/apple.jpg"></FrescoDrawee>
        <Label text="height: 50"></Label>
        <FrescoDrawee #drawee verticalAlignment="center" height="50" aspectRatio="2" imageUri="~/images/apple.jpg"></FrescoDrawee>
        <Label text="width: 50 height: 25"></Label>
        <FrescoDrawee #drawee verticalAlignment="center" width="50" height="25" aspectRatio="2" imageUri="~/images/apple.jpg"></FrescoDrawee>
    </StackLayout>
  `
})
export class AppComponent {
  }

This code renders like this:
image

The aspectRatio seems to be not working as it should. I suppose it should calculate the height of those images based on the width and aspectRatio value itself.

Does anyone knows if it is an real issue or if I'm doing some wrong ? Maybe it has a breaking change that I don't know since I am upgrading to NS3.0 version.

All my projects code is based on aspectRatio property, so It's really important. I do much appreciate your help.

Thanks in advance
Ricardo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.