Mark M. | has entered the room |
Mark M. | turned on guest access |
Dec 10 | 4:00 PM |
Michael W. | has entered the room |
Mark M. |
hello, Michael!
|
Mark M. |
how can I help you today?
|
Michael W. |
Hi Mark
|
Michael W. |
In the book chapter Divider on RecyclerView
|
Michael W. |
Drawable divider = getResources().getDrawable(R.drawable.item_divider);
|
Michael W. |
Saw getDrawable deprecated
|
Mark M. |
IIRC, there is a two-parameter version added in Android 5.0, taking a theme ID as the second parameter
|
Mark M. |
that's not available in older versions of Android
|
Michael W. |
I see.. So what's should be?
|
Mark M. |
what I have is perfectly fine for the purposes of that app
|
Mark M. |
"deprecated" means "there's something else that we think that you should consider using"
|
Mark M. |
most stuff that is deprecated continues to work fine
|
Dec 10 | 4:05 PM |
Michael W. |
great..
|
Michael W. |
Another stuff, I'm creating an activity, with Toolbar, and some fragments inside
|
Michael W. |
I have created a fragment transition, and worked on the 'content' which is the one inside Fragment Layout
|
Michael W. |
I want to make the Toolbar also animating, for example the title change
|
Michael W. |
But still not have any idea how to do that
|
Mark M. |
I doubt that it is possible in any supported fashion
|
Mark M. |
Toolbar does not expose its internal workings
|
Michael W. |
I'm trying to put the toolbar inside the fragment, is it a good idea?
|
Mark M. |
um, I cannot really answer that
|
Mark M. |
Toolbar is designed to go wherever you want it
|
Bob S. | has entered the room |
Michael W. |
But then I will have a nested fragment.. Is it nested fragment recommended or not?
|
Mark M. |
using a Toolbar does not require nested fragments
|
Mark M. |
using a Toolbar does not require any fragments at all, for that matter
|
Mark M. |
(BTW, Bob, I will be with you shortly!)
|
Mark M. |
that being said, I am not a fan of nested fragments
|
Mark M. |
I will go out of my way to avoid them
|
Michael W. |
Agree.. Anyway I will let Bob to raise question first
|
Bob S. |
Reading discussions on SO, I see that many people are using the Genymotion emulator. What are your thoughts on the adequacy of the stock emulators and the benefits of using one of the alternatives?
|
Mark M. |
I have never used Genymotion, due to issues that I have had with their license agreement
|
Dec 10 | 4:10 PM |
Bob S. |
Do you find that the stock emulators meet most of your needs?
|
Mark M. |
I tend to use hardware more than emulators, but I have more hardware than does your average Android developer
|
Bob S. |
Okay, thanks.
|
Mark M. |
based on comments that I have seen, my sense is that Genymotion is an improvement over the stock emulators, and neither is as good as hardware
|
Mark M. |
at least, when you have hardware for the scenario that you're trying to test
|
Mark M. |
now, the Android Studio 2.0 emulator looked slick in the demos shown at the Android Developer Summit a few weeks ago
|
Mark M. |
so they're obviously giving it a bit of attention
|
Mark M. |
let me take another question from Michael, and I will be back with you in a bit
|
Mark M. |
Michael: your turn! do you have another question?
|
Dec 10 | 4:15 PM |
Mark M. |
OK, if either of you have a question, go right ahead
|
Michael W. |
Yes, I've just had a nested fragment because I'm trying to create master-detail app in 1 activity
|
Bob S. |
I've been learning more about TaskStackBuilder. In the docs, I've only seen it used with Notifications. Are you aware of other situations where TaskStackBuilder can be put to good use?
|
Michael W. |
And also put ViewPager
|
Mark M. |
Michael: remember that ViewPager does not necessarily require fragments, and neither does master-detail
|
Mark M. |
fragments are typical ways of implementing those, but not the only way
|
Mark M. |
Bob: I think it gets used for up navigation
|
Michael W. |
I thought that ViewPager only works on Fragment.. Even if combining with tab layout also?
|
Mark M. |
ViewPager uses a PagerAdapter
|
Mark M. |
the PagerAdapter base class only knows about Views
|
Mark M. |
the two concrete implementations of PagerAdapter in the support libraries use fragments
|
Mark M. |
but PagerAdapter itself does not
|
Mark M. |
in the book, I have at least one example of a fragment-less PagerAdapter
|
Michael W. |
in the method public Fragment getItem, it should return Fragment right?
|
Mark M. |
that is FragmentPagerAdapter or FragmentStatePagerAdapter that you are referring to
|
Mark M. |
you do not have to use those implementations of PagerAdapter
|
Michael W. |
ok, thanks, Mark
|
Dec 10 | 4:20 PM |
Michael W. |
Btw, still not found the fragment-less PagerAdapter on the book
|
Mark M. | |
Mark M. | |
Michael W. |
Thanks, Mark
|
Mark M. |
see page 763 of Version 6.9 of the book
|
Mark M. |
they are covered in a discussion of how to have more than one page visible in a ViewPager, as one way of making better use of larger screen sizes
|
Michael W. |
Found it, thanks
|
Michael W. |
Regarding the setHasOptionsMenu, is it only useful for modifying menu from fragment?
|
Dec 10 | 4:25 PM |
Mark M. |
it is how a fragment indicates that wants to participate in the action bar
|
Mark M. |
if a fragment does not need to do that, do not call setHasOptionsMenu(true)
|
Mark M. |
(BTW, Bob, if you have other questions, chime in!)
|
Michael W. |
Thanks Mark, just try that
|
Bob S. |
I was recently trying to answer a question on SO that involved background service state, process management, and such. It eventually become clear the user's device was running Xiaomi MIUI and much of what I understood to be the standard Android behavior didn't apply. How far has MIUI diverged from Android? Is it even correct to still call it Android?
|
Dec 10 | 4:30 PM |
Mark M. |
well, AFAIK, Xiaomi MIUI devices are not Google Play ecosystem devices, and therefore do not have to pass the Compatibility Test Suite
|
Mark M. |
in theory, device manufacturers will aim to be close, if they want third-party developers to ship apps on their devices
|
Mark M. |
so, Amazon was worse early on, but has been better in the second and subsequent generations of their Fire devices
|
Mark M. |
in terms of Xiaomi specifically, I haven't picked up one of their devices to try it out, though I'm looking to do so
|
Bob S. |
Got it, thanks.
|
Mark M. |
it wouldn't surprise me if they have tinkered more than average
|
Mark M. |
but I can't cite specific things where they have departed, as I lack direct experience
|
Michael W. |
I have created a RecyclerView with a set of data (some fields, include an image). Each time the activity started it gathered from the server and put into the list of Model.
|
Michael W. |
But when the app close and reopened, it's again download every data, including the images. How to manage this thing?
|
Mark M. |
what exactly do you mean by "close and reopened"?
|
Dec 10 | 4:35 PM |
Michael W. |
close the app and reopen the app
|
Mark M. |
you don't really "close the app" in Android
|
Mark M. |
so, what exactly do you mean by "close the app"?
|
Mark M. |
do you mean "press the BACK button to destroy the foreground activity"?
|
Michael W. |
yes
|
Mark M. |
you are welcome to maintain some process-level data cache, typically in the form of a singleton
|
Mark M. |
your process is not immediately terminated when the user destroys your last foreground activity
|
Mark M. |
and so, if the user returns to your app fairly quickly, your cache can speed up presenting data to the user again
|
Mark M. |
however, you need to take care, as any singleton amounts to an intentional memory leak
|
Mark M. |
you do not want to start causing yourself OutOfMemoryErrors
|
Michael W. |
So the singleton will still exist unless the user destroy the app from the settings?
|
Mark M. |
no, the singleton will exist until the process gets terminated
|
Mark M. |
that can happen at any moment while your app is in the background
|
Mark M. |
once the user presses BACK or HOME, and you are no longer in the foreground, your process is eligible to be terminated, to free up system RAM for other apps
|
Mark M. |
that may happen in milliseconds, seconds, minutes, or hours
|
Mark M. |
it all depends on how much system RAM the device has, how busy the device is, etc.
|
Michael W. |
should I add another 'layer' like SQLite?
|
Mark M. |
you are certainly welcome to persist data to local files
|
Mark M. |
that could be in the form of a second-level cache
|
Mark M. |
or it could be that you work primarily with the local data, synchronizing data with your server as needed
|
Michael W. |
Since now I'm just creating singleton and save the data into the server directly
|
Dec 10 | 4:40 PM |
Mark M. |
BTW, Bob, Google just posted an article about that new Android Studio 2.0 emulator: android-developers.blogspot.com/2015/12/android-studio-20-preview-android.html
|
Mark M. | |
Michael W. |
okay thanks Mark
|
Bob S. |
Great! I'll take a look.
|
Michael W. |
Which one is most appropiate for sync list of data: Android Async vs OKHttp?
|
Dec 10 | 4:45 PM |
Mark M. |
either should be fine
|
Mark M. |
I tend to use OkHttp
|
Michael W. |
Is there any pro cons?
|
Mark M. |
I like OkHttp's API better
|
Mark M. |
it also dovetails nicely with Retrofit and Picasso
|
Mark M. |
I'm not sure if AndroidAsync has SPDY or HTTP/2 support
|
Bob S. |
This is probably not a good question for a chat session, but I'll ask anyway: I'm still looking at Android architecture diagrams to develop a clear picture of what is in firmware and what gets pulled in from the SDK, particularly the Java libraries. Any tips? Pointers to docs?
|
Mark M. |
Bob: you might try books on Android internals, like Karim Yaghmour's
|
Michael W. |
Will try that
|
Mark M. |
the only things in the "SDK" that become part of your APK are the support libraries
|
Mark M. |
any Java class that doesn't begin with android.support. is only in the SDK in stub form, with the real implementation coming from firmware-supplied code, loaded into the zygote
|
Mark M. |
where the zygote is the master SDK app process that all SDK apps get forked off of
|
Mark M. |
now, if your concern is what happens directly in your process versus other processes, or what happens in Java code versus native callouts, that's another matter
|
Mark M. |
books on the internals probably get into that somewhat, particularly on the IPC side
|
Michael W. |
I'm interested with the size of the APK, so if we use the non-android.support one it will be less size in SDK?
|
Dec 10 | 4:50 PM |
Mark M. |
Michael: any code you add to your app makes your app bigger, whether that code is yours or comes from a library
|
Michael W. |
So if I'm targeting >15 better to use non-android.support?
|
Bob S. |
That helps. I do have some understanding of the numerous "system services" and the Binder interfaces to them.
|
Michael W. |
Sorry, I mean >=15
|
Mark M. |
MichaelL: that is a controversial question
|
Mark M. |
using the support libraries, at least to some extent, is nearly unavoidable
|
Mark M. |
the less you use, the better ProGuard can strip out the unused stuff and minimize their impact
|
Mark M. |
if you are really asking "is it better to not use AppCompatActivity?"... that's where the controversy comes in
|
Mark M. |
I am not a fan of appcompat-v7
|
Mark M. |
that's less an issue of size and more an issue of the way appcompat-v7 is implemented and concerns over long-term stability
|
Mark M. |
however, I am in the minority in this opinion
|
Mark M. |
which isn't the first unpopular opinion that I have held, nor will it be the last :-)
|
Mark M. |
using appcompat-v7 and AppCompatActivity is the conventional choice today
|
Mark M. |
I just happen to sneer in the general direction of convention :-)
|
Michael W. |
thanks for the good and honest explanation, Mark :-)
|
Dec 10 | 4:55 PM |
Bob S. | has left the room |
Michael W. |
Last question, I'm trying to make a preference settings
|
Michael W. |
There is a AppCompatPreferenceActivity
|
Mark M. |
that would be if you are using appcompat-v7 and AppCompatActivity
|
Michael W. |
But read on many sources use the PreferenceScreen
|
Mark M. |
a PreferenceActivity or PreferenceFragment uses a PreferenceScreen
|
Mark M. |
I'm not aware of anyone using a PreferenceScreen directly, outside of a PreferenceActivity or PreferenceFragment
|
Mark M. |
I'm not even sure that it is possible, though I've never really looked into it
|
Dec 10 | 5:00 PM |
Michael W. |
I also want to try that one.. Thanks
|
Mark M. |
that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Saturday at 9am US Eastern
|
Mark M. |
have a pleasant day!
|
Michael W. | has left the room |
Mark M. | turned off guest access |