Office Hours — Today, September 4

Saturday, September 1

Sep 4
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:30 PM
Aaron
has entered the room
Mark M.
hello, Aaron!
how can I help you today?
Aaron
hey Mark, hope you are well, just a few questions today
in Android Studio there seem to be two global find dialogs, Ctrl-Shift-F, and double-Shift. Can't really tell what the difference is supposed to be and Google didn't help much...
Mark M.
well, since I used Ctrl-Shift-F for the first time based on your question, I'm not the best person to answer that question :-)
Aaron
lol, ok no worries
Mark M.
looks like Ctrl-Shift-F offers free-text search, while double-shift is for filenames and class names (mostly)
Aaron
second, my AVD is a Nexus 4 running 8.1 w/ Google APIs, and it seems like anytime I use WebView at all, I get this error, which Google also doesn't help much with:
E/chromium: [ERROR:gl_surface_egl.cc(289)] eglChooseConfig failed with error EGL_SUCCESS
does that mean anything to you? any suggestion on where to research, besides asking on SO?
Mark M.
ignore it
7:35 PM
Mark M.
the Chromium engine logs stuff because it's lonely or something
Aaron
I see. I thought that might be the case, given that the error message is...success
Mark M.
everybody gets those, and unless you have concrete problems, just assume that the Chromium team really likes the error severity, and move on
Aaron
OK
last question for today is implementation-specific w/r/t the app I am continuing to work on
are you familiar with Reddit just as a user?
Mark M.
barely
I'm not a member
Aaron
ok
Mark M.
I occasionally wind up on a page there due to some search result or link
Aaron
no worries, i'll just add more context
my app is a master/detail setup basically. RecyclerView that loads in the front page of Reddit posts (25 posts by default) through LiveData w/ Retrofit, which all comes from one API call.
Mark M.
OK
7:40 PM
Aaron
clicking a row loads a detail view in a fragment, which displays a larger image thumbnail associated with that post, if one exists, any post text, if it exists, and the three most highly-rated comments on the post
Mark M.
OK
Aaron
the thumbnail and post text all are extracted from the data I get back from the API call, however the comments have to be downloaded with a separate call for each post
Mark M.
Reddit needs a new API, but OK
Aaron
haha, yeah may be, in any case, each post has an ID that has to be piped into the second call to download the comments for it
so basically in my click listener for the RecyclerView, I do 2 things: kick off the Retrofit call and launch the new fragment
the way I'm doing it now,
I have only a single LiveData, call it commentsLiveData, and every time the user clicks a different post, I send that post ID to Retrofit and it loads the new comments into the LiveData
so it's not wrapping a single data source over time... instead the source is actually changing
7:45 PM
Mark M.
OK
Aaron
this is causing a problem, because each time a new detail-view fragment is kicked off, the onChanged call that happens after subscription occurs before the Retrofit call reloads the LiveData
so you click post 1, then go back and click post 2, you will see the comments from post 1 for about a second on the post 2 detail page
while the Retrofit call is finishing
that's no good
I suspect I'm abusing LiveData by using it this way
but lacking alternate ideas
Mark M.
off the cuff, two instances of your detail fragment should not be sharing the single LiveData
Aaron
does that all make sense? I'd post code but it's a mess
Mark M.
if you're using the Architecture Components' ViewModel system, each of those fragment instances would have its own ViewModel with its own LiveData
Aaron
hmm, ok I've misunderstood something then
that's a good starting point though, I will research along those lines and see where that gets me
Mark M.
are you using ViewModel, or are you managing your LiveData some other way?
7:50 PM
Aaron
yeah, I am using ViewModel, I'm not even really sure I am using it correctly though. All it's really doing is chaining via SwitchMap to the LiveData exposed by my repository where all the HTTP calls are happening
I mean, I can link you to the current code on Github if you like, but it might be better if I come back with that later after I get a chance to refactor
Mark M.
that's your call
however, if you are using ViewModel, for the purposes of this LiveData, you'd want two ViewModel instances, each with its own LiveData from the repository
that might be in addition to a separate ViewModel that the fragments share with their hosting activity
7:55 PM
Aaron
OK, I think that gives me enough to start a new line of inquiry that might lead to a solution
I will probably ask you to for a mini-code review once I've gotten it more cleaned up, but at this point I just don't think it would be an efficient or respectful use of anyone's time to look at
Mark M.
OK
Aaron
thinking if I have any follow up questions
no, I'll let you go for now and keep working on it
thanks!
Mark M.
you're welcome!
Aaron
has left the room
8:25 PM
Mark M.
turned off guest access

Saturday, September 1

 

Office Hours

People in this transcript

  • Aaron
  • Mark Murphy