Office Hours — Today, November 19

Thursday, November 16

Nov 19
3:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
3:55 PM
rillig
has entered the room
rillig
Hi, thanks for providing this opportunity.
Mark M.
hello, rillig!
how can I help you today?
rillig
View paste
I found a bug in the Internet/OkHttp3 app.

In QuestionsFragment.onCreate, the background thread is started, and when it returns, it posts an event. Assuming you have a very fast internet connection and a slow phone, posting the event can happen before the event handler is regiered in QuestionFragment.onResume.

I found this when I replaced the network code with local code, because I used the OkHttp3 app for understanding ListFragment. That worked very well, by the way.
Mark M.
yes, that's a bit sloppy
it's one of those things where I'm making a sacrifice of reliability for readability of a book example
rillig
View paste
Still in the Internet/OkHttp3 app.

I wondered whether you could rename the `Item` class to `Question` or `SOQuestion`, since that makes a lot more sense.

And, still in the same app, is QuestionsFragment.onEventMainThread guaranteed to be called in the correct thread?
Mark M.
in later examples, I use Question for something else
rillig
ah, ok
Mark M.
onEventMainThread() is always called on the main application thread, by definition
4:00 PM
rillig
by what definition? by its name?
4:00 PM
Mark M.
the definition of the API as documented by the library
rillig
I didn't read the chapter of the book, I just had a look at the code, by the way.
Mark M.
the library documentation says that onEventMainThread() is called on the main application thread
rillig
I was just wondering because IntelliJ marks that method as unused.
Mark M.
that's because it is called by reflection
the IDE does not know about that
I could add an annotation that says "this method really is used", but it's debatable which approach is uglier :-)
rillig
Ah, now it gets clearer. I thought it was the Guava EventBus, but it's another library.
Mark M.
greenrobot's EventBus is derived from Guava's, with more Android-isms
4:05 PM
rillig
View paste
Next topic. :)

Regarding your book app:

* I expected to have a feature for taking notes or marking sections and chapters as "done".
* It would be nice if the app remembered my last position for each chapter.
* After a search, the results are displayed to the right. I have no idea how to close this search result.
Mark M.
the book app was written because EPUB readers sucked years ago
I keep it around, but I cannot afford to invest more time in features
I just update the content
rillig
ok, that's probably work enough :)
Mark M.
with regards to the search result, pressing BACK should revert that fragment transaction and remove the search results, IIRC
rillig
I was pretty impressed by the 4000+ pages
Mark M.
there are also the other two books, neither of which are available in app form
but, yes, the main book is large
rillig
ok, the BACK makes sense. I just didn't think of it because I could do all other navigation stuff by swiping.
4:10 PM
rillig
On another note, somewhere in the book you mention that the `targetSdkVersion` isn't that important. But still you use all from the following list: 4|6|11|13|14|15|16|17|18|19|21|22|23|24|25. Is there a particular reason for that?
Mark M.
as you noted, it's a 4000+ page book
that's rather difficult to maintain
while compileSdkVersion changes do not affect functionality, targetSdkVersion changes do
hence, I only change that when I am updating that particular sample for some other reason
rillig
oh, so you would have to test all 100+ apps
I can understand that. :)
Mark M.
so, I update some things automatically, such as the Gradle plugin version
think of my targetSdkVersions as layers of sediment in the geological record
targetSdkVersion 4 is from the Pliocene era, for example :-)
rillig
:)
4:15 PM
rillig
Wow, the greenrobot library is really minimalistic in terms of size and classes. I just had a look whether there was an interface EventReceiver<T> so that the `onEventMainThread` could be marked as used.
But there isn't anything. So the book just has to explain that magic. :)
Mark M.
EventBus 3.x uses annotations
more of the samples go that route
in fact, I'm not sure if the particular sample that you looked at is used in the book anymore -- I have some stuff floating around the repo that aren't used
but, no, there's no explicit interface or abstract class to use for event receivers
rillig
of course. :) Keeping track of 7 versions of the book and 200+ apps and the chapters is a lot of work.
Mark M.
7?
rillig
oh
Mark M.
many more than that
rillig
2 months/book * 4 years = 24 versions
wow
Mark M.
well, it's been closer to 10 years
rillig
yeah, but I thought versions older than 4 years would be "unsupported". But "free" apparently means something else. :)
Mark M.
if you are referring to Four-to-Free, free means available under a Creative Commons license
rillig
yes, I was.
4:20 PM
Mark M.
4:30 PM
rillig
Thank you for your time. Have a nice afternoon. :)
Mark M.
you too!
rillig
has left the room
4:55 PM
Mark M.
turned off guest access

Thursday, November 16

 

Office Hours

People in this transcript

  • Mark Murphy
  • rillig