Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 9 | 7:30 PM |
Teo I. | has entered the room |
Gabriele | has entered the room |
Gabriele |
hi :)
|
Teo I. |
Hi!
|
Mark M. |
hello, Gabriele and Teo!
|
Teo I. |
Thanks for the book Mark
|
Mark M. |
Teo: it looks like you got in first, so... do you have a question?
|
Mark M. |
you're very welcome!
|
Teo I. |
yes! I'm confused with build types and flavors.
|
Mark M. |
can you be more specific?
|
Teo I. |
1st excuse my bad English. If I wanna have a version with lets say crashlytics. Then this will be a build type ?
|
Mark M. |
I don't know
|
Mark M. |
build types model your development process
|
Mark M. |
product flavors model your distribution channels
|
Mark M. |
so, when would you use a build with Crashlytics, and when would you use a build without Crashlytics?
|
Teo I. |
a debug build without crashlytics for me and a debug build with crashlytics so I can test it with friends.
|
Sep 9 | 7:35 PM |
Mark M. |
then that sounds like a custom build type
|
Mark M. |
let me take a question from Gabriele, and I will be back with you shortyl
|
Teo I. |
ok, thanks.
|
Mark M. |
er, shortly
|
Mark M. |
Gabriele: your turn! do you have a question?
|
Gabriele |
As you probably remember, I'm writing a small irc client. I'm using the same viewPager to swipe Channels and/or Private messages. I have, also, an edittext at bottom, where users write their messages; they must send these messages to the active fragment (which is a channel window or private message window). So, to send the message to the right recipient I must associate each fragment to a "user private window" or to a "channel window", how can I achieve that? I'm already listening OnEditorActionListener to detect when the user sends a message, but even if I detected it, I don't know which is the right action to accomplish, because I don't know which is the current fragment and the user/channel it is associated.
|
Mark M. |
"I don't know which is the current fragment" -- you know which is the current item via getCurrentItem() on ViewPager
|
Mark M. |
figuring out which fragment that it is will be up to you
|
Mark M. |
it might be a bit simpler with my ArrayPagerAdapter
|
Gabriele |
why simpler?
|
Mark M. |
because FragmentPagerAdapter does not give you a way to find out the *existing* fragment for a given position
|
Mark M. |
and, IIRC, ArrayPagerAdapter does
|
Mark M. |
(and if it doesn't, I need to add it...)
|
Sep 9 | 7:40 PM |
Gabriele |
so I should access mypageradapter from inside my listener or you think it's better to use event model and let the pageradapter manage this event?
|
Mark M. |
IMHO, PagerAdapter is not a controller, so it would not handle the event
|
Mark M. |
so, you either need a way to get the fragment for the current index, or go an event bus route and arrange to register/unregister for the event properly with the fragments
|
Mark M. |
so the visible page is the one with the registered subscriber for the event
|
Gabriele |
hm
|
Gabriele |
so inside my onEditorAction method, I should be able to access the pager adapter?
|
Gabriele |
(if choosing the first way)
|
Mark M. |
if that method is on the activity, then yes
|
Mark M. |
assuming the activity is hosting the ViewPager
|
Sep 9 | 7:45 PM |
Mark M. |
let me take a question from Teo, and I will be back with you in a bit
|
Gabriele |
sure, thanks
|
Mark M. |
Teo: your turn! do you have another question?
|
Teo I. |
I don't have a question to ask at the moment.
|
Mark M. |
OK
|
Mark M. |
if you come up with a question, let me know, and I'll swing back to you
|
Teo I. |
ok
|
Mark M. |
Gabriele: over to you!
|
Gabriele |
no, the method isn't on the activity, I have the listener in a separate "java" class
|
Mark M. |
make it an inner class of the activity, or have it hold the PagerAdapter, or something
|
Gabriele |
maybe the inner class is better, yes
|
Gabriele |
considering it's strictly related
|
Sep 9 | 7:50 PM |
Gabriele |
another thing, I'm using eventbus register insidea java class, but I have to unregister it, I thought that when the activity that has the object reference is called stop() or something, I can call unregister to that class and unregister it, is this a decent way of doing it?
|
Sep 9 | 7:50 PM |
Mark M. |
um, I do not know, as I do not completely understand your situation
|
Mark M. |
I recommend registering and unregistering tied to the hosting component's lifecycle methods
|
Gabriele |
I have an activity which holds a java class, A
|
Gabriele |
this class is registering (register(this)) to an event
|
Gabriele |
but then I have to unregister... how should I do it? I thought: when the activity stop()'s get called, I call stop() to the object A, too?
|
Mark M. |
in terms of timing, stick to the lifecycle method pairs
|
Mark M. |
*when* are you registering the object?
|
Gabriele |
(or there is a better way to register/unregister the object of type A?)
|
Gabriele |
I'm doing it when the activity is created
|
Mark M. |
that feels perhaps a bit early, but if that's what you want, unregister in onDestroy()
|
Mark M. |
if you want to unregister in onStop(), then register in onStart()
|
Gabriele |
if I remember correctly I'm not sure that onDestroy gets called, right?
|
Mark M. |
the only times it will not get called are if your process is terminated (in which case, the whole event bus is gone) or you have an unhandled exception (in which case, you have other problems)
|
Sep 9 | 7:55 PM |
Gabriele |
and if the app gets "deleted" from the recent apps, with a swipe, what happens?
|
Mark M. |
the process is terminated
|
Gabriele |
in which case it doesn't matter, because event bus gets too
|
Mark M. |
right
|
Gabriele |
ok, thank you Mark
|
Gabriele |
I don't have questions anymore, today! Thanks, as always!
|
Mark M. |
you are very welcome
|
Gabriele |
good continuation and have a nice day (if it's not too late, to you!)
|
Gabriele |
see you the next time :)
|
Mark M. |
the next chat is next Tuesday at 7:30pm US Eastern Time
|
Gabriele | has left the room |
Sep 9 | 8:00 PM |
Teo I. |
I have to leave now. I'll be back next Tuesday with questions. Thank you
|
Mark M. |
have a pleasant day!
|
Teo I. |
you too!
|
Sep 9 | 8:10 PM |
Jim D. | has entered the room |
Mark M. |
hello, Jim
|
Mark M. |
Jim: Teo is currently out of questions, so, do you have a question?
|
Jim D. |
Hello,
|
Jim D. |
View paste
|
Mark M. |
do you have Gradle installed? if so, what version?
|
Sep 9 | 8:15 PM |
Jim D. |
It just updated itself to 0.8.9
|
Mark M. |
that's Android Studio, not Gradle
|
Mark M. |
I need to point out on the GitHub repository, and in the book, that you need your own installed copy of Gradle 1.12 to be able to import the projects
|
Jim D. |
Is that the standalone gradle, not the plugin?
|
Mark M. |
yes, from gradle.org
|
Jim D. |
OK, I just started, and I was confused about plugin vs standalone. Will both play together
|
Mark M. |
I am not sure exactly what plugin you are referring to
|
Jim D. |
There is a plugin for gradle installed with the Android Studio bundle>
|
Sep 9 | 8:20 PM |
Teo I. | has left the room |
Mark M. |
yes, that plugin will work with Gradle installed from gradle.org
|
Jim D. |
OK, I will install 1.12 from Gradle. Thanks
|
Jim D. | has left the room |
Sep 9 | 8:30 PM |
Mark M. | turned off guest access |