Aug 26 | 8:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Aug 26 | 8:55 AM |
Gabriele | has entered the room |
Mark M. |
hello, Gabriele
|
Mark M. |
how can I help you today?
|
Aug 26 | 9:00 AM |
Gabriele |
hi
|
Gabriele |
I'm writing a small irc client. To do that I'm using pircbotx, a java library, which give me useful info, like events (onUserJoined, ...). Now I'm trying to get users and put them inside the nicklist (a listview). To do it I'm maintaining a list of users (add a user when he join, remove a user when he quit, ...). I'm using the MVP pattern and the client object is stored inside the Presenter, anyway I think that each activity should have its own Presenter and, as I'm using fragments, the nicklist is part of a different fragment. How can the nicklist (ListActivity/fragment2) access the object stored inside the Presenter? Where is the error, if any, using this pattern?
|
Gabriele |
I've put a screen here: http://android.stackexchange.com/questions/8118...
|
Gabriele |
maybe the client object should not be part of a Presenter?
|
Mark M. |
I have never used MVP, so I cannot readily speak in those terms
|
Mark M. |
any aspect of your model that is used by more than one component, such as more than one activity, needs to live outside of any component, usually via a singleton manager of some sort
|
Gabriele |
so I should have another class which contains my irc client object
|
Gabriele |
and this object should be accessible from the two activities
|
Mark M. |
presumably, yes
|
Aug 26 | 9:05 AM |
Mark M. |
I do not know enough about the nature of your app to state conclusively, but if you have 2+ activities needing access to that IRC client object, neither of them can "own" that object
|
Mark M. |
besides, for IRC, since you have open socket connections, there may need to be a service in the mix as well
|
Gabriele |
why a service?
|
Mark M. |
partly, to make sure that your IRC client handles configuration changes properly, without dropping the socket due to activity destroy/recreate cycles
|
Damian | has entered the room |
Damian |
hi all
|
Mark M. |
plus, you need to consider what the behavior should be when your app moves to the background
|
Mark M. |
(BTW, hello, Damian -- I will be with you shortly!)
|
Gabriele |
ah, true;
|
Mark M. |
Gabriele: it may be that you don't need a service for either situation, but any time I see long-lived socket connections, it is something I suggest that people think through
|
Gabriele |
if I need to maintain the connection opened I need to use it
|
Gabriele |
hi Damian
|
Mark M. |
it is certainly part of the risk of saying that an activity "owns" the IRC client -- you'd have to use a retained fragment or something to make sure that you don't close and re-open the IRC connection
|
Mark M. |
let me take a question from Damian, and I'll be back with you in a bit
|
Mark M. |
Damian: your turn! do you have a question?
|
Gabriele |
yes, sure
|
Aug 26 | 9:10 AM |
Damian |
I have a question that was probably asked but I would like to hear from you Mark your current opinion. I am about to work on application with news. There will be probably CursorAdapter with lots of data(news items). What would be the best approach to implement lazy loading, when user scrolls down "loading" should be visible and when data is ready items should smoothly appear. I have noticed that your library cwac-endlessadapter is retiried, any thoughts on that?
|
Mark M. |
I am not a huge fan of the UI pattern, which is part of the reason I retired the EndlessAdapter
|
Damian |
which UI pattern would you suggest then?
|
Mark M. |
well, it depends on situation
|
Mark M. |
yours is one of the few cases where I'm not as strongly opposed to it, at least for uncovering older news
|
Mark M. |
(use a refresh action item or pull-to-refresh to get newer news)
|
Mark M. |
in general, I'd avoid massive scrolling lists, by steering the user in directions to avoid it (filtering, searching, etc.)
|
Damian |
I don't like very long lists either, but user must be able to see older news
|
Mark M. |
there may be other approaches to that (e.g., ViewPager to access news by category, time period, etc.)
|
Aug 26 | 9:15 AM |
Mark M. |
in terms of how to implement endless logic, IIRC there are two main approaches:
|
Mark M. |
1. do what I did, and have a "magic" View at the end of the list, that when it gets loaded, we know we need to go fetch more data, and use that for a progress indicator
|
Mark M. |
2. pay attention to where the scroll position is in the list, and when it gets within such-and-so distance of the end, work on loading more data
|
Mark M. |
I didn't go with #2 as I felt that it was a bit nondeterministic -- we may or may not have more rows by the time the user actually gets to the end
|
Mark M. |
so since we'd need some sort of progress indicator anyway, we may as well wait until we show it, particularly if the work to get the additional data is relatively cheap (e.g., local files versus teh interwebs)
|
Damian |
ok, thanks, what about data that is already loaded, do you clear it from memory once limited number of rows is reached?
|
Mark M. |
that being said, if you set your "such-and-so distance" far enough, *and* the data loading is cheap, the user is unlikely to hit the end
|
Mark M. |
well, that's tricky
|
Mark M. |
I didn't in my implementation
|
Damian |
i see
|
Mark M. |
you could, using a "windowed" approach
|
Mark M. |
where you release old windows as part of loading new ones
|
Mark M. |
the catch is that you still need to know the full count
|
Mark M. |
and you'd have to check for getting near the end in both scrolling directions
|
Mark M. |
and then splicing "new" data into the top of the list may be troublesome
|
Mark M. |
it is possible that the new RecyclerView will handle this sort of scenario better
|
Mark M. |
but I haven't investigated it yet, partly because it is presently L-specific
|
Mark M. |
and partly because I'm buried in "update the book for Android Studio" work :-)
|
Aug 26 | 9:20 AM |
Mark M. |
let me take a question from Gabriele, and I'll be back with you again shortly
|
Mark M. |
Gabriele: do you have another question?
|
Gabriele |
so I will need a service and from this service send messages and all the other things that needs to be showed inside the client to the activity (when the activity is in the foreground, else don't show anything or use notifications ect...), right?
|
Gabriele |
yes, I'd like to know which pattern you'd use, to do a thing like an irc client :P
|
Gabriele |
so I will try your and mine and check differences
|
Mark M. |
what you're describing seems reasonable
|
Mark M. |
I'd use an event bus -- probably greenrobot's EventBus -- for raising events for the UI layer to handle
|
Gabriele |
is event bus a new thing?
|
Mark M. |
the concept has been around for ages in general, but it only caught on in Android in the past couple of years
|
Mark M. |
I cover it now in the book, and have moved all the tutorials over to use it
|
Gabriele |
oh, nice, I will read about it in the book, then
|
Gabriele |
thank you very much, Mark, see you the next time :)
|
Mark M. |
OK
|
Gabriele |
I will read and try these new things :P
|
Mark M. |
Damian: back to you -- do you have another question?
|
Damian |
What about SQLite Cursor, do you know if it's optimized for large data sets? Is data loaded to the cursor at once?
|
Mark M. |
SQLiteCursor will hold the entire result set if it is less than 1MB
|
Mark M. |
there's some windowing facility built into it for scenarios with larger data sets
|
Damian |
great
|
Aug 26 | 9:25 AM |
Damian |
I have one question about the book subscription, at the moment it's my private subscription but I would like my employer to extend it. Probably they would like to have rights to this subscription and let other developers to use it. Is it possible?
|
Mark M. |
there is an enterprise Warescription program, allowing access to the book by all employees of a firm
|
Mark M. |
it really only makes sense financially if you have a dozen or so developers who would use the book, though
|
Mark M. |
hence, it depends a bit on the size of your employer :-)
|
Damian |
it's big :)
|
Mark M. |
contact me at wares@commonsware.com and I can provide the details if you are interested
|
Damian |
ok, thanks
|
Aug 26 | 9:30 AM |
Damian |
are you going to visit any conference in Europe next year ?
|
Mark M. |
2015?
|
Damian |
maybe Poland? :)
|
Damian |
yes 2015
|
Mark M. |
I'
|
Mark M. |
I'm happy if I know what I'll be doing tomorrow :-)
|
Mark M. |
more seriously, I have no idea what conferences I will participate in next year
|
Mark M. |
I waffle between "let's do more" and "let's stop speaking at conferences"
|
Damian |
my new employer is going to start mobile conferences in Gdansk, Poland. What would convince you to join that conference? Do you charge for that?
|
Mark M. |
I have never been to Gdansk, just Wrocław
|
Mark M. |
your employer is welcome to contact me regarding speaking
|
Aug 26 | 9:35 AM |
Damian |
awesome
|
Mark M. |
in general, my #1 criteria is: will there be a big enough audience to make the trip worthwhile?
|
Mark M. |
and international travel raises the threshold for "worthwhile", simply due to the extra time involved
|
Damian |
true
|
Damian |
i guess it won't be that big at the beginning, I will keep in mind to invite you when it gets bigger
|
Mark M. |
OK
|
Mark M. |
(BTW, Gabriele, if you have another question, chime in!)
|
Damian |
I don't have further questions so I'll be leaving. Thanks, good bye and have a nice day!
|
Mark M. |
you too!
|
Damian | has left the room |
Aug 26 | 10:00 AM |
Mark M. |
that's a wrap for today's office hours
|
Mark M. |
the chat transcript will be posted to http://commonsware.com/office-hours/ shortly
|
Gabriele |
oh thank you
|
Mark M. |
the next chat is Thursday at 4pm US Eastern Time
|
Mark M. |
have a pleasant day!
|
Gabriele | has left the room |
Mark M. | turned off guest access |