All Projects → AndreaVitale → av.imageview

AndreaVitale / av.imageview

Licence: MIT license
Titanium native ImageView module that extends the default Titanium ImageView with more capabilities and a different caching system.

Programming Languages

objective c
16641 projects - #2 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to av.imageview

titanium-turbo
Axway Amplify module that adds some enhancements for Appcelerator Titanium Alloy
Stars: ✭ 15 (-84.54%)
Mutual labels:  native, titanium, titanium-mobile, appcelerator, appcelerator-titanium
ti.admob
Use the Google AdMob SDK on iOS and Android with Titanium
Stars: ✭ 51 (-47.42%)
Mutual labels:  native, titanium, appcelerator, titanium-module
TiFastlane
With TiFastlane you'll be able to fully optimize the way you submit your app updates and maintain your certificates and provisioning profiles of all your Titanium Apps.
Stars: ✭ 83 (-14.43%)
Mutual labels:  titanium, titanium-mobile, appcelerator, appcelerator-titanium
ti.paint
Touch-based painting with the Titanium SDK.
Stars: ✭ 27 (-72.16%)
Mutual labels:  native, titanium, appcelerator, titanium-module
ti.playservices
Titanium module for Google Play Services
Stars: ✭ 19 (-80.41%)
Mutual labels:  native, titanium, appcelerator, titanium-module
titanium-paypal
💰 Use the PayPal iOS-SDK 2.x with Titanium Mobile.
Stars: ✭ 22 (-77.32%)
Mutual labels:  native, titanium-mobile, appcelerator
Titanium mobile
🚀 Native iOS- and Android- Apps with JavaScript
Stars: ✭ 2,553 (+2531.96%)
Mutual labels:  native, titanium, appcelerator
titanium-arkit
Use the iOS 11 ARKit API in Axway Titanium
Stars: ✭ 28 (-71.13%)
Mutual labels:  native, titanium, appcelerator
titanium-apple-sign-in
Use the iOS 13+ Apple Sign In API with Titanium
Stars: ✭ 29 (-70.1%)
Mutual labels:  titanium, appcelerator, titanium-module
titanium-alternate-icons
Leverage the ability to change the app icon in iOS 10.3+
Stars: ✭ 24 (-75.26%)
Mutual labels:  titanium, appcelerator, titanium-module
titanium-material
Use the native Material UI/UX framework (https://github.com/CosmicMind/Material) in Titanium!
Stars: ✭ 14 (-85.57%)
Mutual labels:  native, titanium, appcelerator
titanium-firebase-analytics
Use the Firebase Analytics SDK in Axway Titanium 🚀
Stars: ✭ 33 (-65.98%)
Mutual labels:  native, titanium, appcelerator
ti.moddevguide
Appcelerator Titanium native Module Guide
Stars: ✭ 39 (-59.79%)
Mutual labels:  titanium, appcelerator, titanium-module
griffin-app-opensource
The Axway Griffin App goes open source!
Stars: ✭ 19 (-80.41%)
Mutual labels:  native, titanium, appcelerator
ti.coremotion
Support for the native iOS CoreMotion framework in Appcelerator Titanium
Stars: ✭ 15 (-84.54%)
Mutual labels:  native, titanium, appcelerator
ti.map
Use native Apple Maps & Google Maps in iOS and Android with Axway Titanium
Stars: ✭ 49 (-49.48%)
Mutual labels:  native, titanium, appcelerator
ti.accountkit
DEPRECATED -- 🔐 Use the Facebook AccountKit iOS-SDK with Titanium Mobile.
Stars: ✭ 18 (-81.44%)
Mutual labels:  native, titanium
titanium-web-dialog
Use the SFSafariViewController (iOS) and Chrome Pages (Android) in Titanium.
Stars: ✭ 28 (-71.13%)
Mutual labels:  native, titanium
ti.youtube
A small library to get the URL of the desired YouTube video ID to use it natively in Ti.Media.VideoPlayer.
Stars: ✭ 13 (-86.6%)
Mutual labels:  titanium, titanium-module
nl.fokkezb.loading
The widget provides a simple loading mask that can be easily styled and configured.
Stars: ✭ 96 (-1.03%)
Mutual labels:  titanium, appcelerator

av.imageview

An optimized ImageView module
for Axway Appcelerator Titanium Framework

Features

Currently Titanium.UI.ImageView doesn't support the contentMode property so your rendered image will everytime fit your ImageView. The main feature of this module is contentMode handling that allows you to specify which behavior your ImageView must have and, in addition, the module adds some extra features like image caching and placeholder-fallback images.

Here is an example of two mainly supported content modes: CONTENT_MODE_ASPECT_FIT and CONTENT_MODE_ASPECT_FILL.

         

All other macro-features can be grouped in the following list:

  • ContentModes handling
  • Loading image placeholder
  • Broken link image fallback
  • Custom HTTP header, useful if the images are protected
  • WebP support
  • GIF support

Installation

Pick the latest version of the module from here and unzip it inside your application module folder or install it automatically via gitt.io

$ gittio install av.imageview

In your application's tiapp.xml the av.imageview module is declared as follows:

<modules>
    <module platform="iphone">av.imageview</module>
    <module platform="android">av.imageview</module>
</modules>

and you're ready to use it.

API

All Titanium.UI.View properties and methods are supported.

Property Description iOS Android Note
contentMode Sets the ImageView content mode Supported content modes are listed in a next section.
defaultImage Image to display when the image download is in progress Must refers to a local image ; Android must be set before assigning an image (e.g. at creation)
brokenLinkImage Image to display when the image fetch goes in error Must refers to a local image; Android must be set before assigning an image (e.g. at creation)
loadingIndicator Enable or disable the activity indicator when the download is in progress true by default
loadingIndicatorColor Changes the loading indicator color
requestHeaders An object used to define extra http request header fields
timeout Sets timeout for requests, in milliseconds
handleCookies Enables cookie handling for remote images
shouldCacheImagesInMemory Activates in-memory cache mechanism true by default
avoidDecodeImage Disable image decompression 🚫 false by default
maxCacheAge The maximum length of time to keep an image in the cache, in seconds 🚫 integer value
maxCacheSize The maximum size of the cache, in bytes 🚫 integer value
rounded Renders the image in a circle 🚫 Use with CONTENT_MODE_ASPECT_FIT for a correct rendering
animated Disables the fade-in animation 🚫
signature Sets a custom caching signature (Glide documentation) 🚫 string value

Events

  • load an event that is fired when an image was correctly loaded
    • image as a string if a remote or local url was given or as a blob otherwise
  • error an event that is fired when the image fetch goes in error
    • image as a string if a remote or local url was given or as a blob otherwise
    • reason contains the reason why the image fetch goes in error

Supported content modes

Here is a list of supported content modes:

Android and iOS

  • CONTENT_MODE_ASPECT_FIT
  • CONTENT_MODE_ASPECT_FILL

iOS only

  • CONTENT_MODE_SCALE_TO_FIT
  • CONTENT_MODE_REDRAW
  • CONTENT_MODE_CENTER
  • CONTENT_MODE_TOP
  • CONTENT_MODE_BOTTOM
  • CONTENT_MODE_LEFT
  • CONTENT_MODE_RIGHT
  • CONTENT_MODE_TOP_LEFT
  • CONTENT_MODE_TOP_RIGHT
  • CONTENT_MODE_BOTTOM_LEFT
  • CONTENT_MODE_BOTTOM_RIGHT

Usage

You can simply use this module by declaring an ImageView in your controller.xml file as follows:

    <ImageView id="Photo" module="av.imageview" />

and style it by using the related controller.tss file:

    "#Photo": {
        width: Ti.UI.FILL,
        height: 200,
        contentMode: Alloy.Globals.CONTENT_MODE_FILL,
        loadingIndicatorColor: "red"
    }

and of course expose as a global variable your desired CONTENT_MODE inside Alloy.Globals namespace.

ListView ItemTemplate

Using the module in a ListItemTemplate is a bit difference because custom module proxies cannot be directly used inside of it.

    <ItemTemplate>
        <ImageView ns="AvImageview" />
    </ItemTemplate>

where AvImageview is a variable declared in alloy.js like as follows:

    const AvImageview = require("av.imageview");
    global.AvImageview = AvImageview;
    
    //and to use contentmodes constants via alloy
    Alloy.Globals.CONTENT_MODE_FIT = AvImageview.CONTENT_MODE_ASPECT_FIT;
    Alloy.Globals.CONTENT_MODE_FILL = AvImageview.CONTENT_MODE_ASPECT_FILL;

    //If you need to access to protected images you can define which request header fields the module has to use for every request
    Alloy.Globals.REQUEST_HEADERS = {
        'Authorization': 'place or assign dinamically your logged user access token',
        'Another HTTP header field': 'with its value'
    };

A complete example can be:

    <ListView id="Images" defaultItemTemplate="template">
        <Templates>
            <ItemTemplate name="template" height="160">
                <ImageView ns="AvImageview" bindId="photo" height="160" width="Ti.UI.FILL" loadingIndicator="true" contentMode="Alloy.Globals.CONTENT_MODE_FILL" requestHeader="Alloy.Globals.REQUEST_HEADERS" />
            </ItemTemplate>
        </Templates>
        <ListSection>
            <ListItem template="template" photo:image="http://www.nationalgeographic.com/content/dam/photography/photos/000/060/6018.ngsversion.1467254523217.adapt.1900.1.jpg"></ListItem>
            <ListItem template="template" photo:image="http://www.italiangoodnews.com/wp-content/uploads/2014/11/italy-04.jpg"></ListItem>
            <ListItem template="template" photo:image="https://walkingtree.org/wp-content/uploads/2015/09/Elia-Locardi-Whispers-From-The-Past-The-Colosseum-Rome-Italy-1280-WM.jpg"></ListItem>
            <ListItem template="template" photo:image="http://wp-admin.goldenbird-italy.com/wp-content/uploads/2015/07/italy_2631046a.jpg"></ListItem>
            <ListItem template="template" photo:image="http://www.travelviaitaly.com/wp-content/uploads/2015/12/Rome-Italy.jpg"></ListItem>
        </ListSection>
    </ListView>

Do you want a more complete example? Look a the sample app.js.

Contributions

If you enjoy this module, feel free to contribute with your PR or donate :-)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].