Office Hours — Today, December 28

Thursday, December 17

Mark M.
has entered the room
Mark M.
turned on guest access
Dec 28
9:05 AM
Drasko
has entered the room
Drasko
Hi Mark!
Mark M.
hello, Drasko
how can I help you today?
Drasko
Well, I have that design for row and I am not sure what would be the correct approach to set layout for it.
I will give you URL soon.
Score
9:10 AM
Drasko
So, this should be one row in RecyclerView and I am trying to avoid nested layouts.
Mark M.
um, nested layouts are unavoidable
Drasko
For example, I used RelativeLayout as a parent layout
Mark M.
I don't see how you can implement that with just a RelativeLayout
Drasko
And everything besides that little table are direct children of RelativeLayout, but I am not sure what should I do with that table. Since these columns should be evenly distributed, I guess I should put it into another LinearLayout and setting weight.
Mark M.
personally, I wouldn't do it that way, and I'm not sure that you can get it to work the way you want, but you are welcome to try
Drasko
But when I put it, then I have to use another vertical LinearLayout for each column, right?
great, how would you do it?
:)
Mark M.
outermost: horizontal LinearLayout
9:15 AM
Mark M.
that holds two TableLayouts, using weights to divide the space between them per whatever rules you have
left TableLayout has the league, teams, time, and score
right TableLayout has the title and... ummm... whatever the 1/X/2 table is
Drasko
ok. :)
Mark M.
nine-patch PNGs for the backgrounds of the cells for the 1/X/2 part
and that's about it
Drasko
how many passes would be needed to generate TableLayout? For this horizontal LinearLayout two passes will be needed, right?
Mark M.
beats me
IMHO, that's not a major concern
Drasko
Hahahahaha..
I am curious about it, beacuse I have a performance issues on my mind.
Mark M.
if you have 100 developers working on this, and therefore you have tons of engineering time to spare, and you want to optimize to that level, fine
otherwise, I would start with something that works, then worry about it if and only if there is a user-perceptible issue
Drasko
no, I have only 1 developer, and that developer is men. :)
...and that developer is me. sorry, typo.
Mark M.
particularly since this is all just text (no lazy-loading images), and since there are only so many football matches, I doubt that the user will perceive lag when scrolling
Drasko
and yes, you are right about it.
Mark M.
now, you could try PercentFrameLayout or PercentRelativeLayout instead of the horizontal LinearLayout
9:20 AM
Mark M.
my performance tests showed no advantages, but Google claims the Percent... classes are faster
Drasko
hm, interesting idea. i will try one of these options you gave. thanks a lot!
Mark M.
BTW, what *is* that 1/X/2 table?
the rest is recognizable, even to an American like me
Drasko
hahaha, 1/x/2 represents three types of betting for game called in this example "Final score". So, coefficient that home team (1) will win is 2.40, coefficient that they will have tie (X) is 3.40, and coefficient that guest team will win is 2.90.
Mark M.
ah, OK
9:25 AM
Drasko
data will be changed in every eight seconds and that is why I am curious about performances.
Mark M.
the performance from rendering will be mostly seen when scrolling; rate of model data change should not matter at that level
Drasko
ok, thanks
9:35 AM
Drasko
oh, one more question.
Mark M.
go ahead
9:40 AM
Drasko
In my project, couple of fragments are registered to listen to Green Robots' EventBus events. Now, I have in some separate thread some data fetching and storing and when that cycle is finished I simply post that this is over. I would like to be notified of it in onEvent and somehow try to update views in UI thread, without using onEventMainThread. What would be the best approach for doing this?
Mark M.
what is the specific problem with using onEventMainThread()?
UI fragments shouldn't be using onEvent(), IMHO
Drasko
Because of what is stated in documentation: If the posting thread is the main thread, event handler methods will be called directly. Event handlers using this mode must return quickly to avoid blocking the main thread.
Mark M.
I mean, there's nothing stopping you from using runOnUiThread() or something in onEvent(), but I fail to see what you're gaining over just using onEventMainThread()
in this case, you know that the posting thread is not the main thread
9:45 AM
Drasko
are you against of using onEventMainThread() in UI fragments, too?
Mark M.
no; onEventMainThread() is what UI fragments should be using
Drasko
ah, ok.
thanks!
Mark M.
pure model fragments, which are mostly just containers of data, could use other onEvent...() flavors
but if you're trying to update the UI, you need to be on the main application thread, and onEventMainThread() is the most straightforward way to do that
Drasko
View paste
Thanks!
Don't know what I just did...:)
9:50 AM
Drasko
I don't have any question. Good bye and Happy New Year! If you come sometimes to Belgrade, Serbia, I will be more than happy to meet you. Bye.
Mark M.
have a pleasant day!
Drasko
has left the room
10:00 AM
Mark M.
turned off guest access

Thursday, December 17

 

Office Hours

People in this transcript

  • Drasko
  • Mark Murphy