Aug 18 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Kait | has entered the room |
Mark M. |
hello, Kait!
|
Mark M. |
how can I help you today?
|
Kait |
Hello mark!
|
Jeffrey | has entered the room |
Kait |
I'm trying to make a UI like the event detail in Google Calendar
|
Mark M. |
(BTW, hello, Jeffrey -- I will be with you shortly!)
|
Jeffrey |
Hi Mark, Kait
|
Kait |
Is it possible to have a fragment (like the DetailFragment in List/Detail) put it's content in a layout underneath a CoordinatorLayout?
|
Mark M. |
what do you mean by "underneath"?
|
Kait |
a child view
|
Mark M. |
off the cuff, I don't see why not
|
Aug 18 | 4:00 PM |
Mark M. |
use a FrameLayout as the container for the fragment, if it's a dynamic fragment
|
Kait |
I want a CoordinatorLayout to make the FAB half way between the Toolbar and Fragment content
|
Kait |
It doesn't populate the content
|
Kait |
just blank
|
Mark M. |
what is "it" in "It doesn't populate the content"?
|
Kait |
It will populate the root/CoordinatorLayout, but on-top-of/overlapping the toolbar then :(
|
Mark M. |
again, I do not know what "it" is
|
Kait |
the content from the Fragment does not show up
|
Kait |
it = the app
|
Kait |
no error, but no content either
|
Kait |
just the Toolbar and FAB and nothing below
|
Mark M. |
is onCreateView() being called on the fragment? if yes, what is the ViewGroup you are being passed as the container? is it what you expect?
|
Mark M. |
have you used Hierarchy View or uiautomatorviewer to see if your content wound up there but in an odd state (e.g., visibility set to GONE)?
|
Kait |
I call inCreateView *in* the fragment
|
Mark M. |
you never call onCreateView()
|
Kait |
I don't know how to do that
|
Kait |
"you never call onCreateView()" hmm?
|
Mark M. |
the framework calls onCreateView()
|
Mark M. |
you never call onCreateView() yourself
|
Kait |
on no
|
Kait |
I have an onCreateView in the Fragment. I never explicitly call it
|
Mark M. |
OK, is it being called? if yes, what is the ViewGroup that you are being passed in as the container? is it what you expect?
|
Kait | |
Hoornet | has entered the room |
Aug 18 | 4:05 PM |
Mark M. |
yes, that container -- put a breakpoint there and confirm that you are being called and that the container is the container that you are expecting
|
Mark M. |
(BTW, hello, Hoornet -- I will be you in a bit, after Jeffrey!)
|
Mark M. |
with regards to Hierarchy View and uiautomatorviewer, these are tools for inspecting a running UI
|
Mark M. |
Hierarchy View gives you more detail but typically requires an emulator
|
Mark M. |
uiautomatorviewer works on production hardware
|
Mark M. |
I cover Hierarchy View in the book (though it may need some updating), and I really need to add uiautomatorviewer
|
Mark M. |
let me take questions from the others, and I will swing back to you in a bit
|
Mark M. |
Jeffrey: your turn! do you have a question?
|
Kait |
OK, thanks
|
Jeffrey |
thanks
|
Jeffrey |
View paste
(1 more line)
|
Mark M. |
um, at least for ListView, I think the standard recipe is to get the scroll position, store it yourself in the saved instance state Bundle, and restore it yourself
|
Jeffrey |
if I store the scroll position, how to use it?
|
Mark M. |
well, I'm poking at the RecyclerView docs now
|
Mark M. |
and I'm not really sure what the equivalent recipe would be for it
|
Aug 18 | 4:10 PM |
Mark M. |
I'll have to do some research on this point and add it to some future edition of the book
|
Mark M. |
(not v6.8, which will be out next week, most likely)
|
Jeffrey |
sounds great!
|
Mark M. |
sorry I could not be of greater assistance on that one
|
Mark M. |
let me take questions from the others, and I'll be back with you in a bit
|
Mark M. |
Hoornet: your turn! do you have a question?
|
Jeffrey |
Thanks
|
Mark M. |
Hoornet: your turn! do you have a question?
|
Mark M. |
Hoornet: if you return and have a question, let me know
|
Mark M. |
Kait: your turn! do you have another question?
|
Aug 18 | 4:15 PM |
Kait |
No, it's just this :(
|
Mark M. |
there's not much more I can really tell you
|
Mark M. |
I am not aware that a CoordinatorLayout eats fragments for lunch
|
Mark M. |
so, either the fragment is not being created, or its views are not going where you think they are, or those views are in some state (e.g., visibility GONE) that you are not expecting
|
Mark M. |
breakpoints or logging should tell you the first one
|
Mark M. |
Hierarchy View and/or uiautomatorviewer can help with the latter two
|
Kait |
well, in a detail activity layout (in list/detail) that has a Toolbar, FAB, and container for the coresponding fragment -- how would you set up that layout file? It should be a pretty simple file
|
Mark M. |
off the top of my head, I have no idea
|
Mark M. |
while I cover some of the mechanics of using those widgets in my book, I don't deal with them much otherwise
|
Kait |
ok. thanks for trying. I'll try your suggestions and SO
|
Mark M. |
sorry I could not be of more help
|
Mark M. |
Jeffrey: your turn! do you have another question?
|
Jeffrey |
Thanks, According to my previous question, do you know any examples in your book that I can refer ? or do you know any other key words related my problem so that I can search my problem on the web site precisely?
|
Aug 18 | 4:20 PM |
Mark M. |
well, I just ran a Google search on: recyclerview scroll position configuration change
|
Aug 18 | 4:20 PM |
Hoornet | has left the room |
Mark M. | |
Mark M. |
looks like it's the job of the LayoutManager, which is why I wasn't seeing the details on RecyclerView itself
|
Jeffrey |
ok got it. I use it
|
Mark M. |
if that is not working, that suggests perhaps a timing issue
|
Mark M. |
if you replace your adapter after updating the scroll position, the scroll position is probably lost
|
Jeffrey |
oh!! probably!!
|
Jeffrey |
so that is why I am talking about my coding logic
|
Jeffrey |
if I use the linearManager to save my recyclerview state
|
Jeffrey |
how do I know it is a correct state?
|
Mark M. |
I am not sure what "a correct state" means here
|
Jeffrey |
previous state before I rotate handset
|
Aug 18 | 4:25 PM |
Jeffrey |
I can save previous recyclerview state and rotate my handset and get the previous state out
|
Mark M. |
well, going by the blog post that I linked to, rather than immediately applying the LayoutManager state in onRestoreInstanceState(), you cache it, set up your adapter, then apply the state
|
Jeffrey |
thanks I will try it
|
Jeffrey |
may I ask another question? if there is no one have question
|
Mark M. |
basically, calling setAdapter() on a RecyclerView is a full reset, more or less, and it should dump all prior state, because as far as RecyclerView knows, that state is obsolete
|
Mark M. |
Kait: if you have another question, chime in
|
Mark M. |
Jeffrey: pending another question from Kait, go right ahead
|
Jeffrey |
thanks
|
Jeffrey |
When I use third-party Library for example ActionBarPullToRefreah, I import the project from gradle(app). Then, I want to add some methods in the the project. Can I do it? How? Does you book provide the similar materials?
|
Mark M. |
do you mean that you want to add some methods to ActionBarPullToRefresh?
|
Jeffrey |
yes
|
Mark M. |
you need to download the source code and import it as a library module to your Android Studio project
|
Jeffrey |
I did.
|
Mark M. |
you would replace the previous Maven-based dependency (e.g., compile 'group:artifact:version') with a reference to the library module (e.g., compile project(':whateverYouCalledIt'))
|
Aug 18 | 4:30 PM |
Mark M. |
then, edit the code in the module to suit your needs
|
Mark M. |
if you want to be contributing your changes back to the project, fork the repo, issue pull requests, and so on
|
Mark M. |
while I talk about library modules, I do not cover this specific scenario
|
Jeffrey |
got it, thanks. try it later
|
Jeffrey |
may I ask another question?
|
Kait |
Oh, I do have another question. Do you recommend any particular library for adding charts?
|
Mark M. |
Kait: I have not had a chance to use any, so I am afraid I don't
|
Kait |
Thanks, just wanted to ask
|
Kait |
take it away Jeffery!
|
Mark M. |
Jeffrey: go ahead
|
Aug 18 | 4:35 PM |
Jeffrey |
if I found some open source project on Github, I would like to clone it as my local project. Usually, I cannot because of Grading setting. Do you have any tutorial materials?
|
Mark M. |
sorry, but I do not understand your problem
|
Mark M. |
what is "Grading setting"?
|
Jeffrey |
gradle setting
|
Mark M. |
what is the problem with the gradle setting
|
Mark M. |
?
|
Jeffrey |
yes, I can get all project java files in my IDE. but I cannot run it
|
Mark M. |
what happens when you try to run it?
|
Jeffrey |
let me show you a message. wait a second
|
Aug 18 | 4:40 PM |
Jeffrey |
The project XXX may be using a version of Gradle that does not contain in the method
|
Jeffrey |
Gradle setting
|
Mark M. |
could you take a screenshot, then use the "Upload a file" link on the right to upload it into the chat room?
|
Jeffrey |
The build file may be missing a Gradle plugin
|
Jeffrey |
ok, thnaks
|
Mark M. |
it may be easier for me to understand what you are seeing if I can see it :-)
|
Jeffrey | |
Mark M. |
your problem is that the project in question has not been updated in ~1 year
|
Mark M. |
and it is still using an old version of the Gradle for Android plugin, where we had a runProguard() method
|
Jeffrey |
I do know, sorry
|
Jeffrey |
do not
|
Mark M. |
I recommend that you upgrade the project's Gradle (gradle/wrapper/gradle-wrapper.properties file, distributionUrl value) to something current, like 2.4
|
Mark M. |
then upgrade the Gradle for Android plugin (typically the top-level build.gradle file, classpath statement) to something comparable, like 1.3.0
|
Mark M. |
then, you will need to fix up the old build.gradle file for anything that has changed, like replacing runProguard() with minifyEnabled()
|
Mark M. |
another option would be to create a new project (so you get new Gradle/Gradle for Android settings), copy over all the source into that new project, and try that
|
Mark M. |
basically, leaving the old Gradle stuff behind
|
Aug 18 | 4:45 PM |
Jeffrey |
How to do it in detail? do you have any educational materials in your book? I am not good at using gradle
|
Mark M. |
"How to do it in detail?" -- beyond what I already have here in the chat, that is beyond the scope of these chats
|
Mark M. |
"do you have any educational materials in your book?" -- I have ~80 pages on Gradle and Gradle for Android, but I do not have a specific recipe for how to upgrade somebody else's out-of-date project
|
Jeffrey |
ok, I will try it later. Thanks a lot
|
Mark M. |
is this the project? https://github.com/Aesthetikx/hubski-android/bl...
|
Jeffrey |
yes
|
Mark M. |
step #1: change distributionUrl in https://github.com/Aesthetikx/hubski-android/bl... to http\://services.gradle.org/distributions/gradle-2.4-all.zip
|
Mark M. |
all remaining steps are for https://github.com/Aesthetikx/hubski-android/bl...
|
Aug 18 | 4:50 PM |
Mark M. |
step #2: change classpath 'com.android.tools.build:gradle:0.7.+' to classpath 'com.android.tools.build:gradle:1.3.0'
|
Mark M. |
step #2a: consider changing both mavenCentral() occurrences to jcenter(), particularly if later on Gradle complains that it cannot find that artifact listed in the classpath value
|
Mark M. |
step #3: replace apply plugin: 'android' with apply plugin: 'com.android.application'
|
Mark M. |
step #4: unless you are planning on shipping this as a production app, just get rid of the whole buildTypes {} closure for now
|
Mark M. |
that should clear up the problem from the screenshot
|
Jeffrey |
Cool ! I will try it later. Thanks for your time to answer my questions.
|
Aug 18 | 4:55 PM |
Mark M. |
if anyone has any questions, go right ahead -- we're running out of chat time!
|
Kait |
I'm heading off. Thanks again for your time and expertise!
|
Kait | has left the room |
Aug 18 | 5:00 PM |
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
the transcript will be posted shortly to https://commonsware.com/office-hours/
|
Mark M. |
the next chat is Thursday at 7:30pm US Eastern
|
Mark M. |
have a pleasant day!
|
Jeffrey | has left the room |
Mark M. | turned off guest access |