import { EventData } from '@nativescript/core/data/observable' ; import { Button } from '@nativescript/core/ui/button' ; import { GridLayout } from '@nativescript/core/ui/layouts/grid-layout' ; import { Label } from '@nativescript/core/ui/label' ; import { Img , getImagePipeline } from '@nativescript-community/ui-image' ; import { writeToOutputLabel } from './appLogger' ; const src = 'https://raw.githubusercontent.com/nativescript-community/ui-image/master/examples-data/breakfast1.jpg' ; export function onCheckCache ( args ) { const button = args . object as Button ; const gridLayout = button . parent as GridLayout ; const imageView = gridLayout . getViewById ( 'imageView' ) as Img ; const imagePipeLine = getImagePipeline ( ) ; const isInCache = imagePipeLine . isInBitmapMemoryCache ( src ) ; writeToOutputLabel ( imageView , '>>>>> Image is in the Bitmap memory cache - ' + isInCache ) ; } export function onClearCache ( args ) { const button = args . object as Button ; const gridLayout = button . parent as GridLayout ; const imageView = gridLayout . getViewById ( 'imageView' ) as Img ; const imagePipeLine = getImagePipeline ( ) ; writeToOutputLabel ( imageView , '>>>>> Clearning cache' ) ; imagePipeLine . clearCaches ( ) ; } export function onSetImage ( args ) { const button = args . object as Button ; const gridLayout = button . parent as GridLayout ; const imageView = gridLayout . getViewById ( 'imageView' ) as Img ; imageView . src = null ; imageView . src = src ; } export function onResetImage ( args ) { const button = args . object as Button ; const gridLayout = button . parent as GridLayout ; const imageView = gridLayout . getViewById ( 'imageView' ) as Img ; writeToOutputLabel ( imageView , ">>>>> Refreshing cache and 'src'" ) ; imageView . updateImageUri ( ) ; }