Oct 6 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 6 | 4:15 PM |
MyWay | has entered the room |
Mark M. |
hello, MyWay!
|
Mark M. |
how can I help you today?
|
MyWay |
hello again Mark :)
|
MyWay |
I was switching my fragments, but... doesn't ArrayAdapter support Compat? :(
|
Mark M. |
ArrayAdapter has nothing to do with fragments or ...Compat
|
Mark M. |
what exactly is your problem?
|
MyWay |
so I can change the call to the constructor public MyPagerAdapter(FragmentManager...)?
|
Mark M. |
there are four implementations of PagerAdapter supplied by the Android Support libraries
|
Oct 6 | 4:20 PM |
Mark M. |
one axis is whether they work with native fragments or the fragments backport
|
Mark M. |
the android.support.v4 edition of FragmentPagerAdapter and FragmentStatePagerAdapter use the backport
|
Mark M. |
the android.support.v13 edition use native fragments
|
Mark M. |
they take the corresponding v4 or v13 FragmentManager in their constructor
|
Mark M. |
you need to synchronize which PagerAdapter classes you are using with your fragment implementation
|
MyWay |
so I can switch to the support.v13 and chain the fragmentmanager of v13
|
Mark M. |
presumably, yes
|
MyWay |
I thought I needed your arrayadapter to support it
|
Mark M. |
do you mean ArrayPagerAdapter?
|
MyWay |
yes
|
MyWay |
sorry
|
Mark M. |
the main ArrayPagerAdapter works with native fragments
|
Mark M. |
there's a sub-package that has an ArrayPagerAdapter clone that works with the backport
|
Mark M. | |
Mark M. |
"There are two implementations of ArrayPagerAdapter. One, in the com.commonsware.cwac.pager package, is designed for use with native API Level 11 fragments. The other, in the com.commonsware.cwac.pager.v4 package, is designed for use with the Android Support package's backport of fragments. You will need to choose the right ArrayPagerAdapter for the type of fragments that you are using."
|
MyWay |
ah, so I need v4 of everything
|
Mark M. |
consistency is key
|
MyWay |
^^
|
MyWay |
thank you
|
Oct 6 | 4:25 PM |
MyWay |
does google said something about one has to prefer v4 or v13?
|
MyWay |
in my case I need v4 to use your library, but in general?
|
Mark M. |
you don't need to use v4 to use my library
|
Mark M. |
again, there are *two* ArrayPagerAdapter implementations
|
Mark M. |
one for the v4 fragments backport
|
Mark M. |
and one for native fragments
|
Mark M. |
that being said, there are pros and cons with using the backport
|
Mark M. |
clearly, if you want fragments *and* want to support pre-API Level 11 devices, you need the backport
|
MyWay |
but I can't use v13 with your library, right?
|
MyWay |
yes
|
Mark M. |
ArrayPagerAdapter is a *replacement* for FragmentPagerAdapter and FragmentStatePagerAdapter
|
Mark M. |
just as FragmentPagerAdapter and FragmentStatePagerAdapter have two implementations (backport and native), ArrayPagerAdapter has two implementations (backport and native)
|
Mark M. |
"v13", in the context if this chat, refers to FragmentPagerAdapter and FragmentStatePagerAdapter, which you probably are not using, if you are using ArrayPagerAdapter
|
MyWay |
yes
|
Oct 6 | 4:30 PM |
MyWay |
ok, probably I'm doing confusion between the "version" of the Fragments and the Adapter
|
Mark M. |
fragments come in two flavors: the backport (from support-v4) and native (added in API Level 11)
|
MyWay |
so "all" the adapters (native and your) support all those versions
|
Mark M. |
yes
|
Mark M. |
the slight exception is that for the zero devices running Android 3.0 and 3.1, you can't use the v13 editions of FragmentPagerAdapter/FragmentStatePagerAdapter, for some reason
|
MyWay |
I think it's clear now, thank you, I thought I had to use one specific version of the adapter, but as you said, there are two implementations
|
Mark M. |
right
|
Mark M. |
nothing with respect to ViewPager constrains you in terms of whether you use native fragments or the backport
|
Mark M. |
whether you use Google's supplied PagerAdapter implementations, mine, or somebody else's, or your own
|
MyWay |
oh, what about ViewPager?
|
Mark M. |
ViewPager works back to API Level 4, and ViewPager itself has nothing to do with fragments
|
Mark M. |
PagerAdapter implementations may or may not work with fragments
|
Mark M. |
ViewPager just works with a PagerAdapter
|
MyWay |
yes, this seems reasonable
|
Oct 6 | 4:35 PM |
MyWay |
so, I switch my fragments to FragmentCompat
|
MyWay |
FragmentCompat is like Fragment v11?
|
Mark M. |
no
|
Mark M. |
FragmentCompat is a collection of four static helper methods
|
Mark M. |
for some things added to native fragments after API Level 11, these methods allow you to ask for some capability (e.g., request runtime permissions), without having to do version checks yourself
|
Mark M. |
the static methods check the version for you, doing the "real thing" on newer devices, and doing nothing (or something benign, or a work-alike) on older devices
|
MyWay |
simply switching to it, I'm getting some method not found, like getFragmentManager(), getArguments()
|
MyWay |
so something else changed?
|
Mark M. |
"switching to it" -- I do not know what "it" is
|
MyWay |
switching to FragmentCompat, from native Fragment
|
Oct 6 | 4:40 PM |
Mark M. |
again, FragmentCompat is not something you "switch" to
|
Mark M. |
do you mean that you switched to android.support.v4.app.Fragment?
|
MyWay |
I replaced import android.app.Fragment; with the FragmentCompat, so this is wrong
|
MyWay |
because it's not a replace of it
|
Mark M. |
yes, FragmentCompat is not an implementation of fragments, but just a helper class
|
MyWay |
so I just use FragmentCompat statically, when I need, but I still import the "old" native fragment
|
Mark M. |
yes
|
MyWay |
like if I know I need something, if I'm on Android 6 it is going to ask the permission, else not
|
MyWay |
ok, I think now this is clear too, thank you
|
Mark M. |
right
|
MyWay |
so basically I don't even need to change anything, because I'm using the "right" Fragment and the Adapter
|
MyWay |
I mean, I'm already material-ready
|
Mark M. |
I can't really answer that, as I can't see your code from here :-)
|
MyWay |
eheh
|
Oct 6 | 4:45 PM |
MyWay |
the same applies to preferences, right? e.g. I'm extending the native EditTextPreference, this is ok, I don't need the support version
|
Mark M. |
definitely if you are using the native PreferenceFragment
|
Mark M. |
if you are trying to use the backported PreferenceFragment we discussed yesterday, then I don't quite know the rules, as I have not played with thatyet
|
Mark M. |
er, with that yet
|
MyWay |
I've tried playing with it, but it seems a bit harder to manage headers, there are two calls
|
MyWay |
and you have to invent something to "put" and then "select" the right key
|
MyWay |
to choose which category to open
|
Mark M. |
yes, they seem to have backed away from preference headers, for some reason
|
MyWay |
I've also tried the thing you told me about the icon, I've restored it and... its size are wrong
|
MyWay |
lol
|
Mark M. |
there's probably a way to force it to work better, but I never spent the time to try to figure it out
|
Mark M. |
as it'd be a nasty, assume-the-internal-workings sort of hack
|
MyWay |
yes
|
MyWay |
It's like they don't want to, so...
|
MyWay |
I like the idea of a standard, even if I don't like this thing specifically
|
Oct 6 | 4:50 PM |
MyWay |
ah yes, the "problem" was I'm extending PreferenceActivity
|
MyWay |
I could add a toolbar, but probably I will wait
|
MyWay |
I see somebody on stackoverflow is copying AppCompatPreferenceActivity.java
|
Oct 6 | 4:55 PM |
Mark M. |
yeah, creating one should not be too hard
|
Mark M. |
that's what's handy about Android being largely open source
|
MyWay |
thank you very much Mark
|
Mark M. |
you're welcome!
|
Oct 6 | 5:00 PM |
Mark M. |
and that's a wrap for today's chat
|
MyWay |
:)
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
MyWay |
Bye, have a nice day
|
MyWay |
thank you
|
Mark M. |
the next chat is tomorrow at 9am US Eastern
|
Mark M. |
have a pleasant day!
|
MyWay | has left the room |
Mark M. | turned off guest access |