Office Hours — Today, September 8

Tuesday, September 6

Sep 8
3:50 PM
Mark M.
has entered the room
3:55 PM
Mark M.
turned on guest access
MyWay
has entered the room
Mark M.
hello, MyWay!
MyWay
Hello Mark!
4:00 PM
Mark M.
how can I help you today, that doesn't involve Jack? :-)
4:00 PM
MyWay
I'm not just playing with jack unfortunately for you :P
eheh
I'm extending ArrayPagerAdapter with my class MyPagerAdapter and overriding some method, e.g. @Override public void add(PageDescriptor desc) { super.add(desc); }
Paul R.
has entered the room
MyWay
On my activity I'm building the adapter onCreate(...) like this:
View paste
mPages = new ArrayList<>();
if (!isSavedIstance)
	mPages.add(new SimplePageDescriptor(Client.getInstance().getMainChannel().toLowerCase(), Client.getInstance().getMainChannel()));
mAdapter = new MyPagerAdapter(getFragmentManager(), mPages);
Mark M.
(BTW, hello Paul, I will be with you shortly!)
MyWay
For some reason, I have some user getting NullPointerException caused by entries (the array you use inside ArrayPagerAdapter) being null, inside validatePageDescriptor(...) which is called e.g. after add(...). My question is... how is it possible that it's null? If MyPagerAdapter instance was null, than it'd have to stop before, on myPagerAdapter.add() call, so I suppose it's not. But as I'm just calling super(mgr, descriptors); in my constructor I can't understand the reason of getting this exception.
I'm not able to understand how it can be null sometimes
Mark M.
off the top of my head, I can't answer that
are you using the adapter for native fragments or the support-v4 backport?
MyWay
native
onCreate I instantiate it and then magically, even if MyPagerAdapter instance is not null, some user get that NullPointerException
Mark M.
well, I only assign values to entries in three places
two of them are creating new ArrayList instances
the third is in restoreState()
MyWay
infact restore is called on the stack I get from firebase
but I can't understand the reason
Mark M.
so, possibly the saved instance state is getting whacked
or, the custom Parcelable is causing issues
I assume from your phrasing that you aren't able to reproduce this in the lab
MyWay
oh, then it could be possible that this issue is related to Parcelable one
yes, I wasn't able to
4:05 PM
Mark M.
there's not a lot that I can do for you here
you might consider filing an issue on the repo, with the stack trace and other relevant evidence
I'm not sure I'll be able to do a lot there either
but, I'll at least have more ammo
MyWay
keep in mind that in all these months I've never seen this issue reported
and now with the Parcelable one, maybe I'm getting this too
Mark M.
well, I'm happy to blame Jack :-)
MyWay
eheh
I'm getting crazy with it
Mark M.
let me take a question from Paul, and I'll be back with you shortly
Paul: your turn! do you have a question?
MyWay
a lot of problems and I can't find any documentation
sure, sorry :)
Paul R.
I do. three of them actually. The first is that since I noticed chat transcripts are available, how can we use them to our advantage. Do you have some suggestions?
Mark M.
um
well, you could always do a site-specific search on Google, using site:commonsware.com
by volume, most of my site are the chat transcripts and my blog
Lefko
has entered the room
Mark M.
but, beyond that, I don't really have any particular ideas
Paul R.
ok, 2) when developing open source apps, does Proguard obfuscation make any sense?
MyWay
or maybe adding inurl: too? if there is something in the url of the transcript
Lefko
Hello everyone!
Mark M.
(hi, Lefko -- I will be with you shortly!)
Lefko
sure. thanks
4:10 PM
MyWay
hello Lefko
Mark M.
Paul: I don't think that obfuscation is worthwhile in an open source app
Lefko
hey my way
Luca P.
has entered the room
Mark M.
frankly, I don't think that obfuscation is worthwhile in general
(hello, Luca -- I will be with you shortly, after Lefko!)
Paul R.
Good answer. Last question, and the most complicated. I am using managed fragments in an app to build a hierarchy (short one).
I traverse the fragments using the back button and it works perfectly.
But when I background the app and then foreground it, the hierarchy is displayed at the top, not where the User last left off. Clear picture?
Mark M.
I do not understand what "the hierarchy is displayed at the top" means
do you mean that the activity returns to the root fragment of your hierarchy?
Paul R.
There are three fragments in the hierarchy. Call them groups, rooms and messages. Groups is at the top.
If I am seeing messages and then background, when I return to the app I see groups.
More clear?
Mark M.
yes
4:15 PM
Mark M.
if the user is in messages, presses HOME, returns to the app, sees groups, and presses BACK, what happens?
does the user see messages? does the activity get destroyed? or something else?
let me take questions from the others, and I will swing back to you in a bit
Paul R.
The app goes to groups and then shows rooms on a back press. Then exits, probably due to an NPI
NPE
Mark M.
Paul: that sounds like you replaced messages with rooms -- see if you have a FragmentTransaction that does a replace() for a RoomsFragment
(or whatever you call it)
and I'll be back with you in a bit
Lefko: your turn! do you have a question?
Lefko
yes. thanks
In the book you mention that you have a gradle script for uploading artifacts to amazon s3.
I have been struggling for a few days to get this working properly.
Mark M.
actually, I have a shell script for uploading artifacts to Amazon S3
Lefko
ahh
Mark M.
it just uses Amazon's AWS CLI utility
Lefko
Im not so familiar. Ill ask our devops guy
but let me ask you
do you know if the repo needs to have a pom.xml
or is it enough if I got the aar there?
Paul R.
I have a gradle script for that, but i'll have to dig it up and send it to you.
Mark M.
there are two separate steps that I do when I publish a CWAC library
4:20 PM
Lefko
that would be awesome paul
Mark M.
first, I use gradle uploadArchives, which "uploads" my artifact and its generated POM to a local repo on my hard drive
then, I use the shell script to slighly modify that local repo (adding in some stuff that S3 needs) and syncing it with S3
Paul R.
While you chat with Mark, I'll try to chase it down.
Mark M.
the uploadArchives step creates the POM, based on your Gradle configuration
so I don't have a pom.xml in my repo
that's the stanza from my library module's build.gradle file that I run, though a lot of that (the libraryVariants loop) is to prepare plain JARs for those who need them
the constants you see there (e.g., PUBLISH_GROUP_ID) come from gradle.properties, which is not checked into the repo
now, my approach is probably fairly non-standard
there may be cleaner ways to do this now
but, it's working, and so it suffices for now
Lefko
ok thanks. Ill hope that Paul can find his script and if not play with it some more
Paul R.
View paste
fwiw, here's the fragment:    uploadArchives {
    repositories {
      mavenDeployer {
        configuration = configurations.deployerJars
        repository(url: 's3://repo.brightcove.com/releases') {
        }
        snapshotRepository(url: 's3://repo.brightcove.com/snapshots') {
        }
      }
    }
  }
4:25 PM
Mark M.
that's interesting -- didn't know that mavenDeployer recognized s3:// URLs
Lefko
darn, I need one that accepts s3 credentials
Paul R.
You have to provide the secret bits of course in your environment.
Mark M.
that's the same as with the command-line interface (CLI) that I use
Paul R.
Or at least that's what I do.
Mark M.
Lefko: while you ponder all this, let me take questions from the others, and I'll be back with you in a bit
Luca: sorry for the wait! how can I help you today?
Luca P.
Hi Paul, thanks for your time
only one question:
what do yo think about studying third party libraries like Retrofit, GSON, Picasso from a point of view of a beginner? Is it a good path to follow?
Mark M.
by "studying", do you mean looking at how to use them, or how they were written?
Luca P.
I mean using them in a real project
Mark M.
certainly using them is a fine thing
I would not recommend that a beginner try to understand how they work, as all three of those are fairly complex
(Gson in particular)
but understanding how to use them is perfectly reasonable
it's why I cover Retrofit and Picasso in my book
Luca P.
Ok good. Thanks so much
Lefko
View paste
Paul and Mark, heres what Ive been using but no luck with the pom.xml:
uploadArchives {
    repositories {
        maven {
            url 's3://______'

            credentials(AwsCredentials) {
                accessKey = ACCESSKEY
                secretKey = SECRETKEY
            }
        }
    }
}
Mark M.
Lefko: yeah, I haven't tried setting up AWS in Gradle itself, so I won't be of much use to you there
Lefko
ok thanks anyway, and thanks for a great book!
4:30 PM
Mark M.
thanks!
MyWay: your turn! do you have another question?
Lefko
has left the room
MyWay
I'm fine; thank you, Mark
Luca P.
has left the room
Mark M.
OK, if you come up with another question, let me know
MyWay
sure, thanks
Mark M.
Paul: back to you! do you have another question?
Paul R.
I would rephrase my issue as: how should I manage fragments using a backstack across the lifecycles?
Mark M.
well, that should be taken care of for you already
Paul R.
How so?
Mark M.
the big thing is to not accidentally do something yourself to disturb matters
Paul R.
Ah. That begins to make some sense.
Mark M.
well, by "across the lifecycles", and given your earlier question, I assumed that you are referring to pause/stop/start/resume from the activity being moved to the background and then the foreground
in which case, the activity is still intact, with all its fragments
Paul R.
yes.
Mark M.
but, if in, say, onStart(), you run a FragmentTransaction, then that will upset the proverbial apple cart
even if we undergo a configuration change, and the activity is destroyed and recreated, the fragment back stack should be intact
Paul R.
And that, sort of, is what is happening.
Mark M.
um, which that is "that"? :-)
4:35 PM
Paul R.
I think I can take a new tack to avoid the fragment transaction.
Mark M.
OK
Paul R.
The problem is that I shut down listeners when pausing and then restore them when resuming. Some listeners (Firebase) will kick off a authentication change which in turn changes the fragment.
Mark M.
oh, yeah, that doesn't sound good
Paul R.
I will focus on that. Thanks for your help.
Mark M.
BTW, nowadays, consider switching to onStart()/onStop(), due to multi-window
you will be paused while your activity is visible/foreground, but the user is tapping on the other pane of the split-screen, for example
Paul R.
Can you tell me how far back (API level) multi-window gets supported in?
Mark M.
it's new to Android 7.0
Paul R.
I'm guessing not very far. :-)
Mark M.
so that's API Level 24
which is to say, roughly 0.0% of Android devices at the moment
Paul R.
:-)
Mark M.
but it's something to keep in mind
MyWay
is there something that we have to keep inside onResume()/onPause()?
Mark M.
onResume()/onPause() would be for things that you want to not have running while you are not receiving user input
or for things that are so expensive that you want to be more aggressive about shutting them down
Paul R.
Yes, I need to keep eventing for Firebase and the EventBus shut off.
4:40 PM
Mark M.
so, for example, a video player should keep playing through onPause(), and stop playback in onStop()
MyWay
in my case, I can move eventbus too, because if the app is paused and there is multi-window
Paul R.
The EventBus distributes events across the app. Firebase uses it's own events to manage the database.
MyWay
the user can still see messages, right Mark?
Mark M.
if your messages are displayed in your activity, then yes
MyWay
yes
Mark M.
so, for example, a Twitter client should keep updating its timeline through onPause(), only considering shutting some of that down in onStop()
however, if Twitter had some stupid continuous animation effect going on all the time, *that* you might stop in onPause(), as it is non-essential and consumes power
(not to mention the whole "stupid" part)
(and note that I don't use Twitter on mobile, so this is a fictionalized example)
(also, parentheses are fun!)
MyWay
eheh
Mark M.
OK, free-for-all time -- if either of you have a question, go right ahead
Paul R.
I'm all set and chomping at the bit to fix my app. Enjoy, and talk to you soon.
Mark M.
sounds good!
Paul R.
has left the room
4:45 PM
MyWay
I'm using Firebase Crash reporting but it's beta and it's visible it is
you can't hide fixed bugs and nothing
(hide/close)
and when you increment your app version number, you can't upload the ProGuard mapping file until you get a report
Mark M.
sounds like it needs work
MyWay
but then, you can't see this trace :P
and you have to wait the next report
yes
I tought it was mature, even if beta, but it's not
and with Jack I had a lot of problems, I still can't shrink
eheh
4:50 PM
MyWay
I'm hoping for Android Studio 2.2 final and gradle plugin
then I don't think I'm going to move from stable for a bit :P
Mark M.
well, Studio is on 2.2 RC right now, so I would assume it'll hit the release channel soonish
MyWay
yes
oh, and you have no alert of new exceptions on Firebase, so you have to pull yourself!
4:55 PM
Mark M.
hopefully, at least its free
MyWay
there is a free version and an upgrade version if I remember good
but I didn't look at it
I think they give you test-devices and other things with the paid one
Mark M.
ah
MyWay
so their cloud
well Mark, thank you very much for everything, I'll let you know about jack! :P
have a good day
Mark M.
you too!
5:00 PM
Mark M.
that's a wrap for today's chat
the next one is Saturday at 9am US Eastern
have a pleasant day!
MyWay
has left the room
Mark M.
turned off guest access

Tuesday, September 6

 

Office Hours

People in this transcript

  • Lefko
  • Luca Peduto
  • Mark Murphy
  • MyWay
  • Paul Reilly