Office Hours — Today, December 21

Tuesday, December 19

Dec 21
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:00 PM
Mike
has entered the room
Mark M.
hello, Mike!
how can I help you today?
Mike
Hi Mark. I wanted to talk a little about the code in your example for Retrofit2, ref: https://github.com/commonsguy/cw-omnibus/tree/v...
Mark M.
OK
did you have anything specific that concerned you?
Mike
I am a little confused about how the response from the web server api (stack overflow) is processed. First, in this file, where does the "questions" come from? I don't see where it is defined. https://github.com/commonsguy/cw-omnibus/blob/v...
Mark M.
it comes from the server
it is defined, if you will, by Retrofit itself
Mike
you can name it anything you want?
Mark M.
Retrofit synthetically generates an implementation of this interface
the method name does not matter
Mike
ok, great, please standby while I take another look at it.
Mark M.
everything that the server cares about comes from annotations (e.g., the @GET and @Query)
4:05 PM
Mike
I see in QuestionsFragment.java, it seems that the response is processed in onResponse. It seems like the data shows up there "magically," lol
Mark M.
in line 58, I call questions() on an instance of the synthetic implemenation of SOQuestions
I then call enqueue() to say "hey, do this REST call in the background, and let me know when it's done, m'kay?"
onResponse() is the callback for a successful REST call
Mike
right, I think I understand the onResponse(). also in line 58, "android" is the tag for the query?
Mark M.
yes
Mike
nice.
4:10 PM
Mike
i was trying to do my own example, and running into a little trouble with related it to yours and others I had seen. Your comment about the annotations is helpful
another question:
in Line 24 of the I/F, are you kind of saying to retrofit: define a method where it has a parameter of tags?
4:15 PM
Mark M.
I am saying "when this method is called, make a REST request for /2.1/questions?order=desc&sort=creation&site=stackoverflow, and also append a 'tagged' query parameter, whose value comes from the tags method parameter"
4:15 PM
Mike
got it. but we didn't define the method? Retrofit does that?
Mark M.
we didn't create the implementation
Retrofit does that
I don't know exactly how, since there is no compile-time annotation processor at work here
Mike
ok, i think i understand it better now. and @Query("tagged") - how does that work?
Mark M.
again, that says "append a 'tagged' query parameter to the URL, whose value comes from the annotated method parameter)
4:20 PM
Mike
ok, thank you so much, I will take this back and digest your insights some more, and apply them to my example. are these chats archived anywhere?
Mark M.
this chat transcript will be added shortly after the chat ends
Mike
ok, thanks. much appreciated. Happy Holidays to you.
Mark M.
and to you as well!
Mike
thank you
Mike
has left the room
5:00 PM
Mark M.
turned off guest access

Tuesday, December 19

 

Office Hours

People in this transcript

  • Mark Murphy
  • Mike