Office Hours — Today, March 18

Tuesday, March 16

Mar 18
8:25 AM
Mark M.
has entered the room
Mark M.
turned on guest access
8:45 AM
Grigore C.
has entered the room
Mark M.
hello, Grigore!
how can I help you today?
Grigore C.
Hello, Mark!
8:50 AM
Grigore C.
I'm having a hard time with navigation and FragmentContainerView
Mark M.
OK, I have used that a bit -- what specifically is not working?
Grigore C.
the response is quite slow.. I press the button and after a delay the fragment is shown
so I guess it's somehow laggy but I don't really understand why
layouts are ok from my point of view, no recycler views or anything complicated
Mark M.
I have not encountered this behavior
a handful of examples from *Elements of Android Jetpack* use navigation and FragmentContainerView
as does the app being built in *Exploring Android*, if I recall correctly
Grigore C.
nice, I'll check them out
Mark M.
you might try running those projects and see if you experience similar problems
if you do not, then the issues are more likely tied to the specifics of the fragments that you are using, and you will need to look into more general performance analysis
Grigore C.
I'm also using databinding and hilt
do you think hilt can be the reason of this? I've used navigation and databinding before and it was ok
Mark M.
I have not used Hilt yet -- I am waiting for a stable release before fussing with it
I would be surprised if Hilt had really bad performance, but it *is* a pre-release version, so there may be bugs
8:55 AM
Grigore C.
the problem is that I don't really know how to inspect and find the reason for this
I will check out your examples
Mark M.
I am "old school", so I would be littering my code with Log.d() calls and trying to see where in my operations the time is going
Grigore C.
same here :D
I got another question if you don't mind
Mark M.
go right ahead!
Grigore C.
It's related to a SO question I saw, but I guess there could be a better solution
this is it
I want to achieve kind of the same design - an edittext with a clickable right side text
9:00 AM
Grigore C.
I think that the nested elements and a screen with a few input fields could be quite expensive
Mark M.
AFAIK, TextInputEditText does not really support that directly, just for an image
I wouldn't be worried about the performance so much, but figuring out how to prevent the text entry from going behind your clickable text may be tricky
particularly when you take things like font scaling into account
this is one of the things that I am looking forward to with Jetpack Compose: it will be easier to fork existing implementations to handle adjacent scenarios like this
Grigore C.
I ve created a edit text, text view and view as the bottom line
Mark M.
yeah, I did something like that once a few years ago
Grigore C.
and include this multiple times in my screen
yes, jetpack compose might be our lord and saviour
Mark M.
I wouldn't go *that* far, but it has its beneifts
er, benefits
Grigore C.
I've always disliked the XML layout stuff
maybe I don't know how to make use of it as I should
Mark M.
your EditText + TextView + View solution could (should?) be wrapped up in a custom View
these are aggravating to create
the biggest benefit of Compose is that creating these things is just part of normal development
9:05 AM
Grigore C.
well, unfortunately I gotta go, but thank you for your help, I'll check out your examples and might come back with a post on the forum if things go wrong
have a nice day!
Mark M.
sounds good! good luck!
Grigore C.
thank you
9:10 AM
trocchietto_Ivano
has entered the room
9:15 AM
Mark M.
hello, Ivano!
how can I help you today?
trocchietto_Ivano
Hello Mark!
Grigore C.
Managed to solve it, Mark. I had really big .png files and loaded them as background.
trocchietto_Ivano
I would like to know about your code in the from rxjava to Coroutine some choice you made to better understand programming
Mark M.
Grigore: yeah, that can be slow -- glad you identified the problem!
trocchietto_Ivano
View paste

sealed class MainViewState {
  object Loading : MainViewState()
  data class Content(val observations: List<RowState>) : MainViewState()
  data class Error(val throwable: Throwable) : MainViewState()
}
why you use an object inside a sealed class I do not get
Mark M.
I do not need multiple instances of Loading
a single Loading object is sufficient
trocchietto_Ivano
thanks
Mark M.
in some of my examples, you will see that I have Error also as an object -- the only one that consistently is a class is Content, because that almost always has data that changes
trocchietto_Ivano
ah
is something like val and var
so you try to have more object that is a kind of val
because functional programming wants immutability
and so is your unidirectional flow
Mark M.
yes
trocchietto_Ivano
ok
9:20 AM
trocchietto_Ivano
I do not get why you use MutableLiveData, are not the same of flows?
or BehaviorSubjects
Mark M.
well, the specific tutorial is moving away from RxJava, so I would not want to use a Subject
trocchietto_Ivano
as you are implementing flow do you use LiveData because you insure a good lifecycle
Mark M.
I could switch that to StateFlow -- I wrote those tutorials long before StateFlow existed
trocchietto_Ivano
ah I got it
Mark M.
I will look to move them to StateFlow in some future book update
trocchietto_Ivano
but I do not get if LiveData should be considered deprecated or is a good practice to use to insure a smooth lifecycle
9:25 AM
Mark M.
there is nothing wrong with LiveData, and if you have a mixed Java/Kotlin project it is probably better to use LiveData
conversely, if your long-term objective is to use Kotlin/Multiplatform, you might want to remove LiveData, as it is very Android-centric
trocchietto_Ivano
I always say to my senior to use as an Holder with viewModels and Lifecycle
and kotlin multiplatform is going to use only Flow and Coroutines
?
Mark M.
Kotlin/Multiplatform will steer you more towards things that are pure Kotlin and have fewer Android hooks
it will be simpler, I expect, to use flows instead of LiveData in a Kotlin/Mutiplatform project
and it may give you more opportunities for sharing code between platforms, as LiveData is Android-only
trocchietto_Ivano
Mark these bullet points replies are invaluable for my growth thanks, if you do not mind expect more in the future
Mark M.
that's what these chats are for! :-)
trocchietto_Ivano
thank you
I will squeeze you as a lemon
I go to a meeting
thank you again
Mark M.
you're welcome!
trocchietto_Ivano
bye Grigore
Kai H.
has entered the room
Mark M.
hello, Kai!
you have about 60 seconds -- got a really quick question? :-)
9:30 AM
Grigore C.
has left the room
Kai H.
lol. Not for that time X)
Thought it would start now.
Ah well. Cu soon.
Mark M.
sorry -- perhaps next time!
note: I am on Eastern Daylight Time for the next six months (UTC−04:00)
the next chat is Saturday at 4pm EDT
have a pleasant day!
trocchietto_Ivano
has left the room
Kai H.
has left the room
Mark M.
turned off guest access

Tuesday, March 16

 

Office Hours

People in this transcript

  • Grigore Cristian-Andrei
  • Kai H.
  • Mark Murphy
  • trocchietto_Ivano