Office Hours — Today, November 7

Tuesday, November 5

Nov 7
9:50 AM
Mark M.
has entered the room
9:55 AM
Mark M.
turned on guest access
10:00 AM
Guy
has entered the room
Guy
Hello Mark ;)
Mark M.
hello, Guy!
how can I help you today?
Guy
battling with the CursorAdapter
what do i put as an int in the flags
Mark M.
um, could you be a bit more specific? :-)
Guy
Mark M.
pass whatever flags you need, or 0 if you do not need any
the only non-deprecated flag is FLAG_REGISTER_CONTENT_OBSERVER
and that is only relevant if you are using a ContentProvider as your data source and are not using a Loader
Guy
when do I need to use a loader?
sorry
Mark M.
the Loader framework, for asynchronous queries (particularly of content providers), is covered in the book
Guy
thanks
10:05 AM
Guy
the adapter is show the first few lines in the listview and spinner and then repeating them. only after I pull down the spinner does it refresh and show the whole list
10:05 AM
Mark M.
if you have another question, go ahead -- quiet chat room today
Guy
thanks
Brett
has entered the room
Brett
Hi Mark
Mark M.
Guy: I am sorry, but I did not understand your last comment. Let me take a question from Brett, and I will be back with you shortly.
Brett: hi -- do you have a question?
Brett
Yes Sir
Guy
Brett
I'm putting the finishing touches on an app that makes use of your Large-Screen Tablet tactic of using a single activity with a fragment for each screen
which works very well by the way!
10:10 AM
Brett
At first, all of my fragment (screen) transactions where using "add", but I was hoping to visually make the previous screen slide out, so I changed the transactions to "replace"
So I'm wondering does Android really treat the replaced fragments any differently after this change? I noticed that destroy still isn't called on the replaced fragment.
Mark M.
replace() is a remove() and an add(), under the covers, AFAIK
Brett
I was surprised that the replaced fragment still maintains it's state after popping the backstack
(and returning to it)
I am adding most screens to the backstack BTW for reverse navigation
Mark M.
I do not recall having tried replace() *and* addToBackStack()
I certainly do not remember the specifics about the expected behavior
Brett
Yeah, the only reason I tried it was to get the nice slide out animation on the "replaced" screen
10:15 AM
Mark M.
sorry that I could not be of greater help on this one
Brett
no worries, just thought I'd bounce it off ya
Mark M.
OK
Guy: with respect to your adapter, I do not think you need to call bindView() yourself in newView(), as that should be done for you
you might also consider caching the result of the cursor.getColumnIndex() lookup calls, as those will not change for the life of the Cursor
and I would probably set up a static HashMap<String, Integer> rather than use the big if-elseif chain for mapping the currency to its icon(?)
beyond those, nothing leaps out at me as being specifically a problem with your adapter, at least from a quick inspection
Guy
the icons are stored locally
Mark M.
well, yes, they are resources
still, I would use something a bit more declarative, rather than have the big if-elseif chain
Brett
has left the room
Mark M.
but that's just a personal style issue, as much as anything
10:20 AM
Guy
OK. although I never used a hashmap, I'll check your book. Thanks :-)
Mark M.
if you have another question, feel free to chime in
Guy
checking out the HashMap
10:25 AM
Guy
is there a reason why the listview and the spinner show results twice and when I pull down the spinner it get right list of results?
Mark M.
I have no idea what Spinner you are referring to
for that matter, I have no idea what ListView you are referring to
Guy
the spinner and the listivew is here https://github.com/gywst/CurrencyExchange/blob/...
Mark M.
you cannot use the same Cursor for two different purposes at once
10:30 AM
Guy
two spinners? or the listview and the two spinners
Mark M.
well, either
a Cursor has internal state that can cause problems if multiple parties are trying to use the Cursor at the same time
Guy
so I should use an arrayadaper instead?
Mark M.
converting your database results into a model ArrayList and using an ArrayAdapter is one possibility
Guy
the app parses a xml from the internet and keeps it in the sqlite db.
Mark M.
are you really using the database for anything other than retrieving all currencies?
if not, I would consider just holding onto the XML
10:35 AM
Guy
downloading the xml once, and reading it again and again till it expires
where and how do I store the XML?
Mark M.
as a file
using standard Java file I/O
probably in internal storage (e.g., getFilesDir())
Guy
and use the same xmlparser I built to readit?
Mark M.
presumably
10:40 AM
Guy
:-)
now I have to rewrite most of the app :-)
Thanks.
Mark M.
"The management question, therefore, is not whether to build a pilot system and throw it away. You will do that. […] Hence plan to throw one away; you will, anyhow."
:-)
Guy
I finished a very intensive mobile course a few months back Java, Android, Objective C and HTML5
5 months 3 times a week.
not enough
10:45 AM
Guy
Thank. that was helpful. see you soon :-)
Mark M.
you're welcome!
10:50 AM
Guy
has left the room
10:55 AM
Mark M.
turned off guest access

Tuesday, November 5

 

Office Hours

People in this transcript

  • Brett
  • Guy
  • Mark Murphy