Jan 7 | 8:20 AM |
Mark M. | has entered the room |
Jan 7 | 8:25 AM |
Mark M. | turned on guest access |
Kai H. | has entered the room |
Kai H. |
Hello Mark
|
Mark M. |
hello, Kai!
|
Mark M. |
how can I help you today?
|
Kai H. |
In one of your books, you mention that Jetpack "Navigation" is pretty much only suitable for small Apps. Does this still hold true?
|
Mark M. |
it is fairly rigid
|
Mark M. |
bigger apps tend to imply bigger teams, where some team members will not like aspects of that rigidity
|
Mark M. |
bigger apps also tend to imply more "weird stuff" where the rigidity will be an impediment
|
Kai H. |
I see
|
Jan 7 | 8:30 AM |
Mark M. |
bigger apps also tend to imply non-Android parties having significant votes, such as designers
|
Mark M. |
I will probably need to revisit whatever language that I used there and make sure that it is up to date
|
Mark M. |
it's not that a big app *can't* use Navigation, but it requires you to be willing to live within its limits or live with going outside of Navigation from time to time as needed
|
Kai H. |
So is Googles idea probably "every app should have only as much navigation as Navigation can give"? Or what do you reckon?
|
Mark M. |
I suspect that it is impractical to provide a navigation framework that is infinitely flexible
|
Mark M. |
a lot of the Jetpack is Google putting its opinions out front
|
sudokai | has entered the room |
Mark M. |
Navigation is Google's opinion on how navigation should be done, within the limits of the engineering time they could put into it
|
Kai H. |
"Why even bother then?" is my immediate thought.
|
Kai H. |
Hi kai
|
Mark M. |
(hello, sudokai -- I will be with you shortly!)
|
Mark M. |
Kai: to an extent, I had the same sort of reaction
|
Mark M. |
in a pure greenfield environment, such as Navigation for Compose, things feel a bit more natural
|
Mark M. |
(at least in my mind)
|
Jan 7 | 8:35 AM |
Mark M. |
and having a reasonable solution out there for fragments is perfectly fine
|
Mark M. |
it's just that how well Navigation handles the reality of major-project development is... I'll call it "unproven"
|
Kai H. |
Ok
|
Mark M. |
so, IMHO, you don't need to *avoid* Navigation, just understand that it is strongly opinionated and that those opinions may conflict with the opinions of other developers, designers, management, etc.
|
Mark M. |
and the bigger the project, the more likely it is that there will be those other opinions
|
Mark M. |
let me take a question from sudokai, and I'll return to you in a bit
|
Mark M. |
sudokai: hi! how can I help you today?
|
Jan 7 | 8:40 AM |
Mark M. |
sudokai: do you have a question?
|
Mark M. |
sudokai: if you come up with a question, chime in and let me know
|
Mark M. |
in the meantime...
|
Mark M. |
Kai: back to you! do you have another question?
|
Kai H. |
Yes
|
Kai H. |
I have a prepopulated db that I try to access with room. I get 0 results where I should get 18 ("SELECT * FROM mytable"). How to debug?
|
Kai H. |
(Isn't that a very specific question? ;-) )
|
Mark M. |
use Database Inspector if you are on Android Studio 4.1 or higher and confirm what the database has in it
|
Jan 7 | 8:45 AM |
Mark M. |
if it truly has zero rows, do "Clear Data" on your app in Settings (or uninstall it), then try running it again
|
Mark M. |
if you still wind up with 0 rows, then your prepopulated database is not getting used
|
Kai H. |
After deinstalling and rerunning I get a different error. Thanks :D
|
Kai H. |
It seems to not have used my pre-packaged database before. I would have liked to at least have some sort of error message somewhere in between.
|
Kai H. |
But I guess that's what "instant run" gives us.
|
Mark M. |
I always avoided that, and now try very carefully to never click the "Apply Changes and Restart Activity" button
|
Kai H. |
Isn't that the default "shift + f10" behaviour? That's what I always use.
|
Jan 7 | 8:50 AM |
Mark M. |
shift + F10, at least on Linux, is "Run"
|
Mark M. |
ctrl + F10 is "Apply Changes and Restart Activity"
|
Mark M. |
keybindings might vary by platform, though
|
Kai H. |
Ok, so I just ran and it didn't use my database, apparently.
|
Kai H. |
Ah well. Good to know that sometimes a reinstall is in order, apparently.
|
Mark M. |
that's one of the reasons why I suggested seeing what is in the actual database when you were in the 0-rows state
|
Mark M. |
if it shows 18 rows, then your problem is that however you are testing the 0-rows case isn't using your database
|
Mark M. |
if, instead, the actual database shows 0 rows, then either Room created an empty database for you or you deleted 18 rows somewhere along the line
|
Kai H. |
Well, after reinstalling it uses the actual database :D
|
Kai H. |
Now I get "Pre-packaged database has an invalid schema: " instead, which is more to work with.
|
Mark M. |
that's one of the bigger headaches with pre-packaged databases and Room -- keeping the schema of the pre-packaged database up to date
|
Jan 7 | 8:55 AM |
Kai H. |
View paste
|
Mark M. |
one is set for NOT NULL and the other is not
|
Jan 7 | 9:00 AM |
Kai H. |
I didn't know that mattered X)
|
Mark M. |
if it affects the table definition, it matters
|
Kai H. |
So either make the Kotlin variables nullable or the rows NOT NULL in SQL, I guess?
|
Mark M. |
you need to be consistent between the entity definitions and the schema in you pre-populated database
|
Mark M. |
one way to do that is to let Room create an empty database for you, pull it off the device, and use that as the starting point for pre-population
|
Mark M. |
the headache being that every time you tweak an entity, you may need to do that again
|
Kai H. |
How would I fix this one error?
|
Mark M. |
Step #1 would be to decide which is correct. Ignoring the actual error, logically, is a null title valid?
|
Mark M. |
(what Step #2 is will depend on the answer to Step #1)
|
Kai H. |
No, it is not. There shall only be nonNull titles.
|
Jan 7 | 9:05 AM |
Mark M. |
then the Kotlin is fine, based on your earlier statement
|
Mark M. |
and your problem is in the pre-populated database, where you are allowing nulls in the title coumn
|
Mark M. |
er, column
|
Kai H. |
So I'll need to work on that.
|
Mark M. |
yes, using your favorite SQLite client, you would need to amend that table structure to not allow nulls
|
Kai H. |
View paste
|
Kai H. |
And it's also denoted as such in the ChapterEntity
|
Jan 7 | 9:10 AM |
Mark M. |
well, you also have a problem here on type: one says INTEGER, the other says TEXT
|
Kai H. |
Ah, I changed that already. Sorry.
|
Mark M. |
I pretty much always let Room create the empty database for me, then populate it
|
Kai H. |
Ok, so I'll try and do the same.
|
Kai H. |
Makes scraping it with another program a little harder, but ah well.
|
Mark M. |
if I did enough of that sort of work, I would write a tool that reads in the schema stuff written in JSON and use that as the basis for creating a compliant database off-devices
|
Kai H. |
The things we do to use jetpack components ;-)
|
sudokai |
Hello
|
Kai H. |
He's alive!
|
Mark M. |
hello, sudokai!
|
sudokai |
Happy new year
|
Mark M. |
sudokai: Happy New Year! how can I help you today?
|
sudokai |
Yeah, I'm still struggling with some location updates code
|
sudokai |
The problem I now see is that I request location updates and *sometimes*, location updates just don't come in
|
Kai H. |
Happy new year :D
|
sudokai |
So, you request location updates with LocationManager, 1 per sec
|
Jan 7 | 9:15 AM |
Mark M. |
what provider are you using?
|
sudokai |
Then 2 hours later, the listener has received maybe 4 coordinates
|
sudokai |
GPS
|
Mark M. |
OK, and is this happening for you during development or only in the field?
|
sudokai |
Both
|
sudokai |
But it's not always reproducible
|
Mark M. |
if this were purely something you saw in production, then the problem might simply be that the device cannot receive GPS signals -- those are not available everywhere
|
sudokai |
I see really strange stuff
|
sudokai |
Like requesting location updates with locationmanager, no updates for 5 minutes
|
sudokai |
Then switch to fused location, do the same, then switch back
|
sudokai |
voila, now it works
|
sudokai |
Or no location updates for 5 minutes, then voila, you look at the phone, now it starts working
|
Mark M. |
fortunately, I have not needed to use GPS locations in real projects in a couple of years
|
sudokai |
I'm aware of a GPS cold start situation
|
sudokai |
But 5-10 mins to get a fix???
|
Mark M. |
for the "you look at the phone" problem, bear in mind that Doze mode and similar power considerations still apply
|
Mark M. |
so, are you holding a partial WakeLock?
|
Jan 7 | 9:20 AM |
sudokai |
Once, I also started location updates inside a garage with no GPS signal, then went out and drove for two hours, didn't receive a single location update
|
sudokai |
Actually, this case seem to happen fairly frequently
|
sudokai |
If you start your location updates somewhere with no GPS signal, then it never recovers
|
sudokai |
> so, are you holding a partial WakeLock?
|
sudokai |
Yep
|
sudokai |
ForegroundService type=location too
|
Mark M. |
sorry, but I do not have a lot of advice for you
|
sudokai |
Okay, yeah no problem
|
sudokai |
It really sucks
|
sudokai |
Don't work with Android and GPS
|
sudokai |
:)
|
Mark M. |
OK, we're running low on chat time -- if either of you have questions, go ahead!
|
Kai H. |
I have looked at a couple of (open source) android projects and have found that almost none of them have comments or at least very few. Any idea why that is?
|
Mark M. |
are they developed by teams or individuals? a lot of solo developers do not bother with comments
|
Mark M. |
and in some cases, they write books that contain the comments :-)
|
Jan 7 | 9:25 AM |
Kai H. |
Sometimes individuals, often teams.
|
sudokai |
My code has no comments either
|
Mark M. |
my personal commenting approach is: comment the stuff that people might not understand, today or tomorrow
|
sudokai |
:P
|
Mark M. |
IOW, I try to aim for writing comments where I think there will be benefit, not writing comments for the sake of comments
|
Kai H. |
So do I, but I still wondered.
|
Kai H. |
As it makes it a bit hard to understand, at least for me.
|
Mark M. |
for something with an API that I expected arbitrary people to consume, then I try to do a better job with JavaDocs/KDoc-style stuff
|
Kai H. |
But with "normal" Android stuff you don't?
|
Mark M. |
but, in the end, users don't run comments, managers don't (strictly) pay for comments, etc.
|
Kai H. |
But another coder will read the comment.
|
Kai H. |
Or rather won't if it's missing and go "huh???"
|
Mark M. |
I wouldn't comment a findViewById() call, if that's what you mean
|
Kai H. |
Neither would I. But a lot isn't as obvious imo.
|
sudokai |
I don't comment, I make the code clear
|
Kai H. |
For example if Navigation is used or not, where to find certain entry points, thoughts about the architecture and such.
|
Kai H. |
sudokai: I am wondering if that is still possible with Kotlin and Jetpack
|
Mark M. |
Kai: some of that should be documented, but code comments may not be the appropriate place
|
Mark M. |
there might be a Wiki or other team documentation point that contains that sort of material
|
sudokai |
Kai: I avoid language constructs that lead to poor readability
|
Mark M. |
now, for an open source project, ideally that is all visible too, but it might not be, particularly for an open source project maintained by some firm
|
Jan 7 | 9:30 AM |
Kai H. |
sudokai: Right now that feels like 90 % of both Kotlin and Jetpack (currently "migrating" a very small app to kotlin and jetpack)
|
Mark M. |
I'm sorry, but I need to wrap up today's chat
|
Kai H. |
ideally :D
|
Kai H. |
np
|
Kai H. |
Thanks for your time
|
Mark M. |
the next one is Saturday at 4pm US Eastern
|
Mark M. |
have a pleasant day!
|
sudokai |
Thanks
|
Kai H. | has left the room |
sudokai | has left the room |
Mark M. | turned off guest access |