droidcon Online 2020
Tweet |
droidcon News
Jetpacks For You And I
By
Marcos Plancona
droidcon Online 2020
Jetpack Series Part 1 of 3
Transcript
English
00:00
I you should all be seeing my my Andres
00:05
video screen here I am just gonna flick
00:07
to my slides because that's what you
00:09
want to see first
00:11
so yeah hello everyone my name is Marcus
00:14
mokona and I serve the developer
00:18
evangelism team at Twilio I have been a
00:22
developer I have been a hundred
00:24
developer for many many years I you know
00:27
I know you know where to find me on the
00:29
Internet
00:29
but I just wanted to make sure there's
00:31
some information about me in here also
00:33
some information about what we do to
00:34
lose a company I work for
00:35
if you don't know Twilio Twilio is a
00:38
communications platform that helps
00:41
developers like you and i to add
00:44
communications into your applications
00:46
such as like text messages chat video
00:48
and anything to do with communications
00:53
here so you've probably used William in
00:55
the past that you don't know if you've
00:56
used something like lyft or uber or
00:58
Airbnb for example it's all using
01:01
Twitter on the back end well that's
01:03
enough about video I wanted to also let
01:06
you know I am an Android EEE and I am
01:09
very very passionate about this thing
01:10
called jetpack which is what I'm gonna
01:14
be telling you about today but I want to
01:17
start like very very slow here and I
01:19
want to start by telling you a story ok
01:21
so this is the story of the year 2017
01:26
and because we're talking about 2017 I
01:30
kind of want to change the slides and
01:31
say this was a long long time ago 2017
01:35
because they're talking about tech years
01:36
ok back in 2017 there was here I was
01:41
writing code just like this so I was
01:44
getting my instance fades just like this
01:47
and I imagine that if I could asked for
01:50
some of you to like raise your hand you
01:52
would say yeah I I see big things this
01:54
way the other thing that I was doing is
01:57
I was also building camera applications
02:00
back then and again if I could ask you
02:03
to raise your hands I'm sure you would
02:05
say yeah I'm building camera
02:06
applications or I used to build some
02:08
camera applications and and like just it
02:12
just kind of gets
02:14
I when it comes to camera applications
02:17
for example I think that you've all
02:20
you've all seen something like this okay
02:23
because building your camera application
02:24
is super easy right now well it used to
02:27
be like super easy it's easier now but
02:30
it used to be super easy because
02:31
building a camera application basically
02:33
means well you create the camera manager
02:35
then you set up the camera ID their new
02:37
sets at the camera but then you set the
02:39
transformation matrix a text review and
02:41
then you start a background threads then
02:43
you open a connection to the camera with
02:44
a given ID and then you set up the image
02:46
buffer size and sex review then you
02:48
start the camera module and then you
02:50
start the camera preview
02:53
that's easy right does anyone else here
02:57
getting my own Society yeah I'm sure if
02:59
you could raise your hand your words
03:00
I'm sure if you could you know doing
03:02
some conference water right now you
03:04
would that's the kind of thing I used to
03:07
deal with okay and then came the ye olde
03:11
2017 so that's you know talking about
03:14
old markers they're going on 2017 when
03:17
everything changed because better Royal
03:20
2017 they announced the architecture
03:23
components so back then architecture
03:25
components was the name of it which
03:27
later just came to be part of the
03:30
jetpack the jetpack funding and I
03:34
remember listening to my clearing back
03:36
then and my time and talks like
03:39
specifically about jetpack sector
03:42
components but he used terms like
03:45
scalability and use terms like life
03:47
cycles and or ends and backwards
03:50
compatibility and like especially on the
03:53
backwards compatibility I remember back
03:56
there and being kinda like this like I
04:01
don't know about this and and so
04:04
basically I did what most people did
04:06
which is nothing I remained skeptical
04:10
and I was like I am NOT gonna adopt this
04:12
thing so good why old 2018 came about
04:15
and 2018 just absolutely changed
04:19
everything for me
04:20
because at Google i/o 2018 they
04:22
announced what be jet tech components
04:25
are like that you know what is what has
04:26
included components and it was really
04:29
interesting because you had stuff like
04:31
architecture components had behavior you
04:33
had UI in foundation and and the premise
04:37
was you could standardize Android
04:39
development so if you use emojis on your
04:41
application for example here's a way for
04:44
you to do emojis if you use fragments
04:45
there's a way for you to do it
04:47
navigation super interesting cuz like
04:49
everyone sorts of like does navigation a
04:51
different way paging and really for
04:53
databases and it's like wow there's
04:55
suddenly there's like one way of doing
04:58
things and I know this if Android pack
05:01
is a new thing for you and and it wasn't
05:03
your thing for me as well I
05:07
you want to start slowly here but you
05:10
not only want to start slowly but today
05:13
if you're not a jet pack fan I am gonna
05:16
turn you into a jet pack fine
05:20
so we're gonna be changing this let's
05:23
start with the basics because I think if
05:25
you've been an Android developer for
05:27
even if you've been an Android developer
05:29
for a week you will have seen something
05:31
like this which is an applications
05:33
lifecycle so we look at how this is this
05:37
is a look of how life cycles actually
05:39
working on tries again you have seen
05:42
this before but if you remember in my
05:44
previous slides we talked about the same
05:48
instance so let's just go back to my
05:52
previous slide where we talked about say
05:54
the sades instance let's say you have an
05:57
application and your your application
06:01
looks like this so you had received
06:03
instance but let's make it a bit more
06:06
real so instead of like saving games
06:09
fades will make it a bit more real and
06:11
we'll turn that into a number generator
06:15
application because that's the kind of
06:17
thing you want to build right if you
06:18
want to go into the Play Store this is
06:20
where the money is you create a number
06:22
generator application and also you know
06:24
notice that it generates a number
06:26
between 1 and 42 which you know there's
06:29
all the numbers you want now we have
06:33
this application we have the methods on
06:35
create and usually if I if I had a if I
06:39
had a regular audience I would say so
06:41
what happens when I turn my phone and
06:44
there's always gonna be someone clever
06:47
in the audience who say well when it's
06:48
on your phone that number changes and
06:51
some people go removing cursor from the
06:56
screen yeah absolutely
06:58
so some people go oh like the number
07:01
changes and and the reason the number
07:03
change is this
07:05
this is expected okay because every
07:08
single time you change the phone this is
07:11
called
07:11
a configuration change so you get your
07:14
phone you've got your phone on your
07:16
hands you get your phone your turn and
07:17
that's a configuration change so every
07:19
single time this would
07:20
it's a new number for you that is
07:22
between one and forty two so already the
07:26
behavior here is slightly different than
07:29
one would expect because one would
07:30
expect okay so when it done my phone
07:31
nothing changes I still get the same
07:33
number but no configuration changes
07:36
calls your phone to change that and
07:39
obviously I will say here like I'll
07:41
leave a caveat here which is I could
07:44
very easily just have done some like
07:46
shenanigans with my codes it says no I'm
07:47
gonna say that fades and then if you
07:49
turn your phone like the number doesn't
07:52
change but I will I will continue and
07:54
say that what is what I've been using
07:58
here is the Safety's and state and for
08:00
the specific case of same things and
08:03
stays the amount of dates it should be
08:04
kept small because the system process
08:06
needs to hold on to the the provider
08:09
data for as long as the user can ever
08:11
navigate back to the activity so let's
08:13
say you had an activity in your head
08:14
like a bunch of navigation there when
08:16
the user returns you still want to keep
08:19
that same number in there so all this is
08:20
kind of like bundled inside the memory
08:24
but there is a recommendation and this
08:27
is a recommendation by Google which says
08:29
you can only store 50k of data so you
08:34
can you can absolutely go over 50k
08:36
Abeyta
08:37
but that's not recommended so if you if
08:40
you want phone google and say hey i'm
08:43
storing 60 k updates and my applications
08:45
crashing or like it's not keeping stays
08:47
mobile say well you're on your own I'm
08:48
sorry because a recommendation is 50 K
08:51
of data now let's let's look at a
08:54
different demo here because hey like
08:57
number generators are great like we all
08:59
love number generators but let's look at
09:01
a real demo and the reason I want to
09:03
show you this real demo is I want to
09:06
show you why this stuff is important so
09:10
I'm gonna bring my cursor back to my
09:12
screen and I'm gonna show some code that
09:15
I've wrote that I've written in here so
09:17
what we have in here is we have a very
09:20
very simple applications for an activity
09:22
it's got a class this is a data class
09:24
with some results and what it does is it
09:27
goes into an external API that's the
09:30
Pokemon API and it gets
09:32
Pokemon information
09:34
I've got my clients in here and what I'm
09:37
doing is like I'm actually debugging
09:39
everything okay so I want to make sure
09:41
that I can see everything my application
09:43
does and to show you I'm not cheating I
09:45
am gonna show you my phone in here which
09:48
hopefully we can get in the right light
09:49
and I am gonna relaunch this application
09:53
and I wanted to see what happens when I
09:56
relaunch so basically it just goes into
09:58
the internet it just goes into pokeo API
10:01
Co and it downloads some data then it
10:04
gets that data and it just pushes in my
10:07
phone however what happens here is you
10:10
will notice that when I turn my phone
10:12
that's a figuration change something
10:14
happens and yeah so it just keeps on
10:18
making that same EVP request over and
10:21
over again every single time okay and
10:23
the problem with making the HTTP
10:25
requests over and over again every
10:26
single time is like you are actually
10:27
using real data in here like you are
10:30
asking your whoever your your customers
10:33
are whoever the people like your users
10:35
are you are actually using real data in
10:38
here and and that's a problem now let's
10:42
go back so this is this is what the
10:44
problem is now one change that we can
10:46
make into this application is
10:52
we can use something called life cycles
10:54
and life cycles is a way for you to
10:57
fetch some data so I have a load Pokemon
11:01
methods in here I can fetch some data
11:03
and that data gets saved into my
11:07
applications memory but not into the
11:10
unsaved instance so I'm using a life
11:13
cycle class in here I have a add a
11:16
function into my application that uses
11:18
live data so whenever anything changes
11:22
in my application life data just gets
11:24
just get synonyms from here say hey and
11:27
I just let you know there's been a
11:28
change in data so we'll pay attention
11:31
specifically to the live data here and
11:34
the list that comes inside our life data
11:37
now I obviously appreciate some people
11:40
may not have used live data before so
11:42
let me just explain what live data is
11:45
very quickly for you so you have your UI
11:48
in here so this is this is the
11:51
application example I just used and then
11:53
you have your live data object that
11:56
holds the data for you so all the data
11:59
that you want to show on the screen is
12:01
inside the live data object so you can
12:03
think about it like if you wanted to
12:04
make a an analogy here you can say
12:07
everything that is on live dates is like
12:09
life dates is almost like my database
12:10
okay so you have some data that gets
12:12
stored in there and the UI is always
12:16
observing live data so the UI is
12:18
basically saying hey live data if
12:20
there's a change I want to know about it
12:21
I want to get an update so in this case
12:24
I have an API which is the Polti API
12:27
that I'm using and whenever there's a
12:30
change from the API life there's old
12:32
French those changes live data gets
12:36
updated and live dates that would then
12:38
tell my application that there's been a
12:40
change my application would then react
12:43
to that change and do whatever needs to
12:46
be done so in this case you know some
12:48
some road Pikachu just got into the
12:51
polky API and just stick over the whole
12:53
thing and everyone is a Pikachu now
12:55
regardless of like which Pokemon they up
12:58
and and that's how life data works so
13:01
but now when you look at this
13:03
application here you
13:04
probably thinking oh okay so what if I
13:07
what if I wanted to be able to click on
13:10
on that Pikachu and see some details for
13:15
example like how can I do that so that's
13:18
where navigation components come about
13:21
so navigation components are a way for
13:24
you to basically do what the name says
13:27
you can do navigation using navigation
13:29
component so you can click on one of the
13:31
items and you can navigate between
13:32
Springs now the beauty of navigation is
13:36
it basically handles all the data going
13:38
forwards and the dates are coming back
13:40
to you
13:41
so with navigation you don't need to
13:44
keep control that data because the
13:46
navigation components do that for you
13:48
the way navigation components this is a
13:52
this is what a regular navigation would
13:55
look like so in a simple application I
13:58
you know I very much like the idea of
14:00
like using a standardized way like
14:02
that's that's one way and it can those
14:04
navigation components handle the entire
14:06
back stack for you so when I user
14:09
navigates back in for for example the
14:11
application just keeps track of
14:13
everything our pokemon application is a
14:17
perfect example of something like this
14:20
because you could very easily just use
14:24
the navigation components along with
14:27
fragments to build something like a a
14:30
single activity application so instead
14:34
of having all the activities as you have
14:36
in here if they have one activity a
14:38
single activity application and you
14:40
would use just like fragments to switch
14:43
things around now navigation is a huge
14:46
topic like there's a lot with navigation
14:49
and one video will suggest watching like
14:52
if you haven't done anything to do with
14:54
navigation or specifically single
14:56
activity applications there's a good
14:59
supply and lake and this so this is when
15:01
I had the pleasure to see back in 2018
15:03
Android that summit it's on YouTube and
15:06
there's a link on my slides I will be
15:08
publishing those lives later as well so
15:10
you don't need to be copying these links
15:13
from here now navigation also has
15:16
something that is a
15:18
in my opinion is like the is the biggest
15:20
selling point for me because what you
15:24
can do with navigation and I'll just
15:26
I'll just kind of give an example yeah I
15:29
very often go into Stack Overflow and I
15:33
look at like what are the Android
15:36
developers asking the most like what are
15:38
the questions Android developers are
15:39
asking the most and I like doing that is
15:42
because it helps me with like grey in my
15:44
own sense like if I want to go and write
15:45
some people are blog for example you
15:48
know it's it's cool to write about
15:49
something new but it's also cool to go
15:51
and try and solve like answers some
15:53
people's questions so I did that very
15:55
often and one that kind of like got my
15:58
attention here is looking at Stack
16:00
Overflow if you look at the tab I'm
16:02
looking at the frequent tab
16:07
the question is how do I pass days
16:09
between activities in an androids
16:12
application and I went around and I
16:15
clicked on this and I noticed like it's
16:17
got a lot of uploads it's got a lot of
16:19
like answers as well there doesn't seem
16:21
to be an answer that is like the right
16:23
and so like I don't think there was one
16:25
when I looked but the most interesting
16:28
thing here is there are a lot of pages
16:33
and there are a lot of ways to actually
16:36
skin a cat in here like you can you can
16:38
do navigation in so many different ways
16:42
and like people do them in so many
16:44
different ways and I think this is the
16:45
point of like using navigation
16:47
components okay because and and again
16:50
this whole like scrolling was just one
16:52
page this is three pages of this okay so
16:54
I can even I can even run this thing
16:57
back for you in case you want to see
16:59
that again it's quite it's quite pretty
17:01
to look at but the point of like using
17:04
navigation components is it's one way of
17:08
doing things and it's one way that your
17:09
entire team will know how to do and
17:11
that's something I really enjoy because
17:14
in a lot of this case and I looked and I
17:18
looked at a lot of these answers here in
17:19
a lot of these cases there's no right or
17:21
wrong like some people just implement
17:23
things in different way but there's not
17:25
really oh yeah this is the perfect way
17:27
of doing that's definitely the way I've
17:28
done it but there's no right or wrong in
17:31
the way navigation specifically passing
17:34
arguments between between navigation so
17:37
this is a this is opposed by Lila
17:39
Fujiwara who works for Google and the
17:43
way Lila described navigation safe args
17:47
like passing safe arguments in
17:48
navigation is navigation components
17:49
generates classes based off your
17:51
navigation graph to ensure type safe
17:53
access to arguments for destinations in
17:56
actions so this is really cool because
17:59
everything that you pass between one
18:02
activity to the other using navigation
18:05
components if you use safe forms you're
18:07
basically saying yeah this is all type
18:09
safe which is great and implementing
18:12
this is very very easy
18:13
so in these things I have my I have my
18:16
navigation graph in here and I create an
18:18
argument which is the arguments I want
18:20
and I can even have a default value so
18:23
in this days in plastic now and I'm
18:24
saying this is an argumentative strain
18:26
so on the other sides if something tries
18:28
and reads Pennines
18:29
for example that's obviously not going
18:30
to work so it's making its making its
18:33
type safe which is which is super cool
18:37
then all my on my activity so this is
18:40
the button like if I had an on click so
18:43
when you rebuild your project you will
18:45
now have a directions class which I can
18:48
get next on an instance off and then in
18:51
this case what I'm doing is I'm updates
18:52
in the name of my Bulbasaur and I think
18:55
all navigates passing information so
18:57
again just using a single activity
18:59
application I can just go in a date the
19:01
name of my bubble sort and then
19:05
obviously on the other sides I just get
19:06
that like when my field gets created I
19:09
just get the name now if you're in your
19:12
receiving so that's your receiving
19:14
destination now here's how that would
19:19
look like so I have Bulbasaur in here
19:22
and when I click when I click on
19:24
Bulbasaur it turns that into cute
19:26
Bulbasaur so this is just like passing a
19:28
string okay it's not changing anything
19:31
in a database it's not doing anything
19:33
special
19:33
it's just fasting on a string now when
19:38
we're when we're passing a string with
19:39
safeguards its grace like if you want to
19:41
save stuff to a database but we haven't
19:43
done that yet so what if we wanted to
19:46
persist is like what if I wanted to
19:47
really rename my Bulbasaur so everywhere
19:51
when I look on my screen I see cute
19:54
Bulbasaur for example like what could I
19:55
do
19:56
if I wanted to do that so this is where
19:59
this is where room comes in so there's a
20:02
library for that tip and the way remarks
20:05
is room is a persistence library that
20:07
provides an abstraction layer for sicko
20:09
lights so if you've ever done anything
20:11
with sicko light you will know what a
20:15
pain it is like you will know what a
20:16
pain it is to actually maintain an
20:18
application that uses sick light just
20:20
natively I have used things in the past
20:23
like realm for example Rome was actually
20:27
pretty cool but I do think
20:28
Rome is is kind of in my opinion is is
20:31
the thing I've been using the most
20:32
because he could kind of
20:34
gets the best of realm and it gets the
20:35
best of like Jesse's in psycho lights
20:37
and in my opinion that's kind of like
20:41
the way I always go with now if I again
20:45
there are many many ways of doing
20:47
database interactions of sure that if I
20:49
go into Stack Overflow there's like a
20:51
few different ways of using psycho light
20:54
but the way you start using is we
20:56
already have a Pokemon data class as I
20:59
show during the code previously and it
21:02
looked it looks something like this I
21:04
have my name for Pokemon and I have a
21:06
URL what I then do is I create an entity
21:11
so I wrap this on an entity and I give
21:14
it a name so I can I think all my table
21:16
whatever so I'm calling my table Pokemon
21:18
so I haven't really made any changes to
21:21
my data class and I'm setting a primary
21:24
key like I'm giving it a primary key and
21:25
I'm saying my primary key it also
21:27
generates so whenever I add your Pokemon
21:29
it just gets a new it just gets in your
21:31
primary key so not doing anything
21:34
special in here but we can also remain
21:37
columns in here like if we wanted to if
21:39
when it mean to be something else or one
21:41
of names you like Pokemon name for
21:43
example we could also do that remember
21:45
I'm getting all this data from an API so
21:47
I obviously don't get things like ninety
21:49
but if the API had some like cryptic
21:51
names for example I could just change
21:53
that to be called something that is more
21:55
useful to me then I create a data access
21:60
object so this is just an interface and
22:02
here is where I can go in just the
22:05
Claire all of the the things on one of
22:07
the all the actions I want to do so I
22:08
have an excerpt I have an update I have
22:10
a query where it just go and select by
22:12
name for example and and the really
22:15
really cool thing about this like the
22:16
really cool thing about using this with
22:18
Android studio is they are all checked
22:21
at compile time and and I find this
22:25
really interesting so what I mean by
22:27
text by compile time is if I if I have a
22:30
typo on my codes for example I'm gonna
22:32
get in there that looks like this so
22:33
cannot resolve symbol Pokemon so it's
22:36
all it's all checked in compile time
22:38
which I find super interesting and then
22:42
if I fix this then the error kind of
22:44
disappears so this is like what under
22:46
Cydia does for you out
22:47
the box like you don't need to do
22:49
anything is obviously using the room
22:52
library this is 100 study of those out
22:55
of box then the next thing I need to do
22:57
is I need to actually set up my my
22:60
database so I need to implement my
23:02
database so I'm saying where my entities
23:04
are obviously I can have multiple
23:05
entities I am giving this a version so
23:08
if I want to go and bump the version I
23:10
can just bump that number and I said no
23:12
claims database and I say I'm using
23:15
Pokemon 0
23:17
I could have most fold 0 so like
23:19
multiple they type subjects in here and
23:22
then the last thing I need to do is I
23:24
just have a repository I'm using
23:26
recovery in this case and I'm saying
23:28
here's what my database name is Pokemon
23:30
Z B remember we names the table in the
23:33
past now you name the database
23:36
and I am just initializing my Pokemon
23:40
database and I'm saying database builder
23:42
so just like really initializing yet and
23:45
then I can start doing my chorus let
23:52
yeah okay so and this is this is my
23:55
database initializing initialization but
23:58
I wanted to I wanted to show you like
23:60
what this looks like in code as well so
24:03
I'm gonna come out of my presentation
24:05
here and I'm gonna show you some of my
24:07
code I'm gonna switch to rain
24:14
and this is like the amounts of changes
24:18
I've made on this application okay so
24:19
obviously I've created my zero here
24:22
my dates access object I have a methods
24:25
for each one of the things so I have a
24:26
methods for insert I have a method for
24:30
update I have a delete and I have a
24:32
select by name
24:34
I have a repulsor here my repository is
24:36
basically the thing that you've seen on
24:38
on the on the slides I'm making sure
24:42
things are async and everything and then
24:44
I have my database in so this is not
24:48
much different from what it was I can
24:51
now go and run this application and when
24:56
it finishes compiling hopefully I'll be
24:59
able to show you a little bit of like
25:01
how this is working right now
25:07
let me try and bring this here so I have
25:12
my Bulbasaur and what I can there is I
25:16
can from the application I can do things
25:19
like I'm gonna make this like pet and
25:22
then the Bulbasaur becomes my pet so now
25:25
I can go back I can go look at Ibis or
25:27
for examples or is the obviously not my
25:29
pet but if I go back to Bulbasaur I can
25:32
see Bulbasaur it's my pet and the way
25:35
I'm doing is the way I'm doing this I'm
25:37
just adding Bulbasaur into my database
25:40
and I'm saying I'm setting a boolean
25:43
flag to say Bulbasaur is my pet just
25:47
very simple as that so I'm not doing
25:49
anything special here but it's kind of
25:51
cool that I can that I can get database
25:54
like going on on my application without
25:57
actually having to write too much gold
25:60
in fact like I usually do this I usually
26:04
do this Bretton
26:05
usually when I did this presentation I
26:07
actually life codes this farce because
26:09
it's it's so simple but like an interest
26:11
of time in like giving people some
26:14
giving people some time for questions I
26:16
just don't wanna I just don't want to
26:18
take up all the time now I'll go back
26:21
into my slides here so we looked at that
26:23
demo
26:26
now if you wanna if you want to know
26:29
more there are gonna be a couple more
26:32
things going on today so we obviously
26:36
have camera X camera X's I'll say it's
26:40
probably my favorite API in jetpack I I
26:46
had a lot of fun building things the
26:48
camera X I wrote a blog post about it so
26:50
you can check it out to my blog and
26:52
there's also become a composer so I
26:54
purposely didn't mention those things in
26:56
my application even though camera X is
26:58
probably my favorite librarian jetpack I
26:60
didn't mention those things as I knew
27:02
Brian ends idea we're gonna talk about
27:05
those see things so Brian he's talking
27:07
about become a composer Divya is talking
27:09
about camera X composer is super super
27:12
interesting it's still a bit fiddly as
27:15
you will see today but it's super super
27:17
interesting and I think I'm Brian would
27:18
do a good job explaining that with that
27:22
like I said I will be posting those
27:24
lights later I'll put it on whatever
27:26
hashtag Greg tells me to cut on Twitter
27:30
you can find me on Twitter on Marcus
27:32
patron on Twitter all this code is also
27:35
github it's gonna be on my github
27:37
account and you can check a lot of my
27:40
sorts of like answers to Stack Overflow
27:42
questions like unified answers or even
27:46
like a lot of the the open source that I
27:48
write you can find out become a doctor
27:50
dr. K which is my website with that I
27:53
want to thank you and I want to thank
27:55
drug con very much for having me I have
27:58
been Marcus back on it's a pleasure to
27:59
be here Thank You Marcos thanks so much
28:02
fantastic presentation really appreciate
28:04
you being here
28:05
we have Q&A I'm gonna have Willie
28:08
changed himself to the presenter so
28:10
everyone can see the top questions that
28:12
were voted on will give you ten minutes
28:14
to answer them and I'll bring everyone
28:17
back in and introduce Divya after that
28:21
cool
28:24
so feel free to fire away Marcus anytime
28:28
cool all right so I am looking at the
28:32
first question with mostly modular
28:34
architecture work in each module at
28:38
least one activity on the rise isn't a
28:41
single I'm not sure I really understand
28:48
yeah with multi modular architecture
28:51
where each module equals okay so where
28:54
each module equals at least one activity
28:57
on the right is the single activity on
29:02
updated I'm not sure I understand this
29:06
question if there's anyone else who
29:09
wants to help me answer the question
29:10
because I'm not sure I even understand
29:12
it I'm gonna move on to the next
29:15
question and come back to this so the
29:17
next question is is there any
29:19
performance difference between is there
29:21
any performance differences between
29:22
implementing a map with multiple
29:24
activities and implementing an app with
29:26
one activity and multiple fragments I
29:28
haven't seen anything like this
29:31
using multiple fragments in my in my my
29:36
opinion as developer using multiple
29:38
fragments this complicates your code a
29:42
little bit but I haven't seen any kind
29:46
of like performance differences what I
29:48
would say is if your application is very
29:50
complex you probably don't want to make
29:52
it a single activity application and
29:54
just keep on like spawning new fragments
29:57
but if you're if you have like an
29:59
application like the Pokemon application
30:02
for example that I just showed you that
30:03
is the perfect contender for like just
30:06
using nodes for fragments because you
30:07
don't have many of them I'll say if you
30:09
have many fragments then you just need
30:12
to be careful that to the next question
30:17
in and the questions keep on like
30:19
popping around which is really exciting
30:21
in a mostly modular project what's the
30:24
best design using navigation jetpack to
30:29
go from fragments in module a to
30:31
fragment in module B
30:36
in a multi module projects was the best
30:39
design using navigation don't Peck I'm
30:47
not sure I get this I know this is I
30:49
know we're talking about a multi module
30:51
but I'm not sure I get the question
30:55
I don't I don't think you do anything
30:57
different in here like I work with some
31:01
applications that are mostly module and
31:03
I've been using fragments on those
31:04
applications so I don't think you'd do
31:07
anything different in here other than
31:08
just like injecting the the fragment I
31:13
don't think there's anything different
31:17
that you need to do unless I didn't
31:21
quite get the question I have answered
31:25
this one already now the next question
31:30
I'm gonna go to if I'm using the same
31:33
fragment in different Navigation graphs
31:36
I need to update questions as it appears
31:42
[Music]
31:45
what is the best way to map Nessa Jason
31:48
into a room database
31:50
okay I'm gonna answer that because I I'm
31:54
gonna answer that because it's the one I
31:56
got to read what is the way to map what
31:59
you do is I usually just try and map the
32:02
Jason into Data class I get a I get my
32:05
data class and I map it that way so
32:08
Jason entities into you have a lot of
32:12
like generators of usually like what I
32:15
did last time I had today this was
32:17
obvious that generator that basically
32:19
takes my Jason turns into like a POJO
32:23
and I just pasted that into you into
32:27
Andres video and there's three or
32:28
obviously just translated that
32:34
oh there's someone second script under
32:36
its 300 bees translated that to Kotlin
32:38
and then I just turned that into a day
32:39
to class and that's the easiest way you
32:41
can do it like it is
32:43
I'd say if there's like 90% of the job
32:45
for you so yeah that's that's how I do
32:50
it
32:51
do you think it's the best practice to
32:52
use activity per feet Jesus I'll move to
32:57
the browser okay because I'm looking at
32:58
the I'm looking at screen here big tips
33:00
on popping so I'll move to the browser
33:02
yeah
33:14
and I'm just opening here is there is a
33:24
you prefer using navigation say fogs
33:26
instead of parcel eyes data class in
33:29
Kotlin close the new interns fragment
33:33
new instance I'll say no so that's also
33:38
the I'm gonna read the question again is
33:40
there are reasons we prefer using
33:41
navigation safe args instead of partial
33:44
eyes data class teen Kotlin plus the new
33:47
intent fragments new instance parsing
33:50
I'll say no III think that's more of a
33:52
preference I if I'm using if I'm using
33:55
jetpack which is what I tend to use
33:57
right now whenever I use it I just use
33:59
safe args
33:60
now I don't think there's a right or
34:01
wrong in here unless I didn't get the
34:04
question rise but I don't think there's
34:05
a right or wrong using using sorts of
34:07
like Newton's we fragment new instance
34:10
parts and is almost like a you kind of
34:12
like go it's almost like you're going
34:13
under the hood on the on the navigation
34:16
safeguard so I all say this is probably
34:18
more of a preference thing than anything
34:20
else all right
34:23
Marcus we have time for we have time for
34:25
one more question so that's possibly two
34:29
but let's try to get to more questions
34:31
and then okay to the next one and I'm
34:36
looking at my browser now because
34:37
they're like just looking at the screen
34:39
here like the questions is just keep on
34:41
changing
34:43
what about they turbine zine is it
34:46
passive jetpack if used correctly and
34:48
with only two doesn't it result in
34:52
untestable code they surprisingly
34:54
doesn't it doesn't results in accessible
34:56
code no beta binding is you can use it
35:02
as farce of jetpack yes I use data
35:05
binding a lot I'm not sure it results in
35:09
untestable calls I think
35:11
I you know I think most of the
35:15
impossible cause I've seen is like
35:16
written by developers such as ceasing
35:19
functionality so I would say I don't
35:22
think it results in untestable goals
35:23
unless you you had like a different
35:26
experience like I never really had an
35:27
experience where I'm a fuse databinding
35:30
and I used a turbines Nia laughs and I
35:31
never had an experience where like I can
35:34
test all my code because a bit cold yes
35:44
there's one question here that says on
35:47
asynctasks
35:48
deprecated yes async task is deprecated
35:51
as I was talking about it today like
35:53
looking at my goals I was like yeah I
35:55
should have changed that yes async tasks
35:57
our deprecated so you should you should
35:59
move away from using async tasks there
36:04
are definitely new different things that
36:06
you can use I actually wrote an entire
36:08
blog post about this so if you want to
36:10
know what you can what you can using
36:14
stands I wrote a blog post about called
36:17
that UK where I talk about async tasks
36:20
in their deprecation so you are right
36:22
mr. anonymous async tasks are deprecated
36:26
Marcus thanks so much thanks also for
36:29
playing
36:30
question roulette with us you know so
36:35
this is a process we're gonna refine in
36:38
the next but hopefully we'll be cycling
36:40
through the always the top three vote
36:43
and on questions will appear on the
36:44
screen the latest question will keep
36:46
appearing down below and changing so
36:49
hopefully that'll smooth out but thanks
36:51
for playing roulette with us on the
36:53
questions and for the fantastic
36:55
presentation no where's my pleasure
36:58
thank you everyone for having here again
37:00
I'm happy to answer your if you have a
37:03
question I'm happy to answer those on
37:05
Twitter is also just like at me on
37:07
sweets and I'm happy to try and answer
37:09
your questions here thank you
droidcon News
Tech Showcases, Developer Resources & Partners
EmployerBrandingHeader
jobs.droidcon.com
![]() Latest Android Jobs
Kotlin Weekly
![]() Your weekly dose of Kotlin
ProAndroidDev
![]() Android Tech Blogs, Case Studies and Step-by-Step Coding
Zalando
![]() Meet one of Berlin's top employers
Academy for App Success
![]() Google Play resources tailored for the global droidcon community |
Droidcon is a registered trademark of Mobile Seasons GmbH Copyright © 2020. All rights reserved.