Dec 16 | 7:20 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Dec 16 | 7:30 PM |
Brent | has entered the room |
Mark M. |
hello, Brent!
|
Mark M. |
how can I help you today?
|
Brent |
Hey Mark.
|
Brent |
Couple of questions.
|
Brent |
First, drag and drop
|
Brent |
I'm trying to use a view that's not in my layout for the dragshadwobuilder
|
Brent |
but it doesn't show up
|
Brent |
I tried to add it programmatically to the layout, but no go
|
Mark M. |
well, I haven't play with drag-and-drop on Android yet
|
Mark M. |
er, played
|
Brent |
ok
|
Mark M. |
so, I haven't set up a DragShadowBuilder or the like
|
Brent |
let's move to fragments and the back button
|
Brent |
ok
|
Brent |
let's shift to that other topic then.
|
Brent |
i think you'll be able to help
|
Brent |
i have a navigation drawer
|
Brent |
and some fragments i switch between
|
Brent |
i want them to be in the backstack, so that when i hit the back button, i go to the previous one
|
Brent |
the problem is that the title and selection in the menu don't properly track
|
Mark M. |
"some fragments I switch between" -- you mean, based upon nav drawer selections?
|
Brent |
the activity title
|
Brent |
and when i hit back enough times, i'm left with an empty activity
|
Brent |
yes
|
Brent |
based on the drawer selections
|
Dec 16 | 7:35 PM |
Mark M. |
I am somewhat skeptical that your desired flow is a good one, but, be that as it may...
|
Mark M. |
are you handling the back stack manually, or via addToBackStack()?
|
Brent |
you mean using the back button as I described? is that the flow you're talking about?
|
Mark M. |
yes
|
Mark M. |
I'd need to look up more on Google
|
Mark M. |
er, Google's nav drawer recommendations
|
Brent |
so you think back should just be allowed to be handled how Android wants it to (i.e., i shoiuldn't override it)
|
Mark M. |
but I don't think the back stack is supposed to survive a jump to another section of your app via the nav drawer
|
Mark M. |
IOW, the back stack should reset if you use the nav drawer to jump to some other spot in the app
|
Mark M. |
but, that's just gut instinct
|
Mark M. |
again, I'd need to look up the recommendations there
|
Brent |
oh. where would the recommendations be?
|
Brent |
somewhere in the layout design stuff, i imagine
|
Mark M. |
the classic design guide on this is http://developer.android.com/design/patterns/na...
|
Brent |
ok. i'll look at that.
|
Mark M. |
Material Design probably has its own guidance, though that seems to be more on pure look-and-feel and less on navigation
|
Mark M. |
but, regardless, let's assume for the moment that what you're trying to do is fine, or that you're going to do it regardless of what some balding guy says :-)
|
Mark M. |
are you handling the back stack manually, or via addToBackStack()?
|
Brent |
I'm not following. you mean whatever is written for material design probably only addresses the look, and the older docs are still valid as far as behavior goes?
|
Brent |
i tried addToBackStack()
|
Mark M. |
well, Material Design is Google's current "be-all and end-all" on design, so I assume a nav drawer is mentioned there somewhere, but I don't know what it would cover
|
Dec 16 | 7:40 PM |
Brent |
if I don't use it at all, back takes me away from the navigation drawer activity entirely
|
Mark M. |
I'm just mentioning it as another spot of Googly design guidance
|
Brent |
which at this point means back to the home screen of the device
|
Brent |
ok
|
Mark M. |
your primary (not mutually-exclusive) options are addToBackStack() or overriding onBackPressed() of the activity
|
Mark M. |
in either case, when the user presses BACK, you'll need to update your nav drawer to match
|
Brent |
yeah, i guess that's where I'm falling down.
|
Mark M. |
in the addToBackStack() path, you would probably register an OnBackStackChangedListener with your FragmentManager
|
Mark M. | |
Brent |
so there's no example that you know of of what I'm trying to do.
|
Mark M. |
actually, I thought my nav drawer examples had this
|
Mark M. |
been a while since I looked at 'em
|
Mark M. |
(the downsides of having a nearly 3000-page book...)
|
Brent |
i meant to look at yours earlier today, but forgot. i'll check it out.
|
Mark M. |
give me a moment to get one loaded up...
|
Brent |
you have a whole chapter on nav drawer
|
Mark M. |
yes, my NavDrawer/Activated sample that I cover in that chapter uses OnBackStackChangedListener
|
Brent |
great. i'll look that over.
|
Mark M. |
like most of my samples, it's a bit simplified, but it should get you going
|
Dec 16 | 7:45 PM |
Brent |
so do you happen to know what the behavior is when back is pressed in your sample?
|
Brent |
is there navigation to earlier selected fragments?
|
Mark M. |
actually, reviewing it, it seems a bit odd
|
Brent |
I see this:
|
Brent |
"If the user presses the BACK button, having the earlier fragment reappear happens automatically. However, we need to fix up the navigation drawer to show the proper row as being activated. To do that, we implement OnBackStackChangedListener on MainActivity and call addOnBackStackChangedListener() on the FragmentManager in the onCreate() initialization work. That way, onBackStackChanged() will be called when there is a change in the state of the back stack. Then, it is merely a matter of calling post() for onNavChanged again, to update the nav drawer:"
|
Brent |
which seems like what i want
|
Mark M. |
yeah, but my FragmentTransactions do not have addToBackStack()
|
Brent |
huh. so they'r not going on the backstack?
|
Mark M. |
something's out of kilter between the prose and the example
|
Mark M. |
le sigh
|
Brent |
shit happens :)
|
Mark M. |
I'll add this to the list of things I gotta investigate...
|
Brent |
so just so i understand, without the addToBackStack there's no place for a back press to go to, right, at least not to a previously viewed fragment
|
Mark M. |
correct
|
Mark M. |
the rough algorithm is: if there's a transaction on the back stack, roll it back, otherwise finish() the activity
|
Dec 16 | 7:50 PM |
Brent |
makes sense. so if i put the fragment transactions on the backstack and use the listener to help me sync up the menu with what's being shown, i should be able to accomplish what I'm trying to do
|
Mark M. |
yes
|
Brent |
i.e., so your sample, but with transactions added to the backstack, should still be a pretty good guide.
|
Mark M. |
well, I'm less than confident about that at the moment... :-)
|
Aaron | has entered the room |
Mark M. |
give me 48-72 hours
|
Mark M. |
I have a book update scheduled, and I'll try to get this cleaned up for that
|
Mark M. |
howdy, Aaron!
|
Aaron |
Hello sir
|
Mark M. |
Aaron: Brent has had a shot at a question, so it's your turn -- do you have a question?
|
Brent |
yeah, I'm good for now, at least
|
Brent |
thanks.
|
Aaron |
I have a problem that i have been bangin my head against. If i could maybe get your input on it. Or just some direction that would be great
|
Aaron |
i have a gist prepared
|
Mark M. |
north by northwest
|
Mark M. |
oh, no, wait, you didn't mean that kind of direction
|
Mark M. |
:-)
|
Aaron |
lol
|
Brent |
not lol ;-)
|
Aaron |
I have shortened the files down because the only related parts have to do with the views
|
Aaron | |
Aaron |
I have a Main activity that has a view pager in it
|
Dec 16 | 7:55 PM |
Aaron |
the view pager holds 4 fragments. One of which is the featured fragment
|
Aaron |
Featured fragment extends a base fragment that has a Staggered grid view in it
|
Aaron |
Using etsy staggered grid view
|
Aaron |
woops i forgot the layouts
|
Aaron |
I am trying to put a webview fragment into the header of the staggered grid view
|
Aaron |
It is an AbsListView if i remember right. I have done this with a list fragment but i am getting an view not found error here
|
Mark M. |
ok, that last entry in the chat seemed to take a left turn
|
Mark M. |
what is an AbsListView?
|
Mark M. |
or, more accurately, *what* is an AbsListView? I know what AbsListView is, but I don't understand the relationship to the rest of your issue
|
Mark M. |
and you have done *what* with a ListFragment?
|
Mark M. |
and *where* are you getting a "view not found error"?
|
Aaron | |
Dec 16 | 8:00 PM |
Aaron |
I have added a header view in a list fragment
|
Aaron |
using childfragment manager
|
Aaron |
specifically adding a fragment into the list header
|
Mark M. |
as to whether or not your staggered grid supports header views, you'd have to ask the author of the staggered grid
|
Aaron |
It does.
|
Aaron |
I have used the header view before to load an image with picasso
|
Mark M. |
as to your error, it seems like the problem is in BaseWebviewFragment
|
Mark M. |
and its relationship to featured_banner_fragment
|
Aaron |
at com.activities.MainActivity.initFragments(MainActivity.java:107)
|
Aaron |
? where do you see the issue with base webview?
|
Mark M. |
java.lang.IllegalArgumentException: No view found for id 0x7f09009e (staging:id/featured_banner_fragment) for fragment BaseWebviewFragment{42fc9768 #0 id=0x7f09009e}
|
Aaron |
well that fragment is the one i am trying to load into that frame layout
|
Dec 16 | 8:05 PM |
Aaron |
featured_banner_fragment is the framelayout
|
Mark M. |
and that is in R.layout.featured_header?
|
Aaron |
Yes I have added that file to the gist
|
Mark M. |
it feels like Android can't find that widget ID
|
Mark M. |
possibly due to how the staggered grid is implementing the header view stuff
|
Aaron |
hmhm
|
Aaron |
that is what i was thinking might be my problem
|
Aaron |
something to do with the lib
|
Mark M. |
stuff like findViewById() relies upon the parents navigating all the children
|
Mark M. |
but that's not automatic
|
Mark M. |
it is up to each ViewGroup implementation
|
Aaron |
Ahh that makes sense is it different if i use findViewByTag?
|