Jun 19 | 3:50 PM |
Mark M. | has entered the room |
Jun 19 | 3:55 PM |
Mark M. | turned on guest access |
Jun 19 | 4:00 PM |
Paul R. | has entered the room |
Paul R. |
Greetings once again.
|
Mark M. |
hello, Paul!
|
Mark M. |
how can I help you today?
|
Paul R. |
Got a couple of questions. First one is a build issue with kapt.
|
Jun 19 | 4:05 PM |
Paul R. |
View paste
|
Paul R. |
Where is this supposed to be added?
|
Mark M. |
if I had to guess, as a top-level closure in the Gradle script
|
Mark M. | |
Paul R. |
Unfortunate that it is a guess. :-)
|
Paul R. |
But easy enough to try.
|
Mark M. |
I haven't seen that message, though depending on where/how it shows up, I might not be noticing it
|
Mark M. |
you could just have kapt.includeCompileClasspath = false directly, as that is syntactically identical to the closure I pasted in
|
Paul R. |
I'm using 5.5 beta Gradle plugin as it fixes an illegal state exception for the app I'm working on.
|
Mark M. |
oh
|
Mark M. |
yeah, that's 0.3.9 ahead of where I am right now :-)
|
Paul R. |
I also see this: Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the testAnnotationProcessor configuration.
|
Paul R. |
Familiar to you?
|
Mark M. |
I haven't seen that error message, but I ran into a problem that resembled it recently
|
Mark M. |
though it would be testKapt, I think
|
Jun 19 | 4:10 PM |
Paul R. |
Shall I try my next issue, recycler view.
|
Mark M. |
um, sure!
|
Paul R. |
ok, I am using a FAB button to trigger the network load of some Movie objects which I want to get added to the RecyclerView adapter. The recycler gets set up in a fragment. The FAB listener is in the main activity. How would you get the new data to the adapter cleanly?
|
Mark M. |
why is the FAB listener in the activity, instead of the fragment?
|
Mark M. |
er, instead of in the fragment?
|
Mark M. |
I mean, you can keep it there, and have the activity call a method on the fragment, if you want
|
Paul R. |
The setup was originally part of a Basic Activity courtesy of the Android Studio wizard which set it up with a CoordinatorLayout...
|
Mark M. |
ph
|
Mark M. |
er, oh
|
Mark M. |
in terms of the data flow, though, I don't know what your overall architecture is
|
Jun 19 | 4:15 PM |
Mark M. |
in the pattern that I have been using in *Exploring Android* and *Elements of Android Jetpack*, I would have the fragment ask its viewmodel for the data
|
Mark M. |
the viewmodel would work with the repository to get the data on a background thread
|
Mark M. |
the viewmodel would then emit the data, perhaps as part of a view-state, via LiveData
|
Paul R. |
Flat for now. It basically uses your ToDo code but I threw out DataBinding. I think it sucks dead moose balls. :-)
|
Mark M. |
yeah, I can understand that
|
Paul R. |
I have not hooked up a viewmodel yet but I like the idea.
|
Mark M. |
the fragment would observe the LiveData and update its adapter (e.g., call submitList())
|
Paul R. |
I believe you cover this in the ToDo app. Correct?
|
Mark M. |
yes
|
Mark M. |
at least, in the *Exploring Android* one
|
Paul R. |
That's the one.
|
Mark M. |
see "Using a Unidirectional Data Flow"
|
Paul R. |
Ok, I'll look at that code and use that approach.
|
Mark M. |
and the two chapters after it
|
Mark M. |
FWIW, I also cover the same pattern, with different apps, in the latest *Elements of Android Jetpack*
|
Paul R. |
As for databinding, I followed your setup and tried to morph the code to my app. Debugging the result was worse than pulling teeth.
|
Mark M. |
I used it mostly for adherence to the Jetpack philosophy
|
Mark M. |
and, as it turns out, with Jetpack Compose, data binding is likely to be toast in the long term
|
Paul R. |
Good to know about the Jetpack stuff. I have not yet consumed that book.
|
Jun 19 | 4:20 PM |
Mark M. |
it's the second-generation replacement for the core chapters of *The Busy Coder's Guide to Android Development*
|
Mark M. |
and the back 25% or so of the book all uses the unidirectional data flow pattern
|
Mark M. |
though mostly sans fragments -- I only used fragments if the sample needed multiple screens
|
Paul R. |
What is the background for this "universal data flow pattern" . Cannot say I've heard or seen much about it.
|
Mark M. |
whoops, I meant unidirectional
|
Mark M. |
basically, having immutable data flowing through the system, with clear points for where that data gets replaced, rather than updated in-place
|
Paul R. |
I think that might have been me.
|
Mark M. |
so, in the ToDo stuff, if you have gotten to the point where I start talking about "motors", my motor classes are engines of a unidirectional data flow
|
Mark M. |
the UI (activity fragment) receives immutable view-states that it uses to populate the UI
|
Mark M. |
the UI calls functions on the motor based on user input
|
Paul R. |
Ah yes, now it is ringing a bell.
|
Mark M. |
the motor does the work with the repository to actually affect real changes (database, network, etc.), then emits a fresh view-state
|
Paul R. |
You had a very nice picture if memory serves.
|
Mark M. |
IMHO, my diagrams aren't the prettiest, but yes, I think I have some diagrams
|
Jun 19 | 4:25 PM |
Paul R. |
Although that could have been a blog post I chased down after reading the material.
|
Mark M. |
I have more similar ones in *Elements of Android Jetpack*, in the "Adding Some Architecture" chapter
|
Mark M. |
it's a pattern that has been gaining popularity, sometimes referred to as Model-View-Intent, an name that totally sucks in Android
|
Paul R. |
Personally, I think all these MV* things are a dis-service.
|
Mark M. |
it's definitely a fair bit of alphabet soup, and there's not a lot of agreement over the details of any one of the patterns
|
Mark M. |
which is why I tried to steer away from those terms in these second-generation books
|
Paul R. |
I do believe strongly in Clean Architecture, which to me means develop code that adhere's to good coding principles.
|
Paul R. |
And keep projects small. Too often I see simple projects turn into behemoths, hence the need to add structure. I like to use many artifacts so that my app is small. Put all the smarts into libraries developed with IntelliJ rather than keeping everything Android aware.
|
Jun 19 | 4:30 PM |
Paul R. |
fwiw.
|
Mark M. |
there certainly are arguments in favor of that approach, though I think having a multi-module Studio project is a more common way of addressing the concerns
|
Paul R. |
I'm going to get back to my code and follow up with your suggestions. Thanks and talk to you later.
|
Paul R. | has left the room |
Jun 19 | 4:55 PM |
Mark M. | turned off guest access |