Jul 31 | 7:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
ming | has entered the room |
Mark M. |
hello, ming!
|
Mark M. |
how can I help you today?
|
ming |
Hi Mark!
|
ming |
First question is about notification
|
ming |
Is there a way to change the height my notification snippet takes in notification center?
|
Mark M. |
not exactly
|
Mark M. |
there are the big notification styles
|
Mark M. |
but you don't control when those are shown
|
Mark M. |
it's based on where you are in the notification drawer and user preference
|
Mark M. | |
Mark M. |
otherwise, AFAIK, the height is controlled by Android, not developers
|
Jul 31 | 7:30 PM |
ming |
oh
|
ming |
i see an app called
|
ming |
watchon
|
ming |
it shows a remote on notification center, and it takes unusually large height
|
Mark M. |
if you mean Samsung's app, I don't see their notification drawer entry in the Play Store screenshots, so I haven't seen this
|
ming |
i saw it on my friend's samsung s4, is it because samsung made modification to the OS?
|
Mark M. |
it's possible that WatchON has different capabilities on a Samsung device than on others
|
Mark M. |
in fact, looking at the available installation targets, it looks like it might *only* be available for Samsung devices
|
ming |
oh yes that makes sense
|
Mark M. |
hence, they may be doing some sneaky stuff that only works on their devices
|
Jul 31 | 7:35 PM |
ming |
I really wish we can customize the notification center, just like in iOS8
|
ming |
ok, lets talk about listviews. I still don't fully understand how it reuses the view
|
ming |
so in getview() method, one of the argument is convertview, that is the view populated already and will be reused right?
|
Mark M. |
if there is a view to reuse, yes
|
ming |
so let's say i have 10 items in my list, my screen can display 5 of them and it is displaying the first 5 items
|
Mark M. |
OK
|
ming |
I am scrolling so that my 6th item is about to appear
|
ming |
so for this 6th item, which view is it going to reuse?
|
Mark M. |
none of them
|
Mark M. |
convertView will be null, in all likelihood
|
Mark M. |
as the original five views are still visible
|
ming |
wait, so when is a view being reused?
|
Mark M. |
it won't be reused until it is no longer visible
|
Mark M. |
in a ListView, it will have scrolled off the screen
|
Mark M. |
we can't reuse it while it is still visible
|
Jul 31 | 7:40 PM |
ming |
oh i see, so lets say my 1st item is off the screen, 2 to 6 are being displayed
|
ming |
at this time, is the 1st item's view being reused?
|
Mark M. |
probably not
|
Mark M. |
the 1st item was probably visible while the 6th was coming onto the screen
|
Mark M. |
if you scroll up one more, so that 3 to 7 are being displayed, the 1st might be reused at that point
|
ming |
but who's going to reuse 1st view?
|
ming |
7?
|
Mark M. |
yes
|
Mark M. |
when getView() is called for the 7th row, it might be handed the now off-screen 1st row for reuse
|
ming |
oh i see
|
ming |
lets say all items contains a textView, and the text displayed is their corresponding number, 1st item is 1, 2nd item is 2 etc..
|
ming |
when 7th item is using 1st view
|
ming |
if i dont set the text to be 7, is it going to display 1?
|
Jul 31 | 7:45 PM |
Mark M. |
if getView() was passed the 1st row for reuse, then yes
|
Mark M. |
bearing in mind that populating this TextView might be handled by something you are inheriting in your adapter
|
Mark M. |
and therefore it might be updating that TextView, not you
|
ming |
the only place to update textview is in the getview(), i find the reference to the textview, and call getItem(position) to find the string and set the text
|
Mark M. |
that depends a bit on what adapter class you are extending and whether you are chaining to the superclass in getView()
|
ming |
i dont understand by how it being handled by something else
|
Mark M. |
this is covered in the book
|
Mark M. | |
Mark M. |
take a look at the activity
|
Mark M. |
and show me where I am setting the TextView myself in a getView() method
|
Mark M. |
as you'll see, I don't have my own adapter class
|
Mark M. |
I am using ArrayAdapter
|
Mark M. |
and ArrayAdapter is populating my TextView
|
ming |
yes
|
Mark M. |
then, we have this sample: https://github.com/commonsguy/cw-omnibus/tree/m...
|
Mark M. |
here, I am updating one TextView and one ImageView, but I am inheriting from ArrayAdapter, and it is handling the other TextView
|
Jul 31 | 7:50 PM |
Mark M. |
the same thing holds true with most concrete adapter implementations in Android
|
ming |
oh yes
|
ming |
cos getview() in super class may update the view
|
Mark M. |
right
|
ming |
lets talk more about listview
|
ming |
there is a method called getViewCount() and getViewType()
|
ming |
wait
|
Mark M. |
that's getViewTypeCount() and getItemViewType()
|
ming |
i may got it wrong, let me googleit
|
ming |
oh i see. what are the purposes of those two methods
|
Mark M. |
that's covered in the Advanced ListViews chapter
|
Mark M. |
the chapter begins on page 823 of Version 5.9 of the book
|
Mark M. |
you use those if you will have different sorts of rows, with different layouts
|
Mark M. |
such as header rows and regular rows
|
Mark M. |
getViewTypeCount() says how many different types of rows you have
|
Mark M. |
getItemViewType() returns a value, from 0 to getViewTypeCount()-1, indicating which type of row is used for a particular position
|
Mark M. |
AdapterView maintains separate object pools for view recycling
|
Mark M. |
one pool per row type
|
Jul 31 | 7:55 PM |
Mark M. |
so if you implement getViewTypeCount() and getItemViewType(), you are assured that the row handed to you for recycling in getView() will be of the appropriate layout
|
Mark M. |
so you do not get handed a header row to reuse when you need a regular row, or vice versa
|
ming |
oh i see, (getItem(position) instanceof Integer) this is a really smart check
|
ming |
let's talk about multi threading
|
ming |
To me it seems that asynctask and handler they are two best options
|
ming |
I read the book the big nerd ranch guide, the book says use handler for long running tasks
|
ming |
so how do I decide which on to use
|
Mark M. |
that is impossible to answer in the abstract
|
Mark M. |
you choose your approach based on a specific circumstance
|
ming |
I am sorry :( i know that is toooo abstract
|
Jul 31 | 8:00 PM |
ming |
is there a way I can get access to apps produced by google?
|
Mark M. |
what do you mean?
|
Mark M. |
specifically, what does "access" mean?
|
ming |
for example
|
ming |
email
|
ming |
source code
|
Mark M. |
the Email app is part of the Android Open Source Project
|
Mark M. |
the Gmail app is not
|
ming |
source code for gmail app
|
Mark M. |
to get the source code for Gmail, get a job at Google
|
ming |
oh im not good enough :(
|
Mark M. |
the Email app's source code is at https://android.googlesource.com/platform/packa...
|
Jul 31 | 8:05 PM |
ming |
I think I asked all questions I have for now
|
Mark M. |
OK
|
Mark M. |
note that the transcript for the chat will show up at http://commonsware.com/office-hours/ once the chat is over
|
ming |
yes I see. Thank you so much for your time!
|
Mark M. |
you are very welcome
|
ming | has left the room |
Jul 31 | 8:30 PM |
Mark M. | turned off guest access |