Jul 9 | 7:15 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jul 9 | 7:20 PM |
Mark M. | has entered the room |
Mark M. |
testing
|
Mark M. |
testing
|
Mark M. | has left the room |
jdub | has entered the room |
Mark M. |
hello, jdub
|
Mark M. |
how can I help you today?
|
jdub |
Hi Mark
|
jdub |
I am having difficulty putting a HorizontalListView (DevSmartLIb code) into a ListView
|
Mark M. |
I have never used HorizontalListView
|
jdub |
Ok.
|
Mark M. |
you're referring to https://github.com/MeetMe/Android-HorizontalLis... ?
|
jdub |
Yes
|
Mark M. |
what specific problem are you encountering?
|
jdub |
Well
|
Mark M. |
not sure that I can help, but maybe I'll get lucky... :-)
|
jdub |
Ok :-) Here goes
|
jdub |
HorizontalListview is its own class and in its own layout
|
Jul 9 | 7:25 PM |
jdub |
If I setContentView on that layout and provide the adapter, the horizontal scrolling works
|
jdub |
But If I try to add that layout to another
ListView, nothing happens. Its as though setContentView only alllows
one List to be populated
|
jdub |
Sorry if I am explaining it in a confusingg way
|
Mark M. |
when you say "add that layout to another ListView", you mean using that layout as rows from the ListView's own adapter?
|
jdub |
I don't quite understand everthing I am doing
|
EGHDK | has entered the room |
Mark M. |
(hello, EGHDK -- be with you shortly!)
|
jdub |
Well In other words, each HorizontalView object becomes a entry into the "Vertical" ListView
|
Mark M. |
and how are you doing that?
|
jdub |
Not ver successfully I am afraid
|
Mark M. |
OK, I'll ask again: when you say "add that layout
to another ListView", you mean using that layout as rows from the
ListView's own adapter?
|
Jul 9 | 7:30 PM |
Mark M. |
in other words, what are you using for the adapter for the ListView?
|
jdub |
A new adapter
|
jdub |
Can I show you the code?
|
jdub |
It is small
|
Mark M. |
sure, if you can link to it, or paste it here
|
Mark M. |
and you don't mind the world seeing it :-)
|
jdub |
As long as the world won't hold me liable :-)
|
jdub |
Hang on.. let me get it. If you want to answer the other person, that will give time
|
Mark M. |
OK
|
Mark M. |
EGHDK: do you have a question?
|
EGHDK |
View paste
|
Mark M. |
aw, c'mon, I kinda like the look of the sixth "hello" :-)
|
EGHDK |
Hahaha. Problem is, that there are four more hello's right after it that don't show!
|
Mark M. |
anyway, take a look at http://stackoverflow.com/questions/4474237/how-...
|
Mark M. |
FlowLayout was the old Swing component that did this sort of "word wrapping"
|
EGHDK |
View paste
|
Jul 9 | 7:35 PM |
Mark M. |
that in turn links to http://stackoverflow.com/questions/549451/line-...
|
Mark M. |
they both provide links or inline code for various FlowLayout-style containers
|
EGHDK |
Hmm, heard of "Swing" before, but never used it so I'm not familiar with it.
|
Mark M. |
GridLayout can also do this, if you use columnCount
|
Mark M. |
Swing is a Java desktop UI framework
|
EGHDK |
But, awesome, I should be able to use those links
to complete my task. Using a GridLayout is probably not what I want to
do I guess... right?
|
Mark M. |
probably two-thirds of Java desktop apps use Swing for their UI
|
EGHDK |
Gotcha. That makes sense now.
|
Mark M. |
I have not played with GridLayout in the form of having it be a FlowLayout-style replacement, though it should be possible
|
Mark M. |
it has the advantage of being Google-supported (and built into API Level 11+, in addition to the Android Support package)
|
Mark M. |
at the end of the day, though, go with whatever works and you are comfortable with
|
EGHDK |
Wait, so flowLayout only works which API?
|
Mark M. |
I have no idea
|
Mark M. |
there is no FlowLayout in Android, only third-party implementations
|
Mark M. |
as referenced in those two StackOverflow links
|
EGHDK |
Hmmm... alright so I'll have to look into it. Gotcha.
|
Mark M. |
let's switch back to jdub
|
Mark M. |
jdub: are you ready to continue?
|
jdub |
Ok
|
EGHDK |
Well, if you want to take a look at this question and answer it in your spare time you can go ahead ;)
|
EGHDK | |
jdub |
So this won't work but it captures I am trying to do
|
jdub |
View paste
(7 more lines)
|
Jul 9 | 7:40 PM |
jdub |
Naturally I left out a lot
|
Mark M. |
sorry, but I'm lost
|
jdub |
Oh no!!!! :-)
|
jdub |
Allow me to explain
|
Mark M. |
I fail to see where listview is used anywhere
|
Mark M. |
other than as a widget in your existing layout
|
Mark M. |
if you want HorizontalListViews to be the rows of
your ListView, your adapter for the ListView needs to return
HorizontalListViews from getView(), by one means or another
|
jdub |
It does
|
Mark M. |
I'll take your word for that
|
jdub |
You are correct I didn't copy in the overidden getView method
|
Mark M. |
then I am confused by your layouts
|
jdub |
The problem seems to be that the getView method doesn't get called for the layout that is not specified in setContentView
|
jdub |
Go ahead
|
Mark M. |
your layout for the activity is R.layout.listviewdemo
|
Mark M. |
*and* your layout for your rows is *also* R.layout.listviewdemo?
|
jdub |
Yes
|
Mark M. |
how does that work?
|
jdub |
It doesn't
|
jdub |
You are corect.
|
jdub |
The problem I am having is
|
jdub |
setContentView seems to infalte the layout I specify
|
jdub |
If I specify the listviewdemo
|
jdub |
I get the horizontal scroll
|
Jul 9 | 7:45 PM |
jdub |
If I specify the other layout with the list view (and put in say some buttons)
|
jdub |
I get the vertical ListView
|
jdub |
I can't do both
|
Mark M. |
that's because you should have more than one layout file
|
jdub |
Ok
|
Mark M. |
one for the activity, containing your ListView
|
Mark M. |
a second one that serves as the template for your rows, containing your HorizontalListView
|
Mark M. | |
Mark M. | |
jdub |
Ok let me take a look at these...
|
Mark M. |
in those cases, I do not bother with setContentView(), as I am using ListActivity, which supplies a ListView automatically
|
Mark M. |
my layout in each case -- row.xml -- is used to populate the rows
|
Mark M. |
the first one's row is an ImageView and a pair of TextViews
|
Mark M. |
the second one's row is a RatingBar and a TextView
|
Yurii L. | has entered the room |
jdub |
Now ListViewActivity makes the whole activity a listview correct?
|
Mark M. |
by default, yes
|
Mark M. |
you *can* call setContentView() on a ListActivity,
so long as you have a ListView in the layout that is named
android:id="@android:id/list"
|
Mark M. |
but you don't have to if a full-screen ListView is all you need
|
Yurii L. |
Hello everyone.
|
Mark M. |
(hello, Yurii -- I'll be with you in just a moment)
|
jdub |
Ok Mark. Thanks let me chase this dowm
|
Mark M. |
OK
|
jdub |
ThankYOU!!!!!!!
|
Mark M. |
Yurii: you have not had a chance to ask a question yet, so -- do you have a question?
|
jdub |
Ive been fighting this fopr day
|
Yurii L. |
sure, Mark, what is the best way to have reusable FragmentDialogs
|
Jul 9 | 7:50 PM |
Mark M. |
what do you mean by "reusable" in this context?
|
Jul 9 | 7:50 PM |
Yurii L. |
in code I working on, me colleague used dialog builder by passing runnable to be executed on yes or no clicks
|
Mark M. |
I suppose you could somehow do the same thing for a DialogFragment
|
Yurii L. |
instead of creating class for each dialog, I'd like to have fragment dialog to which I can set content, and some action,
|
Mark M. |
personally, I'd use the contract pattern, to have the DialogFragment call methods on the hosting activity when events occur
|
Yurii L. |
how can I pass runnable to dialogfragment?
|
Mark M. |
call a method on your DialogFragment
|
Mark M. |
one that takes a Runnable and does cool stuff with it
|
Yurii L. |
with one activity architechture, should I do the same in coresponding fragments?
|
Mark M. |
I am sorry, but I do not understand what you mean by that
|
Yurii L. |
I have one activity which can hold many fragments, then from fragmen A I want to show DialogFragment D,
|
Yurii L. |
if I use contract pattern, I should created callbacks in Fragment A?
|
Mark M. |
personally, I'd argue that Fragment A wants something to happen, and it is the activity's job to determine how to satisfy that
|
Mark M. |
I do not like fragments working directly with other fragments, as it breaks the fragment UI encapsulation
|
Jul 9 | 7:55 PM |
Mark M. |
I have not experimented with the contract pattern
for a fragment interacting with another fragment, so I do not know
exactly how I would approach that -- sorry
|
Yurii L. |
but in one activity architecture how will you differ one dialog fragment from another?
|
Mark M. |
by class, or by tag
|
Mark M. |
depending on where you are trying to determine the difference
|
Mark M. |
e.g., when trying to retrieve the fragment from a FragmentManager, you usually use a tag with a DialogFragment
|
Yurii L. |
thanks.
|
Mark M. |
let me take questions from the others, and I will come back to you in a bit
|
Mark M. |
EGHDK: do you have another question?
|
EGHDK |
Eh, sort of. Don't know if this is really explainable but I'll give it a shot.
|
EGHDK |
I want to create a game without using OpenGL or unity or anything. Purely a "Java" 2d game.
|
EGHDK |
Before I start I'm realizing that different screen sizes and aspect ratios can really mess up my game. Any ways around that?
|
Jul 9 | 8:00 PM |
Mark M. |
um
|
Liam | has entered the room |
Mark M. |
I am sure that there is more specific game advice
you can get on this subject from whatever game engine you're using
(e.g., andEngine)
|
Mark M. |
beyond that, it would all depend on the game in question
|
Mark M. |
board game vs. side-shooter vs. ...
|
Mark M. |
and since I'm not a game developer, I can only kinda sorta hand-wave around answers
|
Mark M. |
(BTW, hello, Liam -- I will be with you shortly!)
|
EGHDK |
I simply want a square on the bottom of the screen.
|
Liam |
Hey Mark. Thanks.
|
Mark M. |
then have a square on the bottom of the screen
|
EGHDK |
And a sqaure flies from the top of the screen and I have to move my controls to make the two connect.
|
Mark M. |
there is no screen size or aspect ratio that would prevent you from having a square on the bottom of the screen
|
Mark M. |
that too should be fairly flexible for handling screen sizes and aspect ratios
|
EGHDK |
I'll restructure my question, and come back next week with a more detailed scenario. Thanks
|
Mark M. |
OK
|
Mark M. |
Liam: do you have a question?
|
Liam |
yep.. So my question may be a little bit
complicated, but I am going to give it a shot as it has had me stuck for
a couple of weeks now.
|
Liam |
In my app, I am catching a phone call with a
broadcast receiver and then launching a new activity from the broadcast
receiver. My app works perfectly 99% of the time, but when the user
misses the call the phoneApp acquires a wakelock and prevents the phone
from going to sleep. I used the adb dumpsys power to make sure that is
the only wakelock being acquired.
|
Liam |
Any ideas about how to either shut down the phoneApp, clear the wakelock, or some other way to solve the issue?
|
Mark M. |
is "the phoneApp" your app?
|
Mark M. |
or are you really referring to the OS's dialer/phone app?
|
Liam |
no sorry that is the native phone application i beleive
|
Jul 9 | 8:05 PM |
Liam |
actual message in adb is
|
Liam |
PhoneApp'ACQUIRE_CAUSES_WAKEUP activated
|
Mark M. |
yeah, I have no idea
|
Mark M. |
to be honest, I really dislike the family of "intercept the call and interpose something" apps
|
Mark M. |
simply because the framework is not set up for it, and you'll run into problems like this
|
Liam |
okay, no worries. I will keep searching. No way to do a generic clear wakelock right?
|
Mark M. |
no, and definitely not one that's not your own
|
Liam |
okay, that is what i thought. Thanks anyway
|
Mark M. |
sorry I could not be of greater assistance
|
Mark M. |
jdub: do you have another question?
|
jdub |
No I am trying your suggestion now
|
Mark M. |
OK
|
jdub |
I think they will work for me
|
Mark M. |
Yurii: do you have another question?
|
Yurii L. |
sure, what is your suggestion on having viewpager inside slidingpane layotu
|
Mark M. |
I have not tried that, and I can definitely see where there could be problems
|
Yurii L. |
is it posible to make a handle in SlidingPane?
|
Yurii L. |
like 20dp on the left to slide in and out
|
Mark M. |
visually, you can do what you want, just by putting something on that side
|
Jul 9 | 8:10 PM |
Mark M. |
functionally, I don't see an API to control the width of the touch zone
|
Mark M. |
if your content for the "pane" could at all be considered "navigation", I'd consider using DrawerLayout
|
Mark M. |
at least there, you can add the affordance to the action bar
|
Yurii L. |
drawer is already heavily used, application have too deep navigation...
|
Mark M. |
oh, I'd be very concerned with having *both* SlidingPaneLayout *and* DrawerLayout (or a third-party equivalent)
|
Mark M. |
the combination of all those left-edge touch events is likely to tie your app in knots
|
Mark M. |
particularly with your main view being a ViewPager
|
Yurii L. |
do you think it is reasonable to have simple tabs?
it would solve some problem, but I feel like Android users used to
swipe between them
|
Mark M. |
but, beyond that, I do not know of a SlidingPaneLayout + ViewPager recipe, sorry
|
Mark M. |
switching the ViewPager to be a FragmentTabHost or something would simplify the gestures
|
Mark M. |
I agree that it would be nice to offer swiping as well
|
Yurii L. |
thanks
|
Mark M. |
but I have no idea how best to combine all of those
|
Mark M. |
sorry
|
Mark M. |
EGHDK: do you have another question?
|
Jul 9 | 8:15 PM |
EGHDK |
I have a button that creates a DialogFragment, but
if I click the button really fast the DialogFragment opens twice. Any
quick way to make sure nothing else opens up once the DialogFragment is
hit?
|
EGHDK |
Button is hit*
|
Mark M. |
you can disable the button (setEnabled(false)), which will help some
|
EGHDK |
So when my dialog is dismissed I have to setEnabled(true)?
|
Mark M. |
presumably
|
Mark M. |
whenever you want the user to be able to press the button again
|
EGHDK |
Same thing for all of the other buttons on the screen then... I guess right?
|
Mark M. |
I'd worry more about minimizing the time it takes to get the dialog shown
|
Mark M. |
but, yes, if you are concerned about button clicks
in the interval between the launch-the-dialog click and the dialog
taking over touch events, you would need to disable them
|
Mark M. |
and enable them later
|
EGHDK |
It shows up pretty much "instantly", but again if I try hard enough I can click it twice.
|
Mark M. |
you need to decide for yourself how much you want to engineer for this case
|
EGHDK |
Okay, yeah I was guessing that would be the answer.
|
Mark M. |
it's theoretically possible for you to put up a
"glass pane" -- some transparent View that overlays all the buttons but
would be behind the dialog
|
Mark M. |
I have not tried that on Android, though it's an old Swing trick
|
Mark M. |
it also would not give the user any visual feedback that the buttons would not work
|
EGHDK |
Swing to the rescue!
|
Mark M. |
Liam: do you have another question?
|
Jul 9 | 8:20 PM |
Mark M. |
OK, if anyone has a question, chime in
|
jdub |
Will these notes be archived immediately Mark? In case I want to go back to your suggestions?
|
Mark M. |
they will appear at http://commonsware.com/office-hours/ shortly after the chat ends
|
jdub |
Ok Thanks
|
EGHDK |
I have "<requestFocus>" in two of my xml
layouts. The one deeper inside my app works with no problem, but the one
on the MainActivity launcher activity has a cursor blinking in the
editText, but doesn't pull up the keyboard. Any ideas?
|
Mark M. |
did you test this on hardware, or on the emulator?
|
EGHDK |
Both, and both don't work.
|
Mark M. |
I seem to recall that focus on EditText widgets is weird, but I do not remember specifics about this situation
|
EGHDK |
It's funny because the simpler "xml layout" won't
work. All it has is an ImageView and an editText, and my other layout
has a ton of stuff going on.
|
Mark M. |
is the EditText visually getting the focus (e.g., right highlights), beyond just the cursor?
|
Jul 9 | 8:25 PM |
EGHDK |
Also, if I remove requestFocus, the blinking cursor dissapears.
|
Jul 9 | 8:25 PM |
EGHDK |
Hmm... not sure because I have the background simply set to a @color
|
Mark M. |
on an EditText? ick
|
EGHDK |
same exact way it's being done on the layout thats "working".
|
Mark M. |
you might poke through https://github.com/commonsguy/cw-omnibus/tree/m... and the Focus Management chapter and see if anything leaps out at you
|
EGHDK |
Alright, will do. I guess I'll just play around with it some more.
|
Mark M. |
I was fighting with the reverse today, trying to
get the input method editor to go away after executing a search with a
SearchView
|
Mark M. |
(BTW, full-text search coming in the APK formats of future editions of the book!)
|
EGHDK |
Yeah, just can't seem to win em'. Thanks though
|
EGHDK |
Sounds awesome! hahah
|
EGHDK |
I've got two more questions, but I'll save them for next time. Thanks again, see you on thursday.
|
Mark M. |
yes, the next chat will be Thursday at 7:30pm Eastern
|
Yurii L. |
Last quick question? Do you use dependency injection? Any chance to add How to use Dagger in the book?
|
Mark M. |
I have never used DI, and so I'm unlikely to add a Dagger chapter any time soon
|
Yurii L. |
thanks
|
Jul 9 | 8:30 PM |
Mark M. |
well, that's a wrap for today's chat
|
jdub |
Thx Mark
|
Mark M. |
have a pleasant day, all!
|
Yurii L. |
thanks you too!
|
Liam | has left the room |
jdub | has left the room |
EGHDK | has left the room |
Yurii L. | has left the room |
Mark M. | turned off guest access |