Skip to content

Commit be3fee6

Browse files
committed
refactoring
1 parent 1d2ebae commit be3fee6

File tree

12 files changed

+49
-49
lines changed

12 files changed

+49
-49
lines changed

dev_demo/app/examples/animating.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { AnimatedImage, FinalEventData, Img } from '~/nativescript-image';
22
import { writeToOutputLabel } from './appLogger';
33

44
export function onFinalImageSet(args: FinalEventData) {
5-
const drawee = args.object as Img;
5+
const imageView = args.object as Img;
66
const message = '>>>>>> onFinalImageSet ';
7-
writeToOutputLabel(drawee, message);
7+
writeToOutputLabel(imageView, message);
88
const animatedImage = args.animatable as AnimatedImage;
99
if (animatedImage) {
10-
writeToOutputLabel(drawee, '>>>>>> animatedImage: isRunning(): ' + animatedImage.isRunning());
11-
writeToOutputLabel(drawee, '>>>>>> animatedImage: start() ');
10+
writeToOutputLabel(imageView, '>>>>>> animatedImage: isRunning(): ' + animatedImage.isRunning());
11+
writeToOutputLabel(imageView, '>>>>>> animatedImage: start() ');
1212
animatedImage.start();
13-
writeToOutputLabel(drawee, '>>>>>> animatedImage: isRunning(): ' + animatedImage.isRunning());
13+
writeToOutputLabel(imageView, '>>>>>> animatedImage: isRunning(): ' + animatedImage.isRunning());
1414
}
1515
}

dev_demo/app/examples/appLogger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Img } from '~/nativescript-image';
22
import { GridLayout } from 'tns-core-modules/ui/layouts/grid-layout';
33
import { Label } from 'tns-core-modules/ui/label';
44

5-
export function writeToOutputLabel(drawee: Img, message: string) {
6-
const gridLayout = drawee.parent as GridLayout;
5+
export function writeToOutputLabel(imageView: Img, message: string) {
6+
const gridLayout = imageView.parent as GridLayout;
77
const label = gridLayout.getViewById('outputLabel') as Label;
88
console.log(message);
99
label.text += '\n' + message;

dev_demo/app/examples/cache.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@ const src = 'https://raw.githubusercontent.com/Akylas/nativescript-image/master/
1010
export function onCheckCache(args: EventData) {
1111
const button = args.object as Button;
1212
const gridLayout = button.parent as GridLayout;
13-
const drawee = gridLayout.getViewById('imageDrawee') as imageModel.Img;
13+
const imageView = gridLayout.getViewById('imageView') as imageModel.Img;
1414
const imagePipeLine = imageModel.getImagePipeline();
1515
const isInCache = imagePipeLine.isInBitmapMemoryCache(src);
16-
writeToOutputLabel(drawee, '>>>>> Image is in the Bitmap memory cache - ' + isInCache);
16+
writeToOutputLabel(imageView, '>>>>> Image is in the Bitmap memory cache - ' + isInCache);
1717

1818
// TODO: Uncomment this after upgrading the native Image library above the currently used 0.9.0+ version and make sure its is available in the new version.
1919
// var isInDiskCache = imagePipeLine.isInDiskCacheSync(src);
2020
// var message = ">>>>> Image is in the disk cache: " + isInDiskCache;
2121
// console.log(message);
22-
// writeToOutputLabel(drawee, message);
22+
// writeToOutputLabel(imageView, message);
2323
}
2424

2525
export function onClearCache(args: EventData) {
2626
const button = args.object as Button;
2727
const gridLayout = button.parent as GridLayout;
28-
const drawee = gridLayout.getViewById('imageDrawee') as imageModel.Img;
28+
const imageView = gridLayout.getViewById('imageView') as imageModel.Img;
2929
const imagePipeLine = imageModel.getImagePipeline();
30-
writeToOutputLabel(drawee, '>>>>> Clearning cache');
30+
writeToOutputLabel(imageView, '>>>>> Clearning cache');
3131

3232
imagePipeLine.clearCaches();
3333
}
3434

3535
export function onSetImage(args: EventData) {
3636
const button = args.object as Button;
3737
const gridLayout = button.parent as GridLayout;
38-
const drawee = gridLayout.getViewById('imageDrawee') as imageModel.Img;
39-
drawee.src = null;
40-
drawee.src = src;
38+
const imageView = gridLayout.getViewById('imageView') as imageModel.Img;
39+
imageView.src = null;
40+
imageView.src = src;
4141
}
4242

4343
export function onResetImage(args: EventData) {
4444
const button = args.object as Button;
4545
const gridLayout = button.parent as GridLayout;
46-
const drawee = gridLayout.getViewById('imageDrawee') as imageModel.Img;
47-
writeToOutputLabel(drawee, ">>>>> Refreshing cache and 'src'");
46+
const imageView = gridLayout.getViewById('imageView') as imageModel.Img;
47+
writeToOutputLabel(imageView, ">>>>> Refreshing cache and 'src'");
4848

49-
drawee.updateImageUri();
49+
imageView.updateImageUri();
5050
}

dev_demo/app/examples/cache.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ScrollView>
22
<StackLayout>
3-
<img:Img id="imageDrawee" xmlns:img="nativescript-image"
3+
<img:Img id="imageView" xmlns:img="nativescript-image"
44
verticalAlignment="center"
55
placeholderImageUri="res://ns_logo"
66
src="https://raw.githubusercontent.com/Akylas/nativescript-image/master/examples-data/breakfast1.jpg"/>

dev_demo/app/examples/events.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@ import { Label } from 'tns-core-modules/ui/label';
55
import { writeToOutputLabel } from './appLogger';
66

77
export function onFinalImageSet(args: FinalEventData) {
8-
const drawee = args.object as Img;
8+
const imageView = args.object as Img;
99
const message = '>>>>> onFinalImageSet ';
1010
console.log(message);
11-
writeToOutputLabel(drawee, message);
11+
writeToOutputLabel(imageView, message);
1212
}
1313

1414
export function onIntermediateImageSet(args: IntermediateEventData) {
15-
const drawee = args.object as Img;
15+
const imageView = args.object as Img;
1616
const message = '>>>>> onIntermediateImageSet ';
1717
console.log(message);
18-
writeToOutputLabel(drawee, message);
18+
writeToOutputLabel(imageView, message);
1919
}
2020

2121
export function intermediateImageFailed(args: FailureEventData) {
22-
const drawee = args.object as Img;
22+
const imageView = args.object as Img;
2323
const message = '>>>>> intermediateImageFailed ';
2424
console.log(message);
25-
writeToOutputLabel(drawee, message);
25+
writeToOutputLabel(imageView, message);
2626
}
2727

2828
export function onSubmit(args: EventData) {
29-
const drawee = args.object as Img;
29+
const imageView = args.object as Img;
3030
const message = '>>>>> onSubmit ';
3131
console.log(message);
32-
writeToOutputLabel(drawee, message);
32+
writeToOutputLabel(imageView, message);
3333
}
3434

3535
export function onRelease(args: EventData) {
36-
const drawee = args.object as Img;
36+
const imageView = args.object as Img;
3737
const message = '>>>>> onRelease ';
3838
console.log(message);
39-
writeToOutputLabel(drawee, message);
39+
writeToOutputLabel(imageView, message);
4040
}

dev_demo/app/examples/fade.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import * as imageModel from '~/nativescript-image';
66
export function onSetTap(args: EventData) {
77
const button = args.object as Button;
88
const gridLayout = button.parent as StackLayout;
9-
const imageDrawee = gridLayout.getViewById('imageDrawee') as imageModel.Img;
9+
const imageView = gridLayout.getViewById('imageView') as imageModel.Img;
1010
// Fade only executes the first time the image is loaded. Cached images will not fade in - https://github.com/facebook/image/issues/2138
1111
const src = 'https://raw.githubusercontent.com/Akylas/nativescript-image/master/examples-data/drink1.jpg';
1212
const imagePipeLine = imageModel.getImagePipeline();
1313
imagePipeLine.evictFromCache(src);
14-
imageDrawee.src = imageDrawee.src ? '' : src;
14+
imageView.src = imageView.src ? '' : src;
1515
}

dev_demo/app/examples/fade.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<StackLayout >
22
<Button text="set / unset" tap="onSetTap"/>
33
<img:Img xmlns:img="nativescript-image" verticalAlignment="center" row="1"
4-
id="imageDrawee"
4+
id="imageView"
55

66
fadeDuration="3000"/>
77
</StackLayout>

dev_demo/app/examples/failure.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Label } from 'tns-core-modules/ui/label';
44
import { writeToOutputLabel } from './appLogger';
55

66
export function onFailure(args: FailureEventData) {
7-
const drawee = args.object as Img;
7+
const imageView = args.object as Img;
88
const message = '>>>>> onFailureTest ' + args.error;
9-
writeToOutputLabel(drawee, message);
9+
writeToOutputLabel(imageView, message);
1010
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Img } from '~/nativescript-image';
22

33
// export function onLoaded(args) {
4-
// let drawee = args.object as Image;
5-
// if (drawee.android) {
4+
// let imageView = args.object as Image;
5+
// if (imageView.android) {
66
// const matrix: android.graphics.ColorMatrix = new android.graphics.ColorMatrix();
77
// matrix.setSaturation(0);
88
// const filter: android.graphics.ColorMatrixColorFilter = new android.graphics.ColorMatrixColorFilter(
99
// matrix
1010
// );
11-
// drawee.android.setColorFilter(filter);
11+
// imageView.android.setColorFilter(filter);
1212
// }
1313
// }

dev_demo/app/examples/opacity.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ import { writeToOutputLabel } from './appLogger';
88
export function onSeOpacityTo1(args: EventData) {
99
const button = args.object as Button;
1010
const gridLayout = button.parent as GridLayout;
11-
const drawee = gridLayout.getViewById('opacityDrawee') as Img;
12-
drawee.opacity = 1;
11+
const imageView = gridLayout.getViewById('opacityDrawee') as Img;
12+
imageView.opacity = 1;
1313
}
1414

1515
export function onSeOpacityTo01(args: EventData) {
1616
const button = args.object as Button;
1717
const gridLayout = button.parent as GridLayout;
18-
const drawee = gridLayout.getViewById('opacityDrawee') as Img;
19-
drawee.opacity = 0.1;
18+
const imageView = gridLayout.getViewById('opacityDrawee') as Img;
19+
imageView.opacity = 0.1;
2020
}
2121

2222
export function onSeOpacityTo05(args: EventData) {
2323
const button = args.object as Button;
2424
const gridLayout = button.parent as GridLayout;
25-
const drawee = gridLayout.getViewById('opacityDrawee') as Img;
26-
drawee.opacity = 0.5;
25+
const imageView = gridLayout.getViewById('opacityDrawee') as Img;
26+
imageView.opacity = 0.5;
2727
}
2828

2929
export function onAnimateCss(args) {
3030
const button = args.object as Button;
3131
const gridLayout = button.parent as GridLayout;
32-
const drawee = gridLayout.getViewById('opacityDrawee') as Img;
33-
drawee.animate({
32+
const imageView = gridLayout.getViewById('opacityDrawee') as Img;
33+
imageView.animate({
3434
opacity: 1,
3535
duration: 200
3636
});

0 commit comments

Comments
 (0)