1
00:00:00,360 --> 00:00:02,280
Hello this is Mortaza Cordy.

2
00:00:02,430 --> 00:00:09,750
And in this story all your way to learn how to drag or move our floating budget or our floating view

3
00:00:10,050 --> 00:00:13,510
on the screen by using the user's touch.

4
00:00:13,530 --> 00:00:19,620
So in order to do that first of all we need to access the root container or the root view.

5
00:00:19,680 --> 00:00:22,190
So by root view I am actually referring.

6
00:00:22,290 --> 00:00:27,500
Let's go into this flawed underlying view Underland lay out that XML file here.

7
00:00:28,680 --> 00:00:31,310
And now you can see this route view here.

8
00:00:31,320 --> 00:00:37,740
This relatively out which is playing the role of a root container that contains the collapsed state

9
00:00:37,770 --> 00:00:45,810
or the collapsed view and the expanded view is that the idea of this relatively out is this one root

10
00:00:45,900 --> 00:00:47,320
Underland view.

11
00:00:47,400 --> 00:00:50,170
So let's go back into this Flutey and view.

12
00:00:50,160 --> 00:00:58,170
So we start justified and here inside this class you can see that we have some instances valuables.

13
00:00:58,200 --> 00:01:00,630
Let's create another instance variable.

14
00:01:00,750 --> 00:01:08,990
It is going to be of type view and its name is going to be root view semicolon.

15
00:01:09,470 --> 00:01:15,860
So let's actually declare all of our instance variables as private so put the private keyword before

16
00:01:15,860 --> 00:01:20,160
these instance variables because it's a good programming practice to do that.

17
00:01:23,600 --> 00:01:27,780
Now we need to go inside the uncreate benefit.

18
00:01:28,040 --> 00:01:34,010
And if you're going to initialize our route to view Silis scroll down here and before adding curly brace

19
00:01:34,400 --> 00:01:35,950
of this on Christmas.

20
00:01:36,120 --> 00:01:44,070
And we to refer to this Roots view assignment operator and I can say find excuse me Vinita repetoire

21
00:01:44,070 --> 00:01:54,060
which is first floating bitted that find view by ID because here we are actually accessing a view and

22
00:01:54,060 --> 00:01:58,390
we want to assign this view to this read the view which is actually of type view.

23
00:01:58,470 --> 00:02:04,450
We don't have to cast this to any other types because we are directly accessing of you.

24
00:02:04,470 --> 00:02:12,670
So if you can say find by ID inside a Apprentice's I'm going to say are that Id dot root underline if

25
00:02:12,770 --> 00:02:22,110
you semicolon Now that be initialized this root view I can create an on Poche listener for the this

26
00:02:22,150 --> 00:02:22,390
view.

27
00:02:22,400 --> 00:02:31,730
So I went to say root view that sits on touch listener now only to pass the context because we do not

28
00:02:31,730 --> 00:02:36,920
want to actually create an anonymous inner class since insight is unclear if it is going to be too much

29
00:02:36,920 --> 00:02:43,940
crowded and it's not a good programming practice eboy that everything should be encapsulated any and

30
00:02:44,030 --> 00:02:50,210
everything should be done in its own methods or functions so set on patches and or inside Apprentice's.

31
00:02:50,210 --> 00:02:55,020
I am going to say the context that we need to pass the context the context is disserve is floating view

32
00:02:55,020 --> 00:02:58,300
so Service that this.

33
00:02:58,420 --> 00:02:59,410
Now we have an error.

34
00:02:59,410 --> 00:03:04,110
It says that we have to now that we passed this context to the set and to each listener.

35
00:03:04,510 --> 00:03:10,650
And we are saying that this floating View service is going to be the listener for the touch of the user.

36
00:03:10,810 --> 00:03:20,200
This fluty view service that java file this class now must implement the unattach listener interface

37
00:03:20,290 --> 00:03:23,650
and override the untouched method.

38
00:03:23,680 --> 00:03:26,070
So let's scroll to the top here.

39
00:03:26,470 --> 00:03:33,380
It says publish class fluting View service extends service class implements view that unclick listener

40
00:03:33,400 --> 00:03:34,190
interface.

41
00:03:34,240 --> 00:03:40,120
So we now need to implement another interface so people are coming here and now we're going to see view

42
00:03:40,480 --> 00:03:42,580
that on capital or.

43
00:03:42,660 --> 00:03:47,140
Okay touch on that listener.

44
00:03:47,340 --> 00:03:48,120
That's it.

45
00:03:48,160 --> 00:03:53,210
Now we need to override the on touch method inside our class.

46
00:03:53,350 --> 00:03:54,620
So let's scroll down here.

47
00:03:54,640 --> 00:03:56,990
And after this and click on it.

48
00:03:57,130 --> 00:04:01,810
So make sure that you are actually still inside this class.

49
00:04:02,260 --> 00:04:10,660
And after the end in curly brace of our unclick listener uncle Mefford here and before the anti-cruelty

50
00:04:10,790 --> 00:04:17,980
place of the class the fluting you said with class if you're going to see on Poche now the autocomplete

51
00:04:18,000 --> 00:04:20,820
feature helped me to override this method.

52
00:04:20,910 --> 00:04:22,330
So here it is on my phone.

53
00:04:22,470 --> 00:04:23,560
So it is written false.

54
00:04:23,560 --> 00:04:25,420
Let's delete this return false.

55
00:04:25,430 --> 00:04:27,840
Here let's go inside this method.

56
00:04:27,840 --> 00:04:32,160
Notice that the Smurfette needs to return a value of a boolean.

57
00:04:32,310 --> 00:04:36,440
So I think that's enough for this story or indirect tutorial.

58
00:04:36,540 --> 00:04:39,240
We're going to implement this on touch Meffert.

59
00:04:39,630 --> 00:04:41,790
So thank you very much for watching.

60
00:04:42,120 --> 00:04:44,960
And I look forward to seeing you in the next story.

