Feb 4 | 3:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Feb 4 | 3:55 PM |
Jonatan R. | has entered the room |
Mark M. |
hello, Jonatan!
|
Mark M. |
how can I help you today?
|
Jonatan R. |
hey Mark!
|
Jonatan R. |
I’m working on app where we have a long list of full screen pictures in a recycler view. I would like to track exactly how long each pictures is visible on screen. If possible to also know how much of each item is visible. Do you have any suggestions how to do this?
|
Mark M. |
for the former, I suppose it depends upon the degree of accuracy you want
|
Mark M. |
a simple approach would be to track when the rows are attached and detached
|
Jonatan R. |
ah
|
Mark M. |
there's a callback for that
|
Mark M. |
onViewAttachedToWindow()
|
Mark M. |
and onViewDetachedFromWindow()
|
Mark M. |
both on RecyclerView.Adapter
|
Gabriele | has entered the room |
Jonatan R. |
that's a good start for sure
|
Mark M. |
(BTW, hello, Gabriele -- I will be with you shortly!0
|
Mark M. |
er, shortly!)
|
Gabriele |
hello
|
Jonatan R. |
any idea on how to see how much of a view is visible?
|
Mark M. |
Jonatan: in terms of how much of each item is visible, there's probably something with clipping rectangles that covers this, but that's way outside my area of expertise
|
Jonatan R. |
hm, ok
|
Mark M. |
let me take a question from Gabriele, and I will be back with you shortly
|
Mark M. |
Gabriele: your turn! do you have a question?
|
Jonatan R. |
sure, thanks
|
Feb 4 | 4:00 PM |
Gabriele |
always on the Leak, Mark: http://pastebin.com/Y4drU87v now that inside onDestroyView() I have mLastActivityAdapter = null; it seems it's not happening anymore, but I have no idea of the reason, can you take a look at mLastActivityAdapter, please? Maybe you find it easy
|
Mark M. |
what does getNickActivities() return
|
Mark M. |
?
|
Gabriele |
it's a LinkedList<String>
|
Mark M. |
ok, and android.R.layout.simple_dropdown_item_1line is just a TextView or something, I presume
|
Gabriele |
yes
|
Mark M. |
what does Command.getInstance().getCommandsList() return?
|
Gabriele | |
Gabriele |
it's a List<String>
|
Gabriele |
... return Collections.unmodifiableList(aCommands); ...
|
Mark M. |
then I have no idea why setting that field to null would have any impact on your AutoCompleteTextView
|
Gabriele |
oh, me neither TT
|
Mark M. |
then again, I haven't used AutoCompleteTextView much, and I have this nagging sense that others have had strange issues with it
|
Gabriele |
so maybe it's due to it
|
Gabriele |
maybe to the fact I'm doing eInput.setAdapter(mLastActivityAdapter);
|
Gabriele |
but I can't see why
|
Mark M. |
I can recommend two courses of action, not mutually exclusive:
|
Mark M. |
1. see if others have had leak issues with AutoCompleteTextView
|
Feb 4 | 4:05 PM |
Mark M. |
2. try to create a small sample project that can reproduce the leak
|
Mark M. |
if you come up with the latter, I'd be interested in taking a look at it
|
Gabriele |
ok, thank you again!
|
Mark M. |
as I foresee AutoCompleteTextViews in my future, so I'd like to know what to avoid :-)
|
Mark M. |
let me take another question from Jonatan, and I will be back with you shortly
|
Mark M. |
Jonatan: your turn! do you have another question?
|
Gabriele |
eheh, sure, I'm ok for today :)
|
Jonatan R. |
Not right now thanks :)
|
Mark M. |
OK, well, if either of you have a question, chime in
|
Gabriele |
sure, thanks Mark
|
Jonatan R. |
View paste
|
Jonatan R. |
Sounds like it could be what I'm looking for
|
Mark M. |
the key is figuring out when to call that
|
Jonatan R. |
right, this is the next problem :)
|
Mark M. |
I haven't looked, but I assume that RecyclerView has some OnScrollListener or the equivalent
|
Mark M. |
if so, you could iterate over the RecyclerView positions at that point to see what is all visible
|
Feb 4 | 4:10 PM |
Jonatan R. |
yes
|
Jonatan R. |
hmm
|
Jonatan R. |
how would you track the time spent, check system millies at onAttach and again on onDetach?
|
Mark M. |
probably
|
Mark M. |
though you also have to take into account activity lifecycle stuff with all of this
|
Gabriele |
(infact it's working even if I comment out eInput.setAdapter(mLastActivityAdapter); instead of nulling mLastActivityAdapter so I'll do a small project with it)
|
Mark M. |
if the user switches to another activity, that affects your timing data
|
Jonatan R. |
hmm, yes
|
Jonatan R. |
cancel timers in onPause perhaps
|
Mark M. |
Gabriele: in terms of leak possibilities, I am less surprised that commenting out setAdapter() clears up a leak than I am that setting that field to null clears up a leak
|
Feb 4 | 4:15 PM |
Mark M. |
Jonatan: right
|
Mark M. |
similarly, if the user rotates the screen, you'll need to re-check your visible rows and stuff
|
Jonatan R. |
yes, thankfully we don't allow rotation
|
Jonatan R. |
all the images are formatted for portrait mode so it wouldn't make much sense
|
Mark M. |
it would on tablets
|
Mark M. |
it would depend somewhat on your UI, I guess
|
Jonatan R. |
hmm, I guess, to be honest I haven't had the time to even look in to tablet compatibility and product owners don't care at all
|
Mark M. |
about one Android device in six is a tablet
|
Jonatan R. |
that's a lot of tablets
|
Mark M. |
yup
|
Feb 4 | 4:20 PM |
Mark M. |
actually, to be fair, there's somewhat conflicting data on this
|
Mark M. |
sales reports indicate that tablet sales are about 20% the size of phone sales (hence, one in six)
|
Mark M. |
Google's dashboards put -large and -xlarge devices at around 13%
|
Mark M. |
and that'll include some phablets
|
Mark M. |
even with that, though, you're looking at 100+ million tablets, possibly closer to 200 million
|
Mark M. |
and, unless you take some icky steps to avoid it, your app will be shipped to tablets
|
jamshaid | has entered the room |
Jonatan R. |
yeah, it's definitely something I will need to look in to more, and let them know
|
Mark M. |
let me take a question from jamshaid, and I'll be back with you shortly
|
Mark M. |
jamshaid: hi! how can I help you today?
|
Jonatan R. |
sure
|
jamshaid |
i used acra . the crashdialogactivity has a cancel button.i wanted to remove it .extending it wont work i guess as acra uses the implementation of its class...i was wondering how can one go about taking a maven project in android studio n changing source code
|
Mark M. |
"the crashdialogactivity has a cancel button.i wanted to remove it" -- I *really* do not recommend that
|
Gabriele |
I've reproduced it on a new project, Mark
|
Mark M. |
your user is already angry with you for crashing
|
Mark M. |
do not make them angrier by trying (and failing) to force them to supply some sort of feedback
|
jamshaid |
but its not a user app so i awnt that this should be not possible to cancel..or better that the report is sent but user is asked to enter input
|
Feb 4 | 4:25 PM |
Mark M. |
whatever
|
Mark M. |
you shouldn't need to change ACRA, though
|
Mark M. |
all of these handlers are pluggable
|
Mark M. |
so, create your own that is implemented how you want
|
Mark M. |
oh, no, wait
|
Mark M. |
never mind
|
Mark M. |
I forgot, that reporting mode is not pluggable
|
Mark M. |
sorry
|
Mark M. |
anyway, it's a Gradle project
|
Mark M. |
just clone the repo
|
Mark M. |
add it as a library module to your project
|
Mark M. |
replace your existing compile statement with a compile project(':acra') (or whatever you call the module)
|
Mark M. |
so you pull in your local copy of ACRA instead of the published artifact
|
Mark M. |
and from there, you have your own independent copy of ACRA, which you can modify as you see fit
|
Mark M. |
(Gabriele: can you upload it somewhere and post a link here, or email the project to me?)
|
Gabriele |
I've used the Android Studio's default project (the one with tabs), changed the TextView with MultiAutoCompleteTextView and added on the Fragment my old code: http://pastebin.com/FxxhwCEP (look for mLastActivityAdapter), I have a new instance of MultiAutoCompleteTextView for every time I press on different tab (about)
|
jamshaid |
when i clone the project do i have to change any files ...normally when i use androd studio n try changes and build again nothing happens.
|
Gabriele |
yes, sure
|
jamshaid |
but i wil try again thanks
|
Gabriele |
but I did only these three steps
|
Mark M. |
jamshaid: that sounds like perhaps your build.gradle file is still using the ACRA artifact, not your local ACRA library module
|
Feb 4 | 4:30 PM |
Mark M. |
jamshaid: double-check your dependencies closure
|
Feb 4 | 4:30 PM |
jamshaid |
i created a new project using import from github for acra.then i tried to change the code in android studio and build but it does not mark even if i do something in correct by deleting some part of the code..so i was wondering if i just do a clone n import directly using github in android studio ...after that before i make changes do i have to change anything in the maven build to build the project again ?
|
Mark M. |
"so i was wondering if i just do a clone n import directly using github in android studio" -- while that will create the library module, it will not attach it to your app
|
Mark M. |
you have to modify your app's build.gradle to pull in your library module, instead of the ACRA artifact
|
Mark M. |
"do i have to change anything in the maven build to build the project again ?" -- I do not know what you mean; ACRA is built by Gradle, not Maven
|
jamshaid |
that i know but when i make changes to the module do i have to change just the source code
|
Mark M. |
yes
|
jamshaid |
thanks i will try again
|
Mark M. |
Jonatan: your turn! do you have another question?
|
Feb 4 | 4:35 PM |
Jonatan R. |
I just started implementing a new signup flow in our app and decided to try a library called Pancake which is basically a simplified viewstack instead of using fragments. Have you used this or some other alternatives to fragments? What’s your preference when designing navigation?
|
Mark M. |
I have not used Pancake
|
Mark M. |
I have considered experimenting with Square's Flow and Mortar, which appear to be the most popular alternative to fragment-based UIs
|
Gabriele |
yes, if I comment textView.setAdapter(mLastActivityAdapter); it's working in this project, too
|
Mark M. |
I haven't had a problem with fragments, but I tend to use them very carefully
|
Mark M. |
Gabriele: "it's working" meaning that you are seeing the leak?
|
Gabriele |
I mean that if I comment it, there is no leak
|
Gabriele |
if I uncomment it, there is the leak
|
Gabriele |
if you have Android Studio you can try yourself, when you have time
|
Gabriele |
I've used the default project so it's fast to deploy
|
Mark M. |
um, well, I've written several book chapters about Android Studio, so... :-)
|
Jonatan R. |
Ok. I considered Mortar and Flow but liked the simplicity of Pancake.
|
Gabriele |
eheh :)
|
Gabriele |
I've always tought Mark programming with some divine instrument
|
Gabriele |
:P
|
Mark M. |
Jonatan: I forget if I have seen Pancake before
|
Mark M. |
I can see what you mean by the simplicity
|
Mark M. |
plus, pancakes are much tastier
|
Feb 4 | 4:40 PM |
Jonatan R. |
haha yes
|
Jonatan R. |
I never heard of it either, it was mentioned on the Fragmented podcast and I checked it out, seemed stable and well tested so..
|
Jonatan R. |
we'll see how it goes
|
Mark M. |
Gabriele: if you can get me the project, I would be interested in taking a look at it
|
Mark M. |
BTW, at this point, it's "open season", so if you have a question, just ask
|
Gabriele |
I will upload it on git then
|
Feb 4 | 4:50 PM |
Gabriele | |
Mark M. |
got it
|
Mark M. |
I probably won't get a chance to look at this until the weekend
|
Gabriele |
to reproduce, when built, I just click on the tabs a lot of time then I check on the Class List View, for the instances
|
Gabriele |
no problem :P
|
Gabriele |
I'm just curios to understand what's going on
|
Mark M. |
I understand
|
Mark M. |
I'm also interested as to why there is a discrepancy between what you were seeing with LeakCanary and what you are getting from the heap dumps
|
Mark M. |
BTW, do you have the link to your Stack Overflow question on this handy?
|
Gabriele |
yes
|
Gabriele |
stackoverflow.com/questions/35153410/cant-find-the-leak-on-my-fragment-android-code
|
Mark M. |
thanks!
|
Gabriele |
to you :)
|
Feb 4 | 4:55 PM |
Mark M. |
Jonatan: if you don't mind my asking, with Pancake, where are you planning on putting your controller logic?
|
Mark M. |
e.g., handling widget events, populating widgets with model data
|
Mark M. |
I get the sense that the Pancake author does not think that such code goes in the ViewFactory
|
Mark M. |
and putting it all in the activity will make for a very fat activity class
|
Mark M. |
that's one of the reasons why I don't mind fragments that much: I like them as a "local controller", with activities mostly handling cross-fragment orchestration
|
Jonatan R. |
I already have a MVP structure in my app so my plan is to have a Presenter for the activity
|
Jonatan R. |
which connects to different services
|
Mark M. |
but, are you decomposing the presenter into separate ones per ViewFactory?
|
Mark M. |
or is it just one big presenter for everything in the activity?
|
Jonatan R. |
I'm just starting so it's not totally clear yet but I'm thinking of just using one presenter for all the views in the signup flow
|
Mark M. |
ah, OK
|
Jonatan R. |
beause there's not that much going on mostly form fills
|
Gabriele |
is there any different widget with setAdapter I could test it on, Mark? just curios
|
Jonatan R. |
and choosing a picture
|
Mark M. |
Gabriele: well, that adapter will work with ListView
|
Gabriele |
curious*
|
Mark M. |
at least, the adapter from your real app will (haven't looked at the adapter in your standalone sample yet)
|
Gabriele |
yes, it's the same, now it's just empty
|
Mark M. |
I suspect that you will find that there's no leak with ListView
|
Feb 4 | 5:00 PM |
jamshaid | has left the room |
Mark M. |
Jonatan: yes, in that case, a single presenter seems reasonable
|
Jonatan R. |
but I will see how it turns out I guess. But it kind of felt nice to just have one presenter for the activity
|
Mark M. |
that depends on how complex the activity is :-)
|
Jonatan R. |
also nice to gather all the views in this way
|
Jonatan R. |
yes :)
|
Mark M. |
anyway, that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
Gabriele |
thank you :)
|
Jonatan R. |
thanks Mark, be well
|
Mark M. |
the next chat is Saturday at 9am US Eastern
|
Mark M. |
have a pleasant day!
|
Gabriele |
yes
|
Gabriele |
there is no leak
|
Gabriele |
:(
|
Jonatan R. | has left the room |
Gabriele | has left the room |
Mark M. | turned off guest access |