Office Hours — Today, June 10

Yesterday, June 9

Mark M.
has entered the room
Mark M.
turned on guest access
Jun 10
4:00 PM
Ashley
has entered the room
Mark M.
hello, Ashley!
how can I help you today?
Ashley
View paste
Hello, 

I was hoping you could give me some advice. I would like to apply to some android development internships. What is/are some good projects to put on my GitHub what would impress the recruiters. Also what do you think I should know in order to get an internship in android development.
Mark M.
um
I cannot provide advice regarding internships and what people offering those might be seeking
Ashley
Ok
Mark M.
if you have technical questions about Android app development, I can try to help with that
Ashley
I understand
Ashley
has left the room
4:10 PM
trocchietto_Ivano
has entered the room
Mark M.
hello, Ivano!
how can I help you today?
trocchietto_Ivano
HI Mark
I have two questions
the first one is a meta question, not sure if you can help
View paste
I am spending a lot of money to hire code mentors, and what I found is that they have already some code snippet ready, so I thought that I can use some snippets myself and spare all this money.
My question is would you reccomend to maintain these snippets in a kind of snippet organizer, or is better to have some project?
Mark M.
you could write an Android app development book! :-)
4:15 PM
trocchietto_Ivano
ahahahah
do you have suggestion to use your git?
Mark M.
more seriously, I don't really have such a snippet container in my Android work
trocchietto_Ivano
I see thank you to share that
Mark M.
so I do not have much in the way of practical suggestions for one
trocchietto_Ivano
the second question is regarding SwitchMap
I saw a beautiful conference from Lylia from Google
but I am not sure my understanding is right
basically she said to use SwitchMap to substitute a previous LiveData call( for instance to the repository)
My question is SwitchMap in some way is like subscribe/unsubscribe with RXJava? I meam the LiveData's remain zombing around once created, and switch data is the way to Kill the previous instances making a "Transformation"?
Mark M.
switchMap() is reminiscent of flatMap() in RxJava
switchMap() is *very* reminiscent of switchMap() in RxJava
trocchietto_Ivano
interesting this second one
or switchmap in rxjs i guess
4:20 PM
Mark M.
could be, I have not used RxJS
both map() and switchMap() operate on objects emitted by a source LiveData
map() says "convert these objects into some other ordinary type of object"
trocchietto_Ivano
yep
Mark M.
switchMap() says "convert these objects into LiveData streams"
trocchietto_Ivano
while switch map converts all the livedata
yep
Mark M.
for example, in "Android's Architecture Components", I have an example of searching a book via SQLite full-text searching
I have two fragments, each with a ViewModel: one to show the whole book, one to show search results
however, I want to use paging, as I don't want to load the whole book in at once
trocchietto_Ivano
I see
Mark M.
so, my repository is set up to offer that
however, I *also* want to ship the prose of the book in the APK itself
that makes things interesting, because I need to lazy-populate the database
trocchietto_Ivano
mmh you cannot launch livedata to query
Mark M.
so simply getting an instance of my RoomDatabase is expensive
trocchietto_Ivano
I mean transformations
4:25 PM
Mark M.
so my repository does not offer DataSource.Factory<Integer, ParagraphEntity>, but rather Single<DataSource.Factory<Integer, ParagraphEntity>>, so we ensure all the I/O is done on a background thread
in my ViewModel classes, I then "unwrap" this via Transformations.switchMap()
I convert the Single to a Flowable via LiveDataReactiveStreams
and switchMap() returns LiveData<PagedList<ParagraphEntity>>, to hand to my RecyclerView
(and similarly for BookSearchResult instead of ParagraphEntity, for FTS searches)
you will see this covered in the chapter on Room and FTS
and the sample project using this is: https://github.com/commonsguy/cw-androidarch/tr...
trocchietto_Ivano
I had a fast read already
I would take 5 min to have a look to your git
(btw nice name Time Machine, I need one as well to read all the book I desire instead of this devil coding)
Mark M.
well, all credit for the name goes to H.G. Wells
4:30 PM
trocchietto_Ivano
(classics are everything)
btw with your repository, do I have to download all of them to try a single one? in git I do not have a clone link
Mark M.
the GitHub repository is for all the book's samples
trocchietto_Ivano
OK
Mark M.
otherwise, I would have hundreds of GitHub repositories, across my books
which would be unmanageable
trocchietto_Ivano
I see, understandable indeed
Mark M.
so if you want to load the code into an IDE, you would download or clone the book's repo
the import the individual project of interest
4:35 PM
trocchietto_Ivano
OK, as you said and I can see in the ViewModel, you combined SIngle, Flowable and LiveData
this surprise me
surprises*
Mark M.
um, OK
trocchietto_Ivano
if you use RXJava I guess you do not need LiveData, because LiveData is an RXJava WITHOUT muscles in my opinion, you can do everything you do with LiveData using RXJava I guess
apart I guess the fact that LiveData is cycle Aware
Mark M.
RxJava on its own knows nothing about Android's main application thread
trocchietto_Ivano
mmh but you can use ObserveOn
Mark M.
that requires RxAndroid to go along with RxJava
trocchietto_Ivano
I see
Mark M.
plus, as you note, LiveData is lifecycle-aware, though there are RxJava add-ons for that too
trocchietto_Ivano
RXJava is 100 times more powerful imo
Mark M.
you have two choices: use RxJava all the way through, or use RxJava for "back end" bits and convert to LiveData for the ViewModel layer
trocchietto_Ivano
LiveData is perfect to use it togheter with the other components
4:40 PM
Mark M.
LiveData on its own isn't very powerful, and that's by design -- it's supposed to be simpler to use than RxJava
trocchietto_Ivano
so I have a small curiosity
in your app when do you convert the Single/Flowable with a LiveData instance?
Mark M.
the first parameter to both switchMap() calls is the output of LiveDataReactiveStreams.fromPublisher()
this converts a Flowable or other Publisher into a LiveData
trocchietto_Ivano
ah
wow
there is this factory pattern that makes things tougher to me
but will clone your project, will learn a lot
with a breakpoint in the VIewModel
thank you
uncle BOB is right, there is too much black magic around:(
Mark M.
I'll admit that my use of switchMap() here is not very common
however, it is the only switchMap() example in the book
trocchietto_Ivano
I see
I have the feeling that Lylia uses in a much different use case
that make it almost compulsory, afaiUnderstood, LiveData instances remains around
4:45 PM
trocchietto_Ivano
SwitchMap allow you to do more Search queries
transforming the first query in an hypotetical edit text of a Search in a new one, in this way you do not have zombie processes around
Mark thank you very much, was really informative to understand that I can combine Live Data and RxJava for more complex use cases
Mark M.
you're welcome!
trocchietto_Ivano
I wish you a pleasant time, moving forward, but also backward considering the Time Machine `magic`
Mark M.
ha!
5:00 PM
Mark M.
that's a wrap for today's chat
the transcript will be posted to https://commonsware.com/office-hours/ in a bit
trocchietto_Ivano
have a nice time
Mark M.
the next chat is Tuesday at 7:30pm US Easter
er, US Eastern
trocchietto_Ivano
OK
Mark M.
have a pleasant day/evening/other day-part!
trocchietto_Ivano
has left the room
Mark M.
turned off guest access

Yesterday, June 9

 

Office Hours

People in this transcript

  • Ashley
  • Mark Murphy
  • trocchietto_Ivano