Oct 17 | 9:50 AM |
Mark M. | has entered the room |
Oct 17 | 9:55 AM |
Mark M. | turned on guest access |
EGHDK | has entered the room |
Mark M. |
hello, EGHDK
|
Mark M. |
how can I help you today?
|
Oct 17 | 10:00 AM |
EGHDK |
View paste
|
Mark M. |
hmmmm...
|
Mark M. |
that's disappointing
|
EGHDK |
So am I stuck creating a custom view?
|
Mark M. |
how many colors can the user choose from?
|
EGHDK |
Ideally... all of the colors of the rainbow.
|
EGHDK |
(And every color in between).
|
Mark M. |
then a custom view will probably be the answer
|
Mark M. |
you could look at the other similar bubble implementations, like the one I pointed you to last time, and see how they approached it
|
EGHDK |
If you take another look at this link I sent you:
|
EGHDK | |
Oct 17 | 10:05 AM |
Mark M. |
they may not have the color concept, but they may spark ideas
|
EGHDK |
They have to be doing that "cookie cutter" effect on that picture somehow...
|
EGHDK |
Custom view is your best guess though?
|
Mark M. |
use uiautomatorviewer to see what they're doing
|
EGHDK |
?
|
Mark M. | |
Mark M. |
uiautomatorviewer is reminiscent of Hierarchy View, but it works on production devices
|
Mark M. |
it does not give all the information that Hierarchy View does, but it comes fairly close
|
Mark M. |
since it can be applied to production apps running on production devices, you can use it to inspect the UI of some production app, like whatever it was that resulted in the screenshot you linked to, to see what they do
|
EGHDK |
Gotcha. I've user Hierarchy viewer before.
|
EGHDK |
Before I go into that though. You opinion (as of right now) is to build a custom view?
|
Mark M. |
my opinion is to see what others do, by looking at existing implementations (e.g., the map bubbles that I pointed you to yesterday) and using uiautomatorviewer
|
Mark M. |
my *guess* is that you will wind up with a custom view, rendered using the Canvas drawing primitives
|
Oct 17 | 10:10 AM |
EGHDK |
Okay. The map yesterday was done with 9 patches.
|
EGHDK |
I'm trying uiautomatorviewer, but when I type it in terminal it says "command not found"
|
Mark M. |
do you have $ANDROID_SDK/tools in your PATH? (where $ANDROID_SDK is wherever you have the SDK installed)
|
Jose L. | has entered the room |
EGHDK |
Yeah
|
Mark M. |
then your tools are 12+ months out of date
|
Mark M. |
uiautomatorviewer was released late last year
|
Jose L. |
hello everyone, don't have questions so far, just curious :)
|
Mark M. |
Jose: OK -- if you come up with a question, let me know
|
EGHDK |
When I do ls in /tools, it shows uiautomatorviewer though.
|
Mark M. |
EGHDK: then tools/ must not be in your PATH
|
Mark M. |
regardless, you can switch to the tools/ directory and run it from there
|
EGHDK |
I'm in the tools directory?
|
Oct 17 | 10:15 AM |
Mark M. |
sorry, but I do not understand that question
|
EGHDK |
pwd returns ../android-sdk-macosx/tools
|
Mark M. |
on OS X and Linux, to run a program in the current working directory, use ./ as a prefix
|
Mark M. |
so ./uiautomatorviewer
|
EGHDK |
oh...
|
EGHDK |
That worked =)
|
Mark M. |
if either of you have a question, chime in
|
Oct 17 | 10:20 AM |
EGHDK |
Trying to get whatsapp to launch... not working for some reason. I will try uiautomatorviewer later.
|
EGHDK |
So how would I go about creating a custom view..?
|
Mark M. |
create a subclass of View
|
EGHDK |
Just "View"? Not textView or something?
|
Mark M. |
override methods like onDraw()
|
Mark M. |
well, only if you want to inherit TextView behavior
|
Jose L. |
I'm still struggling with gradle in a multiproject configuration but we already talked about that in a previous chat office hour
|
Oct 17 | 10:25 AM |
Mark M. |
Jose: I doubt that I will be of much help with that at the present time
|
Mark M. | |
Jose L. |
yeah... I didn't want to ask <again> the same question ;)
|
Mark M. | |
EGHDK |
The only behavior I need built in is to be able to call match_parent or wrap_content
|
Mark M. |
is this going to be an empty bubble, then?
|
EGHDK |
Nope. I just need it to scale width wise.
|
Mark M. |
then you are going to need more than "to be able to call match_parent or wrap_content", then
|
Mark M. |
do you want your custom view to be a container (so the contents are handled by some other existing widget)?
|
Mark M. |
or do you want your custom view to render the contents as well?
|
Oct 17 | 10:30 AM |
EGHDK |
I just want the bubble to be able to grow in width when I write more stuff in the bubble.
|
EGHDK |
But the bubble will have to hold about 2 textView inside of it.
|
EGHDK |
One for the persons phone number, and one for the persons actual message.
|
Mark M. |
OK, so that means you want the bubble to be a container, so it can "hold about 2 textView inside of it"
|
Mark M. |
if there is a specific existing container class, like LinearLayout, that implements the rules you want, subclass it as the basis for your custom view
|
EGHDK |
Yeah!
|
Luca L. | has entered the room |
Mark M. |
otherwise, you will need to subclass ViewGroup, and cook up your own rules, which can get complicated
|
Luca L. |
hi all
|
EGHDK |
I guess I would want to extend relative layout?
|
Mark M. |
EGHDK: let me take a question from Luca, and I will be back with you in a bit
|
EGHDK |
Yeah, I want to do that.
|
Mark M. |
Luca: do you have a question?
|
EGHDK |
Okay.
|
Oct 17 | 10:35 AM |
Mark M. |
Luca: if you come up with a question, let me know
|
Mark M. |
EGHDK: if RelativeLayout would be how you want to organize the children, then, yes, you could subclass RelativeLayout
|
Luca L. |
yes
|
Luca L. |
I'm using a WakefulIntentService with startForeground inside onCreate and stopForeground inside onDestroy, i have noticed that if i close the app from recent apps onDestroy will never be called for my service. Is it a normal behaviour?
|
Mark M. |
Luca: onDestroy() is never guaranteed to be called
|
Mark M. |
in a WakefulIntentService, call startForeground() and stopForeground() inside doWakefulWork()
|
Mark M. |
(at the beginning and end, respectively)
|
Luca L. |
ok thank you
|
EGHDK |
Okay so I want to subclass relative layout... cool, but does it also have an onDraw method to override?
|
Mark M. |
everything that inherits from View has onDraw()
|
Mark M. |
which includes everything that inherits from ViewGroup
|
Mark M. |
which therefore includes RelativeLayout
|
Mark M. |
though you will need to call setWillNotDraw(false); somewhere, probably in the constructor
|
EGHDK |
Gotcha. So last question I guess is... in onDraw is where I will need to make my chages to make a bubble. How will I go about drawing it? Using Shapes or Paint or..? I've never tried drawing to the screen before.
|
Mark M. |
please read the documentation at the links I provided earlier in the chat
|
Jose L. |
I might have understood wrong the problem, but I think that for holding two textviews and make the container grow to always wrap the two textviews the only thing you need is to use a normal layout with wrap_content for both width and height
|
Mark M. |
EGHDK: particularly http://developer.android.com/training/custom-vi...
|
Jose L. |
if you use background resources, they will grow
|
Oct 17 | 10:40 AM |
Jose L. |
along with the content
|
Mark M. |
Jose: he wants a map-balloon-style caret
|
Mark M. |
with a colored fill
|
Mark M. |
which does not appear to be readily doable using simple resources
|
Mark M. |
(unfortunately)
|
Mark M. |
without the fill, a nine-patch PNG would suffice
|
EGHDK |
Okay, looks like I will start reading!
|
Luca L. |
tell me when can i ask other questions
|
Mark M. |
Luca: go ahead
|
EGHDK |
Go for it Luca
|
Luca L. |
when using fragments onActivityCreated for what operations is reccommended to be used?
|
Mark M. |
that is difficult to answer in the abstract, sorry
|
Oct 17 | 10:45 AM |
Luca L. |
in some example i have noticed that adapters are created and setted inside onActivityCreated instead of onCreateView, why?
|
Mark M. |
with a ListFragment, the ListView is itself created in onCreateView()
|
Mark M. |
hence, you either need to call super.onCreateView() first (before calling setListAdapter()), or delay the setListAdapter() call to some lifecycle method that will occur after onCreateView()
|
Luca L. |
ok so in custom fragments there is no reason to move code to onActivityCreated unless you need to get something from the activity?
|
Jose L. |
View paste
|
Jose L. |
just trying to help
|
Mark M. |
Luca: I suppose
|
Mark M. |
IMHO, you put the code where it works :-)
|
Oct 17 | 10:50 AM |
Mark M. |
Jose: again, the problem is that the bubble needs a color fill, for an arbitrary user-selected color
|
Mark M. |
I had suggested last time a LayerDrawable consisting of the nine-patch and a ColorDrawable
|
Jose L. |
ah... oh, I missed that part
|
Jose L. |
sorry
|
Mark M. |
but that did not work: http://stackoverflow.com/questions/19410967/fil...
|
Luca L. |
ok thank you, i need to start an internal activity and pass some objects by reference without using parcelable, currently i'm using something like "getApplication().setActiveItems(items)" and "getApplication().getActiveItems()" there are better alternatives?
|
Mark M. |
Luca: well, I do not recommend using Application, as it usually adds no value over your own singleton
|
Mark M. |
and, of course, any static data is a memory leak risk
|
Oct 17 | 10:55 AM |
Mark M. |
plus, since this sounds like model data, make sure that you are only treating the singleton as a static data cache, with the real data being persistet
|
Mark M. |
er, persisted
|
Luca L. |
yes real data is already persisted i need only to pass these objects for read only, so is better to use something like ItemsCache.getInstance().get()/set()?
|
Mark M. |
yes, because you can have as many singletons as you wish, for organizing different data sets
|
Mark M. |
there can be only one custom Application subclass
|
Oct 17 | 11:00 AM |
Mark M. |
and that is a wrap for today's chat
|
Mark M. |
the transcript will be posted to http://commonsware.com/office-hours/ shortly
|
Luca L. |
ok thank you, bye
|
Mark M. |
the next chat will be tomorrow at 4pm Eastern
|
Mark M. |
have a pleasant day!
|
EGHDK | has left the room |
Jose L. | has left the room |
Luca L. | has left the room |
Mark M. | turned off guest access |