Office Hours — Today, August 31

Thursday, August 29

Aug 31
3:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:05 PM
Scott W.
has entered the room
Scott W.
hello!
Mark M.
hello, Scott!
how can I help you today?
Scott W.
I have a question, but I'd like to give you an update on the pagination library first
we spoke about it last week
Mark M.
yup! any luck?
Scott W.
I'm sticking with the library, but I decided to remove the header rows in my list to simplify things
Mark M.
if the customer is happy, simpler is good
Scott W.
yeah
I'm still having a problem with the adapter asking for the last available item, which triggers this lookAround function when triggers loadRange, which triggers the recyclerview jumping.
4:10 PM
Scott W.
Also, I'm using 1 fragment to switch between displaying two different data sets of the same data type
I think I can fix some other small issues by separating these into their own fragments
I ran into some of your answers on stack overflow trying to do this actually.
I have a view pager and tab layout to display 3 fragments
the first fragment needs to display different data based on a boolean
so I want to just have 4 fragments and swap the first spot out.
Mark M.
ViewPager, or at least the stock adapters, does not handle that well
OTOH, if you are using library implementations of fragments, nested fragments are stable nowadays
Scott W.
yeah it ended up being too difficult for the time I have left and I will not solve this problem in the near future.
Mark M.
when you return to it, your first page might be a fragment that holds one of two nested fragments
Scott W.
that's a good idea
Mark M.
so you can switch the contents of that page as that boolean changes
Scott W.
I will try this
ok now to my question for the day
4:15 PM
Scott W.
My app uses an SDK for video calls. It does not handle the situation of starting a video call while the user is on the phone well.
so, I'd like to know how to detect if another app, not just the phone app, is using the microphone before a call starts.
all that I've seen so far it to try recording something, and if it fails, you know someone else is using the microphone.
Mark M.
the APIs aren't really set up for that AFAIK
that might actually be the only viable option
Scott W.
ok I
ok I
haha
ok I'll stick with that
I'm typing at an odd angle right now
Mark M.
I won't ask :-)
Scott W.
good good
Mark M.
the media APIs aren't my strong suit, so I can't rule out there being some other option
Scott W.
I've got another topic I'd like to chat with you about
Mark M.
if it's "how is Duke shutting out Bama?", I can't explain that
4:20 PM
Scott W.
haha I've got the game on and am sitting on my couch! there's the odd angle explanation.
so, I am the lead developer on one app, but the basics of the app were in place when I joined the company.
so all of the communication between client and server were set up by the founder of the company.
::roll tide::
This guy isn't a Java developer, and the way he implemented this communication doesn't seem standard at all.
Mark M.
is the Android app the only client, or do you have others (iOS, desktop, single-page Web app)?
Scott W.
iOS and web. web functions on desktop and mobile
iOS came first, then Android was adapted from that code.
Mark M.
perhaps the communications were set up with iOS in mind
Scott W.
maybe
Mark M.
what sort of communications is it? REST Web service? GraphQL? WebSockets? something else?
Scott W.
sockets
4:25 PM
Mark M.
plain sockets? that's... rather low level
Scott W.
all the socket objects have been moved to a lower library that we hired a couple of dudes to come in a write last year.
I'm not too concerned with that right now. That library was written by some Java pros
in out app though, I make a request to the server like "get page of one of my contacts"
and it hands me an object called a Deferred. When the response comes back, it is delivered through callbacks or errorbacks in this Deferred object
Trying to figure out how to handle these Deferred objects has been a great pain for me.
We are about to make the core of our app into a library to sell to people, and I do not want to expose Deferreds to them.
That's what the original developer based the Deferred object code off of.
So, I'm wondering if this is a common thing, or if I should use a more standard Java object for this.
And what that standard Java object is.
4:30 PM
Mark M.
"deferred" is one approach to a reactive sort of API
that particular construct is not common in Android
if you wanted to stick with fairly "pure" Android SDK stuff, LiveData would be the reactive option to consider
RxJava's Single is another candidate, if you want to climb the RxJava learning curve
Scott W.
I do not
I just got my first taste of LiveData with this pagedlist stuff
I don't understand LiveData yet. I'll have to go through your book on this stuff.
I don't understand the relationship between it and ViewModel
Mark M.
I cover it in *Elements of Android Jetpack* and *Android's Architecture Components*
in a CRUD-style app, a ViewModel typically will expose LiveData to the UI (activities/fragments)
if you want to stick with a Deferred approach, you could consider http://jdeferred.org/, which AFAIK is the most popular implementation
as opposed to using a homebrew implementation
4:35 PM
Scott W.
interesting
one issue our Deferred has is that it is eventually "called" which triggers all of the chains of callbacks you've attached to it. However, it's possible for it to be called before you attach your callbacks. So, you callback would never run in that case.
Mark M.
that seems like a bug
there should be a way to wire everything up, then say "go!"
Scott W.
It's a known limitation according to the developer. For me to go in and add that capability would seem like a waste of time.
I would rather switch to this jdeferred or use LiveData if I'm going to put that sort of time in.
Mark M.
I don't know enough of JDeferred to say how it handles the situation that you described
with LiveData, you would start the work in the onActive() method, which means you have at least one observer to deliver results to
4:40 PM
Mark M.
as you are creating this API, you also need to keep Kotlin in mind
insofar as some percentage of your customers might be developing in Kotlin
the advantage of LiveData and RxJava is that there is quite a bit written about using those from Kotlin
Scott W.
our first customer is developing in xamarin
Mark M.
oh, right, you mentioned that
I haven't the foggiest notion what would be easiest for Xamarin users
I'm happy that I can usually spell "Xamarin" successfully
Scott W.
yeah. They've said androidx in general might be a problem
I'm hoping that xamarin has support for androidx by the time we get them this library.
I'd like to explain a little more of our process to you
The deferred is held by a Command object that goes into a queue held by our custom Reactor
we pump the Reactor once every 100ms
results go into Result objects which gets the deferred and starts the chain of callbacks
Results are in a separate queue in the Reactor
This whole process also seems like something that we should not have written ourselves.
4:45 PM
Scott W.
so I have the same concerns with our Reactor as I do with the Deferred object
Mark M.
well, there are standard approaches for work queues and results delivery with RxJava and Kotlin coroutines
but that reflects a lot of work in reactive programming in the past 4-5 years
your Reactor is implementation, not interface, if I understand correctly
Scott W.
that's right
Mark M.
so, you can change that around in the future without necessarily impacting your API customers
Scott W.
absolutely
however it's tightly coupled with Deferreds right now
I don't know what it would take to swap out Deferreds for LiveData
Mark M.
yeah, I can't really answer that
Scott W.
yeah I'll see how far I can get with that. Might need to pull in the original developer.
I'll have to convince him this is a good ideal
*idea
4:50 PM
Scott W.
I don't work with any other Android developers, and there aren't many at all where I live. Being able to chat with you like this is really great.
Mark M.
happy to help!
Scott W.
I'm going to switch gears to Udacity videos now.
Thanks for the help!
Mark M.
you're welcome!
Scott W.
has left the room
5:00 PM
Mark M.
turned off guest access

Thursday, August 29

 

Office Hours

People in this transcript

  • Mark Murphy
  • Scott Wehby