1
00:00:00,150 --> 00:00:06,580
Hire anyone in this theater you are really going to go ahead and create another Android application.

2
00:00:06,600 --> 00:00:09,750
So just click on this start in your Android studio project

3
00:00:12,730 --> 00:00:23,170
and for the name of the application just type in hit app app 49 and then click on next and here choose.

4
00:00:23,170 --> 00:00:27,980
AP is 16 Android 4.1 Jelly Bean for a minimum SDK.

5
00:00:28,000 --> 00:00:36,210
And then click on next and here choose empty activity next and then click on finish.

6
00:00:36,270 --> 00:00:40,760
So now as you can see our Android application is actually created.

7
00:00:40,770 --> 00:00:47,170
So now let's actually go inside this this folder and then go is go inside this folder and then go inside

8
00:00:47,170 --> 00:00:50,340
this activity Underland main that is and here.

9
00:00:50,460 --> 00:00:53,640
And as you can see here this is the user interface of our application.

10
00:00:53,780 --> 00:00:57,350
And as you can see I have this direct action bar theme here.

11
00:00:57,480 --> 00:01:01,970
So if I click on it now I can actually select a theme for my user interface.

12
00:01:02,100 --> 00:01:08,940
So I chose this material light and here I chose this one material that light the dark action one and

13
00:01:08,940 --> 00:01:10,010
then click on OK.

14
00:01:10,350 --> 00:01:14,280
So now I want to actually design the user interface of my application.

15
00:01:14,280 --> 00:01:20,700
So here first of all because I want to actually download an image from it from the internet I need an

16
00:01:20,730 --> 00:01:27,010
image view here so I'll just select this image inside this widgets folder and then put it here.

17
00:01:27,270 --> 00:01:33,450
As you can see this is actually relatively out and I can actually put it anywhere I want and here as

18
00:01:33,450 --> 00:01:36,110
you can see it's in these lines here.

19
00:01:36,150 --> 00:01:44,640
And as you can see I am actually positioning this image view relatively to other components here on

20
00:01:44,640 --> 00:01:46,380
the screen as you can see here.

21
00:01:46,380 --> 00:01:47,190
Right.

22
00:01:47,220 --> 00:01:53,610
So first of all let's actually drag linearly out of vertical vertical at the center of this relatively

23
00:01:53,610 --> 00:01:54,200
out here.

24
00:01:54,210 --> 00:02:00,590
So just put it at the center of this relatively out and then let's actually isolate this image view

25
00:02:00,630 --> 00:02:08,250
here inside these widgets folder and put it here at the center of this linearly out vertical.

26
00:02:08,310 --> 00:02:08,940
OK.

27
00:02:09,240 --> 00:02:15,120
And here in the properties section as you can see here selectees image view and here as you can see

28
00:02:15,420 --> 00:02:17,770
I have this layout with here.

29
00:02:17,820 --> 00:02:18,270
OK.

30
00:02:18,420 --> 00:02:24,570
So just selected and assigned the value 300 for the layout of this image view.

31
00:02:25,050 --> 00:02:32,340
And as you can see selecting a layout height and here assigned the value of three hundred for the layout

32
00:02:32,340 --> 00:02:39,240
height of this image view and then let's actually track our pattern here into this linearly out vertical.

33
00:02:39,390 --> 00:02:43,150
So inside this widgets folder as you can see I have this button here.

34
00:02:43,290 --> 00:02:46,060
Just select it and put it below this image view.

35
00:02:46,340 --> 00:02:47,020
OK.

36
00:02:47,370 --> 00:02:48,980
And double click on it.

37
00:02:48,990 --> 00:02:51,020
So for the text just typing here.

38
00:02:51,180 --> 00:02:56,890
Download an image from the Internet.

39
00:02:59,990 --> 00:03:09,390
And for the ID just type in here between download image and then press Enter key on your keyboard.

40
00:03:09,420 --> 00:03:14,960
So now the user interface as you can see here this is the user interface of my application.

41
00:03:15,210 --> 00:03:18,810
And I actually finished the design of this user interface.

42
00:03:18,840 --> 00:03:22,270
So now let's actually go back and say this main activity that I have a file here.

43
00:03:22,440 --> 00:03:26,690
So first of all let's actually declare an object of type image view.

44
00:03:26,790 --> 00:03:33,060
So Image view and the name of this image is going to be image view and then I put a semicolon at the

45
00:03:33,060 --> 00:03:34,330
end of your statement.

46
00:03:34,350 --> 00:03:36,170
So let's go back and say this activity on.

47
00:03:36,190 --> 00:03:41,400
And in that example and if I double click on this image here as you can see the idea is in his view

48
00:03:41,400 --> 00:03:42,290
right.

49
00:03:42,300 --> 00:03:47,620
So let's go inside this man activity a double file here and now it's actually declared a button.

50
00:03:47,660 --> 00:03:55,140
So button between download and then put a semi-colon at the end of your statement.

51
00:03:55,140 --> 00:04:01,260
So inside this uncreate Smurfette that's actually initialize these objects that we declared inside this

52
00:04:01,290 --> 00:04:02,420
main activity class.

53
00:04:02,580 --> 00:04:04,690
So here I can just type an image view.

54
00:04:04,950 --> 00:04:13,080
Assignment operator and then I can actually track this object to a image view object find view by ID

55
00:04:13,820 --> 00:04:19,790
are that Id dot image view and then put a semicolon at the end of your statement.

56
00:04:19,920 --> 00:04:24,210
And here let's actually initialize this PTEN download button.

57
00:04:24,210 --> 00:04:31,900
So between download assignment operator so here that actually cast this object to a button object find

58
00:04:31,940 --> 00:04:39,330
you by ID on that ID dot PTEN download and then put a semi-colon at the end of your statement.

59
00:04:39,360 --> 00:04:44,760
So here you want to actually make the spot in this and as you can see here a listener to the clicks

60
00:04:44,760 --> 00:04:45,570
of the user.

61
00:04:45,570 --> 00:04:51,210
So in say the main activity that have a file here I just need to type in bit here and download the data

62
00:04:51,210 --> 00:04:59,460
set on click listener and here inside the prentices I can just put this context in activity to this.

63
00:04:59,580 --> 00:05:01,900
OK so this is going to be the context.

64
00:05:02,010 --> 00:05:06,470
And now I need to actually implement the the view that Uncle listener interface.

65
00:05:06,540 --> 00:05:13,500
So here at the top after this extends our computer activity I just need to type in implements and here

66
00:05:13,530 --> 00:05:19,390
I need to refer to the name of my interface view that unclick listener.

67
00:05:19,550 --> 00:05:20,080
OK.

68
00:05:20,310 --> 00:05:25,090
So here we need to actually implement the abstract method that is inside this interface.

69
00:05:25,150 --> 00:05:29,750
Uncle listener so that if it is on click OK.

70
00:05:30,030 --> 00:05:32,650
So this is going to be that Meffert as you can see here.

71
00:05:32,790 --> 00:05:37,260
So here are let's actually change the name of these arguments to view.

72
00:05:37,530 --> 00:05:42,520
And if I click on this button here these are Meffert here as you can see it's going to be executed.

73
00:05:42,810 --> 00:05:46,980
So now it's actually inside the main activity class.

74
00:05:46,980 --> 00:05:49,320
Let's create an inner class.

75
00:05:49,320 --> 00:05:49,900
OK.

76
00:05:50,010 --> 00:05:55,920
So an inner class is actually like a usual class here as you can see here but and you know class is

77
00:05:55,960 --> 00:05:58,520
inside this you know this outer class here.

78
00:05:58,530 --> 00:06:04,410
For example this meant main activity class and an inner class actually actually I can access all the

79
00:06:04,410 --> 00:06:07,140
features and behaviors of the outer class.

80
00:06:07,140 --> 00:06:13,250
For example the instance variables are or the methods or other variables.

81
00:06:13,380 --> 00:06:19,550
OK so here inside is our main activity class you want to actually create another class.

82
00:06:19,560 --> 00:06:23,810
So make sure that you that you are actually inside this main activity class here.

83
00:06:23,940 --> 00:06:29,970
So this is the curly braces at this end in curly brace is going to be the ending calibers of this main

84
00:06:29,970 --> 00:06:31,750
activity class right.

85
00:06:31,800 --> 00:06:34,330
So inside is our main activity class here.

86
00:06:34,330 --> 00:06:36,890
I want to actually create an inner class.

87
00:06:36,930 --> 00:06:42,380
So first of all I need to specify the axis modifier of the Smith of this class.

88
00:06:42,390 --> 00:06:44,520
So here I can just type in private.

89
00:06:44,970 --> 00:06:53,830
OK class and the name of this class is going to be download image task.

90
00:06:53,930 --> 00:07:00,350
So the job of downloading the image from the Internet is going to be up for this class locate this class

91
00:07:00,370 --> 00:07:02,400
is going to download an image from the Internet.

92
00:07:02,630 --> 00:07:05,140
And then we can put that image on this image for you.

93
00:07:05,150 --> 00:07:05,600
OK.

94
00:07:05,720 --> 00:07:09,930
So I created a separate class for downloading an image from the Internet.

95
00:07:10,160 --> 00:07:13,320
And the name of this class is download image task.

96
00:07:13,640 --> 00:07:18,110
And this class extends OK from this scene.

97
00:07:18,890 --> 00:07:21,590
Task here has class.

98
00:07:21,590 --> 00:07:24,040
So what is this async task class.

99
00:07:24,050 --> 00:07:26,860
So let's actually open the Android documentation.

100
00:07:26,930 --> 00:07:32,720
So as you can see here if this is the android documentation you can actually put this all in your search

101
00:07:32,720 --> 00:07:38,150
for Endeavor on your web browser here developer that Android dot com and you will be guided to this

102
00:07:38,150 --> 00:07:38,720
page.

103
00:07:38,720 --> 00:07:46,910
So inside the search here inside the search bar I can search for a scene our class here a sink task

104
00:07:47,180 --> 00:07:47,670
class.

105
00:07:47,720 --> 00:07:48,240
OK.

106
00:07:49,190 --> 00:07:51,250
So this is going to be a syntax class.

107
00:07:51,440 --> 00:07:55,160
So just select this class here as you can see Android AP Olly's.

108
00:07:55,430 --> 00:07:57,710
So I have this azing test class.

109
00:07:57,710 --> 00:08:01,160
And as you can see this class is actually public abstract.

110
00:08:01,250 --> 00:08:07,670
OK so we cannot actually create an object directly from this class async task list.

111
00:08:07,940 --> 00:08:14,210
And he had as he can see this class extends from the object class and here as you can see we have some

112
00:08:14,210 --> 00:08:22,180
descriptions about this class here and it says a simple task enable is proper and easy use of the UI

113
00:08:22,250 --> 00:08:23,150
it.

114
00:08:23,600 --> 00:08:30,620
This class allows you to perform background operations and publish results on the UI for it without

115
00:08:30,620 --> 00:08:34,650
having to manipulate Fritz and or hand-wrote handlers.

116
00:08:34,940 --> 00:08:36,180
So what does this mean.

117
00:08:36,200 --> 00:08:43,370
This means that because we want to actually download an image from the Internet and that task and downloading

118
00:08:43,370 --> 00:08:46,770
an image from the end a task is actually a little bit heavy.

119
00:08:46,820 --> 00:08:47,330
OK.

120
00:08:47,540 --> 00:08:53,870
So if you want to actually put that task on the UI if read to you the user interface for it.

121
00:08:54,010 --> 00:08:58,930
Going to actually take some time and our application may freeze or actually crash.

122
00:08:59,150 --> 00:09:04,160
So because downloading an image from the internet is a truly is a heavy task.

123
00:09:04,310 --> 00:09:07,950
We need to put that operation put that task in the background.

124
00:09:08,020 --> 00:09:13,500
OK a background for it so that it's not going to actually block the user interface.

125
00:09:13,520 --> 00:09:20,270
Ok so that the user can actually interact with the user interface while the emet is actually downloading

126
00:09:20,780 --> 00:09:22,160
downloaded from the Internet.

127
00:09:22,220 --> 00:09:22,620
OK.

128
00:09:22,700 --> 00:09:26,560
And the user can actually interact with that application.

129
00:09:26,600 --> 00:09:28,640
So that's the job of this class.

130
00:09:28,640 --> 00:09:37,040
This class allows us to actually do something and put the operation of downloading the image from the

131
00:09:37,040 --> 00:09:39,750
internet in the background for it not the UI for it.

132
00:09:39,770 --> 00:09:40,350
OK.

133
00:09:40,400 --> 00:09:47,210
And after the image is downloaded from the Internet we have a method and that if it is post execute

134
00:09:47,690 --> 00:09:48,440
we have an.

135
00:09:48,470 --> 00:09:53,540
And we can actually put that image which is downloaded from the Internet and we can put that image on

136
00:09:53,540 --> 00:09:57,960
the UI thread on the user interface for it and we can show that image to the user.

137
00:09:58,040 --> 00:09:59,700
So hopefully that makes sense.

