Office Hours — Today, November 19

Thursday, November 17

Nov 19
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Paul
has entered the room
Mark M.
hello, Paul!
how can I help you today?
Paul
Greetings. I want to pick your brain about a dilemma I face.
Mark M.
be sure to put my brain back when you're done with it
Paul
Briefly I have an app with 1 activity and two fragments each displayed side by side on a tablet and in a view pager on a smart phone.
7:30 PM
Paul
There is a toolbar attached to the activity but as I test the app more and more it strikes me that there should be two toolbars, one on each fragment.
My dilemma is over whether to continue using the activity attached toolbar and manage it as best I can from each fragment or have no activity toolbar but manage a toolbar on each fragment.
Is that clear so far?
Mark M.
yes
Paul
Now I would love to hear how you would approach this dilemma.
Mark M.
first question: when the user swipes between the pages in the ViewPager, do you want the toolbar to appear to move with the page, or not?
Ron
has entered the room
Mark M.
(BTW, hello, Ron -- I will be with you shortly!)
Ron
(HI)
Paul
Probably less important than getting the content right.
But it would clearly be a nice UX feature.
Mark M.
"it" meaning "move with the page"?
7:35 PM
Paul
yes.
Mark M.
then a toolbar per fragment would seem to be the choice
I'm assuming that your original reason for considering this is to get toolbar buttons closer to the right fragment on the tablet
in which case, a per-fragment toolbar gives you that, plus the desired toolbar-moves-with-the-page behavior
personally, I would *not* want the toolbar to appear to move with the page, if the toolbar is at the top, as that's not what the user will be used to
Paul
My main reason was that the options menus are different on each fragment and the title and sub-title might be different on each toolbar.
Mark M.
in a single-bar approach, the two menus get merged, and you only get the one title
so, if you want each fragment to get its own title, that calls for separate toolbars per fragment
Paul
Yes, that was the catalyst to move me to consider two toolbars, one per fragment.
Mark M.
and since you like the toolbar-moves-with-the-page behavior, you seem to be set
let me take a question from Ron, and I'll be back with you in a bit for more follow-up or other questions
Ron: your turn! do you have a question?
Ron
View paste (8 more lines)

I have a simple multi-flavor app with two buildTypes: debug & release. I'm trying to define a new task in 

build.gradle that will execute under the following circumstances in Android Studio.

When a buildVariant:

a. Is executed on the device via the RUN or DEBUG icons in the toolbar. I would like the task to execute 

immediately before the app is installed on the device.

b. An APK is built via the 'Build APK' menu option on the toolbar.

I've played with this and have defined a task dynamically with the tasks.createTask but I can't seem to figure 

...
Paul
I am. The fact that you did not weigh in with a "that's a stupid idea", helps considerably! Thanks.
7:40 PM
Mark M.
Ron: to be honest, I'm not sure if Android Studio is using Gradle tasks for the install process or not
there is installDebug (and installRelease if you have signing keys), but I haven't paid attention to see if that's what Studio is using or not
Ron
I think it is but I want it to be done on a single variant not all variants
Mark M.
well, deciding which variants to worry about is a matter of filtering them as you loop through android.applicationVariants or android.libraryVariants
Ron
Yeah, I got that part working okay
But trying to 'attach' or 'insert' my tasks between two other tasks is driving me nuts.
Mark M.
I haven't used whenAdded
Paul
Mark, I am going to abort. Thanks for your help and I'll chat with you soon.
Paul
has left the room
Mark M.
I have only chained onto a handful of well-defined tasks (e.g., variant.javaCompile)
Ron
What I am trying to do for any particular variant is insert my task when it 'compiles' or 'builds'
Mark M.
well, javaCompile isn't the worst choice then
7:45 PM
Ron
I have tried that one, any others?
How are you 'chaining in'?
Mark M.
variant.javaCompile.dependsOn task
Ron
Okay, I'll give that a try! Thanks
Mark M.
I'm having difficulty navigating the plugin DSL docs (as usual)
and I'm blanking on other candidates
you can see variant.javaCompile.dependsOn task in action in the Staticizer Gradle plugin sample
part of Version 8.1 of the book
Ron
Yes, it is a real nightmare to figure it our from the docs.
I'll look at your example,
That is all I have for tonight! Thanks again!
Ron
has left the room
Mark M.
you're welcome!
8:25 PM
Mark M.
turned off guest access

Thursday, November 17

 

Office Hours

People in this transcript

  • Mark Murphy
  • Paul
  • Ron