Jan 13 | 7:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Suzanne A. | has entered the room |
Mark M. |
howdy, Suzanne!
|
Suzanne A. |
howdy, Mark!
|
Suzanne A. |
first, I fixed my db column (and Studio got fixed too)
|
Jan 13 | 8:00 PM |
Mark M. |
cool!
|
Suzanne A. |
so now I have a list pulled from a SimpleCursor adapter, but it's very slooooow
|
Suzanne A. |
can I subclass SimpleCursorAdapter to recycle views? do you have an example?
|
Mark M. |
slow to load? slow to scroll? something else?
|
Suzanne A. |
slow to scroll, with a big db
|
Mark M. |
SimpleCursorAdapter already does row recycling, AFAIK
|
Mark M. |
what are you displaying in the list?
|
Suzanne A. |
baby names :-) plus a background image
|
Suzanne A. |
maybe it's the background?
|
Mark M. |
background is per row?
|
Suzanne A. |
I think bg is per list view
|
Mark M. |
you might experiment with removing that, but I doubt it is your problem
|
Mark M. |
so the only thing in the row is a TextView?
|
Suzanne A. |
yes
|
Mark M. |
when you say "a big db", how big?
|
Suzanne A. |
I found this example, but it extends CursorAdapter http://stackoverflow.com/questions/4102219…
|
Suzanne A. |
db is about 200 rows - maybe not big by your standards
|
Julius | has entered the room |
Mark M. |
yeah, that's not big
|
Mark M. |
> 1MB is big
|
Mark M. |
(BTW, howdy, Julius!)
|
Julius |
(hi all)
|
Suzanne A. |
when I scroll, list background goes black and waits ... then redraws bg and shows new rows
|
Mark M. |
well, maybe I was wrong about the background being the problem
|
David | has entered the room |
Suzanne A. |
ok. i'm doing lv.setBackgroundResource
|
Mark M. |
Romain Guy has some posts on that, as I recall,
either in the Articles area of the Android Developers site, or on his
personal blog
|
Mark M. |
you might consider trying Traceview to see what it tells you
|
Mark M. |
(BTW, howdy, David!)
|
David |
Hi Mark,
|
Jan 13 | 8:05 PM |
Suzanne A. |
okay, will do
|
Mark M. |
Julius: do you have a question?
|
Julius |
hi yes:
|
Julius |
I have two IntentServices each of which performs
writes to my application's database. I get SQLiteExceptions (error code
5: database is locked) if both are running at the same time. Should I
bind to the IntentService to find out if an IntentService is active when
an application starts?
|
Mark M. |
well, ideally, you synchronize access to the database
|
Julius |
(so as not to start the other process if teh user requests it)
|
Mark M. |
why do you need two IntentServices?
|
Julius |
oh ok... I'm not sure how to go about that
|
Julius |
they're both getting data from different places
|
Julius |
so one is from online and the other is from a local source MediaStore
|
Mark M. |
I wouldn't consider that a strong design criterion for having more than one IntentService
|
Julius |
so maybe I should combine them into one
|
Julius |
?
|
Mark M. |
that would be my gut instinct
|
Julius |
ok great :)
|
Mark M. |
use different action strings, or extras, or something to tell one command from the other
|
Julius |
ok that sounds good
|
Julius |
thanks you
|
Mark M. |
David: do you have a question?
|
David |
Yes. What is the best way to transfer data received by Socket to other Activities?
|
Jan 13 | 8:10 PM |
Mark M. |
Let's back up a step. What is opening/using the socket?
|
David |
It is UDP socket.
|
Mark M. |
OK. What is opening/using the socket?
|
David |
Android runs a Server.
|
Mark M. |
OK. What is opening/using the socket? Is it a service?
|
David |
I need to parse UDP packet by server to retrieve some information.
|
David |
I guess I don't understand your opening/using the socket.
|
Mark M. |
OK.
|
Mark M. |
In Java, you will be creating a Socket or ServerSocket object.
|
Mark M. |
Somewhere, there is a line of code that does this.
|
Mark M. |
That line of code will be in a class.
|
Mark M. |
That class might be a Service, or it might be an Activity, or it might be something else.
|
David |
I got that, and runs okay. Android app is receiving data from other clients which initiates traffic.
|
David |
I mean UDP server/client is running okay.
|
Mark M. |
OK, but you are not answering my questions, which means I cannot help you.
|
Mark M. |
What sort of class has the code which is opening your Socket or ServerSocket? Is it a Service?
|
Jan 13 | 8:15 PM |
David |
Oh I see. It is Activity. I am consider to use Service.
|
Mark M. |
Yes, your first move should be to have your socket be managed by a Service.
|
Mark M. |
Otherwise, you cannot "transfer data received by
Socket to other Activities", since you will be closing that socket when
you move to the other activities.
|
David |
But Service is not on all the time, isn't it?
|
Mark M. |
It is far closer to "on all the time" than is an activity
|
Mark M. |
Activities are destroyed frequently.
|
Mark M. |
Users press the BACK button, rotate the screen, etc.
|
Mark M. |
Android kicks activities out of memory if they are not on the screen (e.g., user presses HOME button)
|
David |
That means a packet is arrived, server will run?
|
Mark M. |
There is no "server"
|
Mark M. |
You have a socket
|
Mark M. |
You listen on the socket
|
Mark M. |
This is done by a background thread in a service
|
Mark M. |
when the packet arrives, the service does something, perhaps on another thread if it might take a while
|
Mark M. |
(so as to not interrupt your ability to read packets off the socket)
|
David |
Thank you.
|
Mark M. |
The Services chapter of _The Busy Coder's Guide to
Android Development_ outlines a variety of ways your service can send
information about this packet to an interested activity.
|
Jan 13 | 8:20 PM |
Mark M. |
I cannot tell you which is best without knowing more about your app, and that is probably beyond the scope of this chat
|
David |
I will closely look at
|
Mark M. |
So, I recommend you review that chapter.
|
yuku | has entered the room |
yuku |
umm.. everyone seems idle now.. so, Hi!
|
yuku |
can I start a new question
|
Mark M. |
howdy, yuku!
|
yuku |
?
|
yuku |
hi again mark!
|
Mark M. |
everyone else has had a turn, so go ahead
|
yuku |
I'm not sure if you always monitor all stackoverflow android question?
|
Mark M. |
no, particularly when I am traveling, like this week
|
yuku |
so, actually I want to re-ask this question http://stackoverflow.com/questions/4583484…
|
yuku |
do you have any opinion about how to implement pull-to-refresh in android?
|
Mark M. |
nothing better than the answers you were already given
|
David | has left the room |
Mark M. |
what was wrong with the code that johan supplied?
|
yuku |
really? which one from no 1 and 2?
|
Mark M. |
I have no idea
|
Mark M. |
I have not looked at johan's code
|
Mark M. |
He gave you the link
|
Mark M. |
it's the 2-point rated answer
|
Jan 13 | 8:25 PM |
Mark M. |
bear in mind, I have never used a pull-to-refresh app in my life, so I only have a vague notion of what it even means
|
yuku |
I have, but I haven't tried it personally, because it requires animating on the list view using API level 8
|
yuku |
hmm, ok, I see, let me see if I can find some info for you
|
Mark M. |
BTW, at this point, I would assume the Twitter app will never be released
|
Julius |
(bugger... :))
|
yuku |
really? what happened to twitter?
|
Mark M. |
they probably took over the app, if I had to guess
|
Julius |
(oh that's Kiwi speak not offensive!)
|
yuku |
http://www.youtube.com/watch?v=5mzn9Wrk7ss jump to 0:25
|
Mark M. |
:: shrug ::
|
Mark M. |
I haven't the foggiest idea how to do that
|
Mark M. |
heck, just the touch events are pushing the boundaries of my experience
|
yuku |
basically you can pull down the listview and see something on the top of the first item
|
Mark M. |
actually animating based on touch events is well beyond those boundaries
|
Mark M. |
you might look at the implementation of SlidingDrawer and see if you could leverage that as a starting point
|
yuku |
so you think we still need to mess with the touchevent?
|
yuku |
hmm
|
Mark M. |
I'm imagining a SlidingDrawer effectively above the ListView
|
yuku |
nice idea
|
yuku |
yeah
|
Jan 13 | 8:30 PM |
Mark M. |
as the drawer opens, the ListView resizes smaller
|
Mark M. |
there's a few gaps in the SlidingDrawer
implementation compared to what you would need, but it's the closest
thing in android.widget I can think of that would be a starting point
|
yuku |
ok, thanks mark!
|
Mark M. |
you could try hunting around to see how the notification drawer works, but I have no idea where that code might live
|
Mark M. |
Suzanne; do you have another question?
|
Suzanne A. |
Yes - you were right - it was the background image. Would using a simple background color affect ListView performance?
|
Mark M. | |
Mark M. |
that's the article I was thinking of
|
Suzanne A. |
okay, I'll read it - thanks
|
Mark M. |
however, it's not on performance so much as look
|
Mark M. |
ahh
|
Mark M. |
you probably want to set the cache color hint
|
Suzanne A. |
aha .. will try it, thanks
|
Mark M. |
a bit over halfway through the article is the part you need
|
Suzanne A. |
ok
|
Mark M. |
Julius: do you have another question?
|
Julius |
hi yes:
|
Julius |
I have a Cursor which I pass into an AsyncTask as a
parameter and work through the Cursor. The Cursor is managed using
startManagingCursor in an Activity. If I destroy the Activity I get a
StaleDataException. Just wondering if you've got any idea why this is
occurring or what would be a better thing to do.
|
Mark M. |
I would not pass a managed Cursor into an AsyncTask
|
Jan 13 | 8:35 PM |
Julius |
ah ok
|
Mark M. |
if the activity is destroyed while doInBackground() is rolling, you'll have some sort of problem
|
Julius |
:)
|
Julius |
ok
|
Mark M. |
not sure if that's the StaleDataException -- I'd've expected another name
|
Mark M. |
general rule of thumb: don't pass into AsyncTask anything that depends on Activity that you plan to use in doInBackground()
|
Julius |
it tryies to access a cursor that doesn't exist from memory
|
Julius |
ok
|
Julius |
thanks for that - it sounds sensible.
|
Julius |
:)
|
Julius |
bfn
|
Suzanne A. |
thanks, mark - bfn
|
Suzanne A. | has left the room |
Mark M. |
yuku: do you have another question?
|
Julius | has left the room |
fitz | has entered the room |
Mark M. |
howdy, fitz!
|
Mark M. |
fitz: do you have a question?
|
cody | has entered the room |
cody |
hello.
|
Mark M. |
howdy, cody!
|
Mark M. |
cody: do you have a question?
|
cody |
hi mark! thanks for the great packages and documentation
|
Mark M. |
you're very welcome
|
Jan 13 | 8:40 PM |
cody |
i *did* have questions earlier but i was able to answer them / figure out my issue.
|
Mark M. |
great!
|
cody |
but i will just ask again to see if i was on the right track....
|
cody |
i am using merge adapter and I originally had a
regular Activity (NOT ListActivity) and i had a layout with a ListView
which I injected with content, and then beneath the listview i had
various other views, basically being placeholders for "sorry, no data
here" (with visiblity set to gone, which i would switch back to visible
when needed). anyways, i was seeing 2 issues
|
cody |
i would populate my merge adapter and its sub-adapters with a bunch of data, and it would render just fine
|
cody |
but on swipe down - the top view in my activity with fundamentally shrink in size, it would go like 1/2 screen width
|
cody |
AND
|
cody |
no click events were happening until after i
"primed" the activity by clicking the MENU button. i could click around
and they would get queued up but no fire, and then if i clicked the MENU
button they would all fire at once.
|
cody |
it was somehow swallowing my events
|
cody |
my solution: switched my Activity to ListActivity and ditched those placeholder layouts
|
cody |
and both problems went away
|
Mark M. |
that's wild
|
cody |
yeah. so my overall question then is
|
cody |
does MergeAdapter require a ListActivity?
|
cody |
i seem to have it working just fine in a reg Activity
|
cody |
but maybe i should switch it too
|
cody |
not seeing those issues on my other activities
|
cody |
but wild indeed
|
Mark M. |
MergeAdapter should not require ListActivity, AFAIK
|
cody |
thats what i thought, especially after looking at the source it seems pretty generic
|
cody |
but good to know
|
Jan 13 | 8:45 PM |
cody |
btw, do you still recommend to inflate views with the 3 param style: inflate(R.layout.foo, parent, true)?
|
Mark M. |
yes
|
Mark M. |
necessary for RelativeLayouts in rows
|
cody |
i saw a stackoverflow thread where you said you might have given us all bad ideas by doing 2 param with null
|
Mark M. |
oh, wait
|
Mark M. |
not, true
|
Mark M. |
inflate(R.layout.foo,parent,false)
|
cody |
i might be able to find it
|
Mark M. |
right
|
Mark M. |
I thought inflate(R.layout.foo, null) was OK a while back
|
Mark M. |
Romain Guy set me straight
|
cody |
yep, thats the thread. he piped up
|
cody |
is that just with RelativeLayout ?
|
Mark M. |
it's the one case I know of
|
cody |
...just an issue with....
|
cody |
makes sense, since a RL will get its layout from
its parent, which is the list view. which he addresses in another
question of mine
|
cody | |
cody |
ok, i think it makes sense now
|
Mark M. |
fitz: you haven't had a chance yet -- do you have a question?
|
cody |
hah, sorry for taking over
|
cody |
ok. im good. thanks mark!
|
Jan 13 | 8:50 PM |
fitz | has left the room |
Mark M. |
ok, does anyone have a question?
|
cody | has left the room |
Jan 13 | 9:00 PM |
yuku | has left the room |
Mark M. | turned off guest access |