@@ -2,14 +2,14 @@ export * from './index-common';
22import { Color , Image , ImageAsset , ImageSource , Trace , Utils , knownFolders , path } from '@nativescript/core' ;
33import { android as androidApp } from '@nativescript/core/application' ;
44import { isString } from '@nativescript/core/utils/types' ;
5- import { RESOURCE_PREFIX , ad , isFileOrResourcePath , isFontIconURI } from '@nativescript/core/utils/utils' ;
65import { AnimatedImage , CLog , CLogTypes , EventData , ImageBase , ImageError as ImageErrorBase , ImageInfo as ImageInfoBase , ImagePipelineConfigSetting , ScaleType } from './index-common' ;
6+ import { layout } from '@nativescript/core/utils/layout-helper' ;
77
88let initialized = false ;
99let initializeConfig : ImagePipelineConfigSetting ;
1010export function initialize ( config ?: ImagePipelineConfigSetting ) : void {
1111 if ( ! initialized ) {
12- const context = ad . getApplicationContext ( ) ;
12+ const context = Utils . ad . getApplicationContext ( ) ;
1313 if ( ! context ) {
1414 initializeConfig = config ;
1515 return ;
@@ -70,9 +70,9 @@ function getUri(src: string | ImageAsset) {
7070 } else {
7171 imagePath = src ;
7272 }
73- if ( isFileOrResourcePath ( imagePath ) ) {
74- if ( imagePath . indexOf ( RESOURCE_PREFIX ) === 0 ) {
75- const resName = imagePath . substring ( RESOURCE_PREFIX . length ) ;
73+ if ( Utils . isFileOrResourcePath ( imagePath ) ) {
74+ if ( imagePath . indexOf ( Utils . RESOURCE_PREFIX ) === 0 ) {
75+ const resName = imagePath . substring ( Utils . RESOURCE_PREFIX . length ) ;
7676 const identifier = Utils . ad . resources . getDrawableId ( resName ) ;
7777 if ( 0 < identifier ) {
7878 uri = new android . net . Uri . Builder ( ) . scheme ( com . facebook . common . util . UriUtil . LOCAL_RESOURCE_SCHEME ) . path ( java . lang . String . valueOf ( identifier ) ) . build ( ) ;
@@ -536,15 +536,15 @@ export class Img extends ImageBase {
536536 if ( src ) {
537537 let drawable : android . graphics . drawable . BitmapDrawable ;
538538 if ( src instanceof ImageSource ) {
539- drawable = new android . graphics . drawable . BitmapDrawable ( ad . getApplicationContext ( ) . getResources ( ) , src . android as android . graphics . Bitmap ) ;
539+ drawable = new android . graphics . drawable . BitmapDrawable ( Utils . ad . getApplicationContext ( ) . getResources ( ) , src . android as android . graphics . Bitmap ) ;
540540 this . updateViewSize ( src . android ) ;
541- } else if ( isFontIconURI ( src as string ) ) {
541+ } else if ( Utils . isFontIconURI ( src as string ) ) {
542542 const fontIconCode = ( src as string ) . split ( '//' ) [ 1 ] ;
543543 if ( fontIconCode !== undefined ) {
544544 // support sync mode only
545545 const font = this . style . fontInternal ;
546546 const color = this . style . color ;
547- drawable = new android . graphics . drawable . BitmapDrawable ( ad . getApplicationContext ( ) . getResources ( ) , ImageSource . fromFontIconCodeSync ( fontIconCode , font , color ) . android ) ;
547+ drawable = new android . graphics . drawable . BitmapDrawable ( Utils . ad . getApplicationContext ( ) . getResources ( ) , ImageSource . fromFontIconCodeSync ( fontIconCode , font , color ) . android ) ;
548548 }
549549 }
550550 if ( drawable ) {
@@ -821,23 +821,23 @@ export class Img extends ImageBase {
821821 private getDrawable ( path : string | ImageSource ) {
822822 let drawable : android . graphics . drawable . BitmapDrawable ;
823823 if ( typeof path === 'string' ) {
824- if ( isFontIconURI ( path ) ) {
824+ if ( Utils . isFontIconURI ( path ) ) {
825825 const fontIconCode = path . split ( '//' ) [ 1 ] ;
826826 if ( fontIconCode !== undefined ) {
827827 // support sync mode only
828828 const font = this . style . fontInternal ;
829829 const color = this . style . color ;
830- drawable = new android . graphics . drawable . BitmapDrawable ( ad . getApplicationContext ( ) . getResources ( ) , ImageSource . fromFontIconCodeSync ( fontIconCode , font , color ) . android ) ;
830+ drawable = new android . graphics . drawable . BitmapDrawable ( Utils . ad . getApplicationContext ( ) . getResources ( ) , ImageSource . fromFontIconCodeSync ( fontIconCode , font , color ) . android ) ;
831831 }
832- } else if ( isFileOrResourcePath ( path ) ) {
833- if ( path . indexOf ( RESOURCE_PREFIX ) === 0 ) {
832+ } else if ( Utils . isFileOrResourcePath ( path ) ) {
833+ if ( path . indexOf ( Utils . RESOURCE_PREFIX ) === 0 ) {
834834 return this . getDrawableFromResource ( path ) ; // number!
835835 } else {
836836 drawable = this . getDrawableFromLocalFile ( path ) ;
837837 }
838838 }
839839 } else {
840- drawable = new android . graphics . drawable . BitmapDrawable ( ad . getApplicationContext ( ) . getResources ( ) , path . android ) ;
840+ drawable = new android . graphics . drawable . BitmapDrawable ( Utils . ad . getApplicationContext ( ) . getResources ( ) , path . android ) ;
841841 }
842842
843843 return drawable ;
@@ -847,14 +847,14 @@ export class Img extends ImageBase {
847847 const img = ImageSource . fromFileSync ( localFilePath ) ;
848848 let drawable : android . graphics . drawable . BitmapDrawable = null ;
849849 if ( img ) {
850- drawable = new android . graphics . drawable . BitmapDrawable ( ad . getApplicationContext ( ) . getResources ( ) , img . android ) ;
850+ drawable = new android . graphics . drawable . BitmapDrawable ( Utils . ad . getApplicationContext ( ) . getResources ( ) , img . android ) ;
851851 }
852852
853853 return drawable ;
854854 }
855855
856856 private getDrawableFromResource ( resourceName : string ) {
857- const identifier = ad . getApplication ( ) . getResources ( ) . getIdentifier ( resourceName . substr ( RESOURCE_PREFIX . length ) , 'drawable' , ad . getApplication ( ) . getPackageName ( ) ) ;
857+ const identifier = Utils . ad . getApplication ( ) . getResources ( ) . getIdentifier ( resourceName . substr ( Utils . RESOURCE_PREFIX . length ) , 'drawable' , Utils . ad . getApplication ( ) . getPackageName ( ) ) ;
858858 // we return the identifier to allow Fresco to handle memory / caching
859859 return identifier ;
860860 }
@@ -887,7 +887,7 @@ class GenericDraweeHierarchyBuilder {
887887 private nativeBuilder : com . facebook . drawee . generic . GenericDraweeHierarchyBuilder ;
888888
889889 constructor ( ) {
890- const res = ad . getApplicationContext ( ) . getResources ( ) ;
890+ const res = Utils . ad . getApplicationContext ( ) . getResources ( ) ;
891891 this . nativeBuilder = new com . facebook . drawee . generic . GenericDraweeHierarchyBuilder ( res ) ;
892892 }
893893
0 commit comments