Office Hours — Today, June 15

Yesterday, June 14

Jun 15
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:35 PM
Wari
has entered the room
Mark M.
hello, Wari!
how can I help you today?
Wari
Hi there, quick question. Will Kotlin be covered as part of a track?
Mark M.
I am not sure what you mean by "track"
I have no plans on covering Kotlin in my book, insofar as that would take another book :-)
Wari
The other part of the book I mean, like scripting, etc
Mark M.
no, sorry
in fact, I will be pulling a lot of the scripting stuff in the next book update, as it is old and stale at this point
I might reintroduce it later, when I have time to update it properly
but even with the scripting stuff, the focus is on the integration of a scripting language, not the language itself
Wari
Got it. Anyway, thanks, that's all I need to know :) GTG and thanks again Mark.
Mark M.
Kotlin is not a scripting language, so it wouldn't fit there
Wari
Yeah
Mark M.
you're welcome!
Wari
Bye
Wari
has left the room
7:40 PM
Chandra S.
has entered the room
Mark M.
hello, Chandra
how can I help you today?
Chandra S.
Hi Murphy
7:45 PM
Chandra S.
I'm currently still confused whether choosing Retrofit or Volley
Do you have any advise?
Mark M.
IMHO, they are not really directly comparable
OkHttp+Picasso would be a better comparison with Volley
Retrofit is specifically for REST-style Web service APIs
Volley has light support for that, but not nearly as much as Retrofit offers
personally, I use the Square libraries (OkHttp/Retrofit/Picasso)
Chandra S.
I see, thanks for the opinion, Mark
Is there any significance difference between retrofit 1 and 2?
Since what's there in the book is the retrofit 1 only
Mark M.
I am slightly behind on Retrofit :-(
IIRC, it is fairly close to the original, but I forget the differences
I will try to get this updated in the book in Version 7.4
er, 7.5
Chandra S.
OK, Thanks, Mark
I also still confuse on using retrofit
7:50 PM
Chandra S.
Some questions arised, like why we have to use interface?
Mark M.
well, they code generate the implementation
my guess is that it is easier for them to code generate an interface implementation than, say, a subclass of an abstract base class
but, you would have to ask them for the specifics of why they made that choice
in general, the idea is that you describe a service API, and then you get a Java object that handles all the implementation, so the API is as natural as possible
contrast that with Volley or OkHttp, which both can talk to REST-style Web services, but where all the HTTP "plumbing" is exposed
Chandra S.
I see.. quite clear, Mark
And since the book only mention to write 1 connection, how if we want to define 2 or more connections?
Put another @GET in the same interface or should be the different interface?
7:55 PM
Mark M.
if it is for the same Web service, it goes in the same interface
I have an example of that in the data binding chapter, IIRC
here, I have two @GET methods for StackOverflowInterface, each pointing to a different path
Chandra S.
Nice one!
A little bit confuse about the query also
Mark M.
could you be a bit more specific?
Chandra S.
With the query tagged, the full link will be: api.stackoverflow.com/2.1/order=desc&...&tagged=android?
Mark M.
given my Java code, yes
Chandra S.
If called with the tagged android
Mark M.
yes
as I have it implemented, the tag is a parameter, so the Java code could supply a different tag (e.g., java)
whereas sort and site are hard-coded
Chandra S.
I see.. so it used for define more generic code
8:00 PM
Mark M.
basically, if your Java code does not need the parameter to be variable, you might as well just hard-code it
the only reason I made the tags a parameter was to demonstrate using a parameter :-)
I could have used a Spinner or something to allow you to switch between different tags, but that seemed like overkill
Chandra S.
Sorry Mark, I got disconnected
8:05 PM
Mark M.
ok
can you see past messages, or did they go away?
Chandra S.
Ok understand it :-)
Yes I will write down again
About Picasso, I didn't see any URL in the load method
How it can get the picture?
Mark M.
it gets a URL in the load() method
in this case, it is a URL pulled from the Retrofit response
Chandra S.
Ah sorry, I just saw the Stackoverflow API output
So the profile_image consist of image URL
Mark M.
yes
that particular detail comes from the Stack Exchange Web service API
Chandra S.
And one more in the code that I still confuse is about the eventbus
Mark M.
the URL could come from anywhere
Chandra S.
What is the purpose of the eventbus?
Mark M.
mostly, it is for communications between components of an app, such as service back to the activities
Chandra S.
In the retrofit + picasso example, what did the event bus do?
Mark M.
hold on...
8:10 PM
Mark M.
ah
Chandra S.
OK
Mark M.
when the user clicks on a question in the ListView in the QuestionsFragment, I post an event on the event bus
that gets picked up by the activity
which then brings up the Web page for the question in a browser
the idea of the fragment delegating that work to the activity is a good idea
using an event bus there... mostly, I was trying to show different uses for an event bus
I should consider rewriting those to just use the contract pattern and call a method on the activity directly
Chandra S.
I see.. OK, thanks Mark
Hmm but I still confuse how it can call the web page
Mark M.
the activity just uses ACTION_VIEW
the link to the Web page is part of the Stack Exchange Web service API response
8:15 PM
Mark M.
similar to the link to the question asker's avatar image
Chandra S.
Is there any line I have to notice beside Line 63?
Mark M.
I don't know
that is where the event is posted
the line before it (61) is where we get the Item from
8:25 PM
Chandra S.
OK, Mark, I will look and see the code again first, since I think this one is a little bit difficult to me :-)
Maybe I will join the next session tomorrow, hopefully have understand throughly
Mark M.
you may wish to review the chapter on threads, where I introduce the event bus
there is also a dedicated chapter on event buses in the trails
Chandra S.
OK, I will read that chapter
Since the book is very thick, so what I usually do is jump to the part that I want to implement in my application
Many thanks, Mark, for the explanation :-)
Mark M.
you are very welcome
Chandra S.
OK, I'll see you later :-)
Chandra S.
has left the room
8:30 PM
Mark M.
turned off guest access

Yesterday, June 14

 

Office Hours

People in this transcript

  • Chandra Siahaan
  • Mark Murphy
  • Wari