Nov 11 | 9:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Nov 11 | 10:00 AM |
Ales | has entered the room |
Ales |
Hello
|
Mark M. |
howdy, Ales!
|
Mark M. |
how can I help you today?
|
Ales |
Much better than tuesday :)
|
Ales |
Just one quick question. Can I call Toast from a service?
|
Mark M. |
I think so
|
Mark M. |
Dialogs are a problem, but I'm reasonably sure toasts work
|
Mark M. |
I don't do it, personally
|
Nov 11 | 10:05 AM |
Ales |
I read somewhere that it pops up in front of active activity
|
Ales |
But not in my case :)
|
Mark M. |
it has to
|
Mark M. |
it's not part of any activity
|
Mark M. |
are you sure the code block where you are show()-ing the Toast is being invoked?
|
Ales |
It should go to queue right
|
Mark M. |
AFAIK, Toasts are not part of the message queue
|
Mark M. |
I think they go straight to the window manager that underlies Android's GUI
|
Ales |
they aren't?
|
Ales |
oh didn't know that
|
Ales |
btw I really like your books :)
|
Mark M. |
certainly, from a display standpoint, no activity shows the Toast -- that's a window manager thing
|
Mark M. |
thanks!
|
Ales |
With every update everything gets clearer
|
Ales |
Explanations I mean...
|
Nov 11 | 10:10 AM |
Ales |
If I have a list of news items with images, is it
best to download all images to phone first? Because it seems to be very
slow if they are downloading concurrently with news stroy for example.
|
Mark M. |
no, I would download them only when needed
|
Mark M. |
not everybody has an unlimited data plan
|
Mark M. |
and unlimited data plans are not really unlimited
|
Mark M. |
show a placeholder image, then swap in the actual image when it is ready
|
Mark M. |
I have a ThumbnailAdapter and ThumbnailActivity that wrap up the pattern
|
Mark M. | |
Mark M. |
However, I need to rewrite that someday -- the interface is fine, but the underlying caching logic is messy
|
Ales |
Is a game hard to programm (create) for beginners?
|
Nov 11 | 10:15 AM |
Mark M. |
Beats me
|
Mark M. |
I haven't written a game in two decades
|
Mark M. |
Not my cup o' tea, as it were
|
Ales |
I looked on market and games always have a lot of downloads, much more then apps
|
Mark M. |
That's very possible
|
Ales |
Still trying to solve than ANR, it's making me crazy :)
|
Mark M. |
did you post an issue to StackOverflow?
|
Nov 11 | 10:20 AM |
Ales |
Well, not yet. It's hard to explain
|
Mark M. |
ok
|
Ales |
My app currently looks like this http://tehnik.mobitel.si/wp-content/upload…
|
Ales |
It's my first project :)
|
Mark M. |
nice!
|
Mark M. |
though the green-and-orange theme is not quite my style :-)
|
Mark M. |
did you do the icons and backgrounds yourself, or do you have somebody else who does your graphic work for you?
|
Ales |
Not my fault :) Designer did GUI
|
Mark M. |
ah, OK
|
Ales |
It's kind of RSS app
|
Ales |
So I have like news, weather, traffic on top
|
Mark M. |
for Slovenia, presumably
|
Ales |
Those are my main activities.
|
Ales |
How do you know
|
Nov 11 | 10:25 AM |
Ales |
Oh
|
Ales |
From image :)
|
Mark M. |
yeah, I can't read much on there, but I figured that Slovenia was a good guess
|
Ales |
nicely done
|
Ales |
Those are sections like World, Sport, Politics, Tech,...
|
Ales |
Below is a RSS icon
|
Ales |
There is my problem with ANR. If I start my application and access it with long click it works fine.
|
Mark M. |
"access it with long click" -- what is "it"?
|
Ales |
But if I switch between those icons on top and then go to RSS source selections ANR show up
|
Ales |
onlong...
|
Mark M. |
"it" is the RSS button?
|
Ales |
Yes
|
Ales |
I mean activity starts
|
Mark M. |
what happens when you long click on it (and it works -- not the ANR case)?
|
Ales |
A list of sources displays
|
Mark M. |
where are those sources coming from: a local database, an HTTP request, or something else?
|
Ales |
You don't have emulator handy right?
|
Mark M. |
sure
|
Ales |
Database, but there only are like 6 or so
|
Nov 11 | 10:30 AM |
Mark M. |
OK, so that shouldn't be the problem
|
Ales |
Would you mind trying apk?
|
Mark M. |
often times, with apps like this, you accidentally
do an HTTP request on the main application thread, and that can cause
problems
|
Mark M. |
trying the APK probably will not help
|
Mark M. |
since I don't have the source
|
Mark M. |
probably the ANR is coming when the sources activity is starting up
|
Mark M. |
the most likely culprits, then, are whatever work you are doing in onCreate(), onStart(), or onResume()
|
Ales |
Hmm, maybe image downloading... But as I mention list does show up very fast. I just can't check any of my checkboxes
|
Mark M. |
oh, right
|
Mark M. |
forgot about that
|
Mark M. |
OK, so you long-press the RSS feed button, the
sources list is displayed, and then you get ANRs when you try
interacting with the list -- right?
|
Nov 11 | 10:35 AM |
Ales |
correct
|
Mark M. |
then something else is stealing the main application thread after onResume()
|
Mark M. |
otherwise, you wouldn't see the list
|
Ales |
And it always works fine if I go to sources list immediately after I start my app.
|
Mark M. |
the ANR dialog will tend to appear when you try tapping on an activity and your touch events are just getting queued up
|
Mark M. |
that may mean that the sources activity is not the problem, but something else (e.g., those images) is
|
Mark M. |
double-check to make sure all of your HTTP operations are done in AsyncTasks or otherwise on a background thread
|
Mark M. |
also, the images that you are downloading -- are
they really the right size, or are you downloading full-size images and
then having to scale them to be thumbnails?
|
Ales |
No scaling in app
|
Mark M. |
OK, then that's not it
|
Ales |
Oh one more question
|
Mark M. |
HTTP operations, Thread.sleep(), infinite loops -- those are the typical ANR sources I've encountered
|
Ales |
When I say ImageView with android:width="100dp". What happens with image if it's bigger?
|
Mark M. |
it gets scaled
|
Mark M. |
or cropped
|
Mark M. |
see android:scaleType for the options
|
Nov 11 | 10:40 AM |
Ales |
So there is some scaling i guess
|
Mark M. |
are you downloading really big images that are
being scaled? or is it that you are downloading thumbnails but not quite
the right size?
|
Ales |
No no i do thumnails on web server
|
Ales |
But since devices have different resolution
|
Mark M. |
ah, I see
|
Ales |
Android probably scales a bit
|
Mark M. |
you have two choices
|
Mark M. |
1. what you're presently doing
|
Mark M. |
2. have different thumbnails on your server, and download the right set
|
Mark M. |
in that case, you wouldn't use 100dp, but rely on
the image itself to have the right size (e.g.,
android:layout_width="wrap_content")
|
Mark M. |
and you'd have different directories or filenames or URL parameters or something to get the right thumbnail for this density
|
Mark M. |
advantages: crisper images, less on-device CPU usage
|
Mark M. |
disadvantages: more server code and complexity
|
Ales |
I should do that yes.. still a lot of devices to cover :)
|
Ales |
I must learn proper DPI conversion though
|
Nov 11 | 10:45 AM |
Ales |
Any Gingerbread news yet :)
|
Mark M. |
latest rumors say it'll ship today
|
Mark M. |
hasn't shipped yet, though
|
Nov 11 | 10:50 AM |
Ales |
Wow only me today :) Was packed two days ago
|
Mark M. |
yeah, these chats are feast or famine
|
Mark M. |
usually they are fairly quiet
|
Mark M. |
the 4pm Eastern time is a new one, and so maybe there is pent-up West Coast demand or somethign
|
Mark M. |
er, something
|
Ales |
It's 16:51 here :)
|
Ales |
Slovenia
|
Ales |
But you are just starting your day
|
Mark M. |
yes, I am surprised you were on Tuesday's chat, as that is rather late in your time zone
|
Ales |
It wasn't to bad. It was like 16 right?
|
Ales |
So it was about 22 here
|
Mark M. |
right
|
Ales |
Those 20:00 are a killer :)
|
Mark M. |
well, yeah
|
Mark M. |
that's why I rotate between times as best I can
|
Mark M. |
to try to give everybody a shot at a reasonable hour
|
Ales |
Well Mark, thank you very much for your time.
|
Mark M. |
sure! happy to help!
|
Ales |
Keep regular book updates and we'll be more than happy
|
Nov 11 | 10:55 AM |
Mark M. |
I do my best
|
Ales |
Thanks again, bye
|
Nov 11 | 11:00 AM |
Ales | has left the room |
Mark M. | turned off guest access |