Can I call FrescoDrawee image library in java for Android from my NativeScript app?

Thread is closed for posting
3 posts, 0 answers
  1. Stan
    Stan avatar
    40 posts
    Member since:
    May 2017

    Posted 03 Jan 2018 Link to this post

    In my NativeScript app I need to resize my images before using it in the RadListView because of out of memory issues in Android. I have found a NativeScript-Fresco plugin but unfortunately it does not do resizing, however the Fresco library does have a resize routine, it's just not available in the NativeScript-Fresco plugin.

    So, can I call FrescoDrawee (Facebook's image library in java for Android) from my NativeScript app?
    If so , how do I do that?

    Thanks so much!

  2. Nikolay Iliev
    Nikolay Iliev avatar
    351 posts

    Posted 04 Jan 2018 Link to this post

    Hi Stan,

    In NativeScript 3.x.x there were some changes and optimizations for working with images on Android and properties
    like decodeWidth and decodeHeight were introduced. In fact, the Fresco library can be dismissed if we are following the best practices
    for using images in Android

    However, if you still need to use the Fresco library you can extend the existing plugin (you can even contribute with a PR and provide the additional functionality so it can become a part of the nativescript-fresco plugin). The existing plugin is requiring the dependency to the Fresco library in the build.gradle here.
    From that point, we can access the library classes, methods, and properties by using data conversion (Java to JavaScript) - examples can be found all over the code base of the plugin (e.g. here is the initialization of the Fresco). Examples of marshaling code from Java to javaScript can be found in this documentation article.

    In case, extending the plugin (which is the recommended way) is considered overkill, you can include the library as project dependency in app/App_Resources/Android/app.gradle file and once again access the library as mentioned above while using data conversion syntax.

    Nikolay Iliev
    Progress Telerik
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
  3. Stan
    Stan avatar
    40 posts
    Member since:
    May 2017

    Posted 04 Jan 2018 in reply to Nikolay Iliev Link to this post

    Thank you for your insight. Have a happy new year.
Back to Top