Office Hours — Today, March 17

Tuesday, March 15

Mar 17
9:50 AM
Mark M.
has entered the room
9:55 AM
Mark M.
turned on guest access
10:00 AM
Thierry-Dimitri R.
has entered the room
Mark M.
howdy, Thierry!
Thierry-Dimitri R.
Hi Mark
Mark M.
how can I help you today?
Thierry-Dimitri R.
I have a question for you: I'm building a news application. I download image for each news item that I stored on the sd card to fetch them later. I do not want to fill up 100 megs on the sd card. When would be the appropriate them to clean those that are more that 1 day old? Do an AsyncTask when my main activity onCreate is called? onDestroy()? Or setup an Alarm task during the night?
Mark M.
when are you doing the downloads?
10:05 AM
Dimitri
has entered the room
Thierry-Dimitri R.
during the onCreate(), I start an AsyncTask to get the last 25 items, which I store into a list. This list start other async task to download the image when the user scrolls through the items
Dimitri
Hello
Mark M.
howdy, Dmitri!
Thierry: I would recommend the nightly Alarm task, then
no sense in adding more flash I/O than necessary right when the user is using the phone
Dimitri: do you have a question?
Thierry-Dimitri R.
That's what I thought. Thanks
Also, I really loved each of your AnDevCon presentation. Is there a screencast of your anti-pattern talk?
Dimitri
Yes sorry was waiting for you to finish with Thierry
Mark M.
Dimitri: no problem, but ask away!
Thierry: no screencast, but the slides are up on https://commonsware.campfirenow.com/01de5
Thierry-Dimitri R.
Thanks Mark
10:10 AM
Dimitri
I recently posted a question regarding Custom Autocomplete and implementing Filterable i have seems to have solved that problem.
View paste
What i would like to do now is have (2) Auto-Complete boxes in a single activity. Initially, onCreate both Auto-Complete boxes values will be filled with the same data.

If the user inputs his selection in one auto-complete box (filtered based on initial data) upon selection of the item, the other auto-complete box (underyling data) needs to be updated based on the item selected
Mark M.
what sort of adapter are you using for the 2nd AutoCompleteTextView?
Dimitri
I posted a question on StackOverflow regarding update the underlying adapter but i have yet to receive an answer...
sorry
an ArrayAdapter<Object>
Mark M.
OK, so when the user enters something into the 1st AutoCompleteTextView, call add() on the ArrayAdapter
where specifically are you running into problems?
10:15 AM
Mark M.
while Dimitri ponders that...Thierry: do you have another question?
Tejas
has entered the room
Mark M.
howdy, Tejas!
Tejas
Hi Mark !
Dimitri
sorry i was reading about add() . This will Adds elements at the end of the array. But i want to constantly refresh my adapter list....
Mark M.
Dimitri: Call add() on the ArrayAdapter. It will "automatically refresh [your] adapter".
Dimitri
View paste
So what i do is call new StationAutoCompleteAdapter(Main.this, getStations(mOrigin));
10:20 AM
Thierry-Dimitri R.
has left the room
Mark M.
I am going to try to handle both of your threads simultaneously -- Tejas: do you have a question?
Tejas
nopes... but will just be passive until some question strikes me
Mark M.
OK
10:25 AM
Dimitri
Sorry i have just realized that i have completely mixed up my question... I am updating two things my ArrayAdapter<Station> and my CustomAutoCompleteAdapter<Station> both are used by the UI. One for a dialog with alist of Station. The other for the autocomplete.
is it possible to upload a snippet of code....
i may not be explaining it well....
Mark M.
I would recommend that you use a paste service like gist.github.com
larger code listings sometimes get messed up when pasted directly into the chat
you can paste in the link to the gist you put on gist.github.com
Dimitri
wiil this do...
Mark M.
OK, one moment while I read through that
Dimitri
Thank you
Mark M.
I really do not understand what you are trying to do in the two onItemClick() methods
All you seem to do is load the same data back into the same AutoCompleteTextViews
Oh, wait
I understand a bit better
when the user clicks on an AutoCompleteTextView entry, you are replacing the other adapter with a new list of stations, right?
10:30 AM
Mark M.
In answer to the question itself that you posed on StackOverflow, I do not see how else you could do it much more efficiently
Dimitri
That is right...
Also i am loading the List of Station on an ArrayAdapter<Station> the is used in a Dialog the is triggered by a button next to the auto-complete...
10:35 AM
Mark M.
Again, I think that the code that you have on StackOverflow is as good as that is going to get, at least in terms of your adapter management
if you have other questions, feel free to ask
10:40 AM
Dimitri
Ok, Different question regarding Parcelable and Map.
First is a good idea i am new to Android and what i have read so far Parcelable offers better performance than serializible?
Mark M.
Parcelable is designed to convert objects to byte arrays for transport across process boundaries
Dimitri
I have a object with a Map as a field.
Mark M.
Serializable is designed to write objects out to streams to later be read in
Dimitri
ok...
I am using Parcelable to pass my object in an Intent: i.putExtra(MY_RESULT, result);
10:45 AM
Tejas
has left the room
Dimitri
My "result" object has a Map<String, Parcelable<Object>> by implementing parceable i have to Override writeToParcel
how do i actual write a Map?
Mark M.
let's back up a step
why are you trying to put this object into an Intent?
Dimitri
So that i can read its values in the next activity and present them.
Mark M.
then I think you have a design problem
victor
has entered the room
Mark M.
if the data model is that complicated, it should not be "owned" by any activity
victor
hi
Mark M.
the data model should be held outside of all activities -- Service, Application, static data member, something
(btw, howdy, victor!)
victor
:)
Mark M.
Dmitri: if this were a Web app, and the two activities were Web pages, you would not be trying to stuff this data into some GET parameter
Intent extras are equivalent to GET parameters
10:50 AM
Mark M.
all that being said, I have never implemented Parcelable, so I have no idea how I would convert a Map<String, Parcelable<Object>> as part of a Parcelable, sorry
another possibility, if two activities have that complicated of data to be shared between them, is that perhaps they should not be two separate activities
and since we're running out of time... victor: do you have a question?
Chris H.
has entered the room
victor
yes a small one
I have a webview that calls some native methods through a js interface
Dimitri
thank you.
victor
and I would like to know in Java the variable type that javascript is passing to my method
since javascript is not typed I just get Strings from the webview
10:55 AM
Mark M.
you will have to pass the data type as another parameter
as you say, everything is a string
victor
ok, I guess there is no other way
:)
Mark M.
or, possibly, convert the data to JSON, and derive the type as part of parsing the JSON, but that seems like overkill
Chris: do you have a question?
victor
ok, thanks
Chris H.
Mark, I was just popping in to see if you got any feedback on my hardware questions from Tuesday?
Mark M.
ah!
yes!
bad news, though
my contact didn't have great recommendations
hold on while I pull up the email
"In the end, the people who will do this are going to be the silicon vendors, TI, broadcom, wondermedia, freescale. They are the ones that have the incentive and the resources."
he knew of no independent firms handling this sort of thing
sorry!
Chris H.
I see. Im not giving up hope yet. Honestly, I think the silicon vendor already has support for what I need on the linux layer, but there is no interface to it from Android. Mentor Graphics did the Android port for my processor, so I am in discussions with them. I just hope it doesn't cost us $50k. Thanks for the help.
11:00 AM
Mark M.
OK, that is all for today's chat
Chris H.
has left the room
Mark M.
the two next week are 8pm Eastern Time
have a pleasant day!
Dimitri
has left the room
victor
has left the room
Mark M.
turned off guest access

Tuesday, March 15

 

Office Hours

People in this transcript

  • Chris Hartley
  • Dimitri
  • Mark Murphy
  • Tejas
  • Thierry-Dimitri Roy
  • victor