Office Hours — Today, September 27

Tuesday, September 25

Sep 27
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:35 PM
Ed T.
has entered the room
Ed T.
Howdy Mark!
Aaron
has entered the room
Mark M.
hello, Ed and Aaron!
Ed: you narrowly beat Aaron here, so... do you have a question?
Aaron
howdy
Ed T.
Curious your thought on the best way to sync background threads with the UI... would you use a Looper ?
7:40 PM
Mark M.
that depends a lot on what you mean by "sync"
my default approach nowadays is LiveDataa
Ed T.
was my question that crazy? :-)
Mark M.
er, LiveData
not crazy, but "sync" could have a lot of different definitions
could you explain a bit more about your scenario?
Ed T.
sure... JSON config file... that we get via a payload
has options which could be called states... I guess
and all of these require logging or hitting a server for an action... if they are flipped on
Was trying to find a nice clean way for a Background task to come back the UI
and the UI handle it when it comes in cleanly and update state
because 2 of these could be pending in the background
not many
basically a document with a few background updates based on the settings
Mark M.
for that sort of background work, I'm mostly using RxJava (for the background "heavy lifting") and LiveData (for getting the results to the main application thread in a lifecycle-aware fashion)
RxJava isn't a requirement, though -- you can use LiveData with any sort of background work
Google will be steering developers towards WorkManager, which also delivers results via LiveData, but that's more of a 2019 thing
Ed T.
I've not heard of LiveData... is it on GitHub?
k
Mark M.
it is part of the Architecture Components
I have several chapters discussing LiveData in "Android's Architecture Components", part of your Warescription
7:45 PM
Ed T.
I'll check it out tomorrow... I'm on NYC time
I set an alarm to ping you
best $20 I've ever spent... for my 2nd subscription
cheers! Have a great evening...
Mark M.
thanks for the kind words!
you too!
Ed T.
yvw
Mark M.
Aaron: your turn! do you have a question?
Aaron
yes, here are my questions for today, descending order of priority
View paste (4 more lines)
Say I have an options menu XML file with several items, and an alternate resource set (e.g., night mode via DayNight theme) where only ONE of those items differs. Is there a way to specify just that one item in the alternate XML file, and have it override the correct option, in order to stay DRY? Or must I repeat all the menu items including the ones that do not change?

If I'm still developing my app, but I want to generate a beta APK to email someone to test (but not for wider distribution), what is the best procedure? Generate a production key and sign with that, or is that considered a bad practice when it is not really for distribution? I previously emailed a debug APK to someone and it caused problems - the first one installed right but subsequent versions refused to install over the old one, even after it was uninstalled. I want to make sure I generate APKs correctly for this scenario in the future. I don't think BCG talks about this case.

Is there any way to determine what styles are applied to some given text on screen? Closest thing I've found is the "theme" section in the Layout Inspector. Any other options, ideally with more detail?

For 3rd party libraries like Retrof
...
Mark M.
regarding your 1st paragraph... unfortunately, <include> is only for layout resources, otherwise that would be a possible solution
you could always cook up something yourself via custom Gradle tasks to assemble menu XML from pieces, but that's probably way more work than it is worth
so, either only have one menu resource (and do something in code to change the UI as needed), or I think you're best off living with the duplication
Aaron
OK
Mark M.
regarding your second paragraph, I definitely steer clear of distribution issues in my books, as that is a sticky wicket
7:50 PM
Mark M.
but in terms of signing keys, I would use the same key that you plan on using "for realz" when you ship the app
7:50 PM
Aaron
OK
Mark M.
you probably don't have a choice if you are using Play Store's beta system
and if you are rolling your own beta system, using the same key (and application ID) means that beta users can seamlessly upgrade to your final release
Aaron
have not actually researched that option yet, I will do so, currently the beta is limited to one person ;)
Mark M.
let me switch back to Ed for a bit, and then I'll return to work through more of your list
Aaron
OK
Mark M.
Ed: back to you! do you have another question?
Ed, if you have another question, chime in and I'll take it
Aaron: in the meantime, back to your list...
"Is there any way to determine what styles are applied to some given text on screen?" -- none that I know of
"For 3rd party libraries like Retrofit, Picasso, Glide, etc, is it typically necessary to do anything manually to avoid leaking threads?" -- usually these libraries are set up for dealing with config changes, such as having a static thread pool
7:55 PM
Mark M.
however, certainly check for leaks from time to time, or integrate LeakCanary
Aaron
OK
Mark M.
in your fifth paragraph... that quoted sentence is probably obsolete
Aaron
ok, p.3718 FYI
Mark M.
in terms of your last paragraph, what is the WebViewClient doing? what methods are you overriding?
Aaron
nothing too exciting:
View paste (10 more lines)
        browser = result.findViewById(R.id.nosurf_webview_fragment_webview);
        WebSettings browserSettings = browser.getSettings();
        browserSettings.setDomStorageEnabled(true); // Imgur needs this
        browserSettings.setJavaScriptEnabled(true);
        browserSettings.setBuiltInZoomControls(true);
        browserSettings.setDisplayZoomControls(false);
        browserSettings.setLoadWithOverviewMode(true);
        browserSettings.setUseWideViewPort(true);
        browser.setWebViewClient(new WebViewClient() { // needed to load all user clicks inside the WebView

            @Override
            @TargetApi(21) //TODO: support down to 19
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                String url = request.getUrl().toString();

...
Mark M.
I wouldn't expect that to break video playback, but ¯\_(ツ)_/¯
8:00 PM
Ed T.
has left the room
Mark M.
you might put breakpoints or logging in there to see if it is getting invoked
Aaron
yeah ok, no worries
Mark M.
and that wraps up your list
Aaron
it is, I was trying to do some debugging by hooking it into the Chrome developer tools but I don't know enough about web technologies to make sense of it, I may try posting this one on SO
yeah, that's all I've got
thanks!
Mark M.
you're welcome!
Aaron
has left the room
8:30 PM
Mark M.
turned off guest access

Tuesday, September 25

 

Office Hours

People in this transcript

  • Aaron
  • Ed Tidwell
  • Mark Murphy