Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 18 | 7:40 PM |
Parth M. | has entered the room |
Parth M. |
Hey Mr. Murphy I finally got around to creating a warescription, how exactly does this work?
|
Mark M. |
howdy, Parth!
|
Mark M. |
how can I help you today?
|
Mark M. |
(and I do not know what "this" is to be able to tell you how it works)
|
Parth M. |
So I took your advice on creating a Meetup account, I was wondering what kind of "meetups" I should be going to.
|
Sep 18 | 7:45 PM |
Mark M. |
um, whatever ones are near you that are of interest, I suppose
|
Mark M. |
I am not completely clear on how this relates to Android application development
|
Parth M. |
View paste
|
Mark M. |
you probably need to rethink your strategy
|
Mark M. |
there is no point in putting bitmaps in memory that cannot be seen
|
Mark M. |
so, assuming that you cannot reduce the number and/or size of the bitmaps, you will have to not load them all
|
Mark M. |
which means you will probably need to either
handle the scrolling yourself (vs. using ScrollView) or trying to rework
your presentation model to fit an AdapterView pattern
|
Sep 18 | 7:50 PM |
Mark M. |
for example, games with maps that are bigger than
the screen use map tiles, so that they do not have to try to hold the
entire map in heap space
|
Parth M. |
View paste
|
Parth M. |
or
|
Parth M. | |
Mark M. |
if you run your code on Android 3.0+, dump your heap, and use MAT to inspect the heap, you will know what is using your memory
|
Mark M. |
most likely, it is the bitmaps
|
Mark M. |
but that's just an educated guess
|
Parth M. |
What is MAT?
|
Mark M. |
MAT is the Memory Analysis Tool, an add-on for
Eclipse that can inspect a heap dump, so you can see what's all being
held onto in the heap
|
Mark M. |
there is a chapter on it in _The Busy Coder's Guide to Android Development_
|
Parth M. |
Ok I'll take a look at that. If we assume that the
bitmaps are using up my memory, can I create an integer array to hold
the resource ID, and and have one bitmap object
|
Sep 18 | 7:55 PM |
Mark M. |
well, you will need a Bitmap object for every Bitmap that is presently on the screen
|
Mark M. |
and, with your ScrollView approach, you will
presumably need one Bitmap object for every Bitmap that you intend to
have on the screen if the user scrolls
|
Mark M. |
that's why I am advocating that you find a way to avoid using ScrollView
|
Parth M. |
I see, ok, I'll try all of that and tell you how it goes, thanks!
|
Sep 18 | 8:00 PM |
Mark M. |
if you have another question, feel free to ask -- the chat room is not exactly crowded :-)
|
Parth M. |
haha, sure, although It's not really android app dev related
|
Mark M. |
alas, that is pretty much the focus of this chat room
|
Parth M. |
alright, I do have a java related concern
|
Mark M. |
OK
|
Parth M. |
I would like to upload a file, but It contains information about shades that I'm not supposed to release
|
Sep 18 | 8:05 PM |
Mark M. |
do you mean you want to upload a file into the chat room, or you want to upload a file as part of your Android app?
|
Parth M. |
to the chat room, should I just try to explain it using pseudo code?
|
Mark M. |
that's probably best, as this chat room is semi-public
|
Parth M. |
Ok so I have an activity that receives an RGB
value (3 integers) from an activity before it. The activity before it
gets these values frome the Bitmap.getPixel() method, but that's not
really Important. The values enter like so:
|
Parth M. |
View paste
|
Ryan H. | has entered the room |
Mark M. |
(howdy, Ryan -- I'll be with you shortly)
|
Parth M. |
View paste
|
Ryan H. |
Thanks Mark
|
Sep 18 | 8:10 PM |
Parth M. |
then my algorithm sorts through the integer array to find 20 of the closest shades from the input, like so:
|
Parth M. |
View paste
(26 more lines)
|
Parth M. |
is there a better way to go about this>
|
Parth M. |
*this?
|
Mark M. |
since I do not completely understand your algorithm, I cannot really answer that
|
Parth M. |
Is there anything I can clarify?
|
Mark M. |
probably not in the scope of what can fit in the chat room
|
Mark M. |
if "closest shades from the input" means smallest R/G/B deltas...
|
Mark M. |
...then I think you have to examine all 180 items, compute that delta, then find the 20 lowest delta values
|
Parth M. |
yes it does, sorry my code is quite unreadable
|
Sep 18 | 8:15 PM |
Parth M. | |
Mark M. |
Ryan: do you have a question?
|
Ryan H. |
Hi Mark. A simple one. I have an app with multiple
activities that bind to a service with a Binder. In my service I track
the clients
|
Ryan H. |
When the top level activity hits onDestroy when the screen rotates, my service gets restarted
|
Ryan H. |
ie, during that point there are no bound activities.
|
Ryan H. |
Can I bind the service to Application?
|
Mark M. |
well, you can use the Application context to bind to the service, if that's what you mean
|
Parth M. | has left the room |
Ryan H. |
Yes
|
Mark M. |
I think I demonstrate that in my binding coverage
|
Mark M. |
in the book
|
Ryan H. |
Will that cause any problems?
|
Mark M. |
well, you will need to both bind and unbind using the same Context, so you have to remember to use Application in both places
|
Mark M. |
beyond that, I am not aware of any particular problems (e.g., memory leaks) that this might cause
|
Ryan H. |
OK. I'll try that then.
|
Mark M. |
hmmm... I may have lost the sample I was thinking of as part of this year's Big Book Reboot...
|
Mark M. |
here it is from an older edition: https://github.com/commonsguy/cw-android/t…
|
Sep 18 | 8:20 PM |
Ryan H. |
Thanks. Of course if the service binding returns the service, anything I do with the service happens on the UI thread
|
Mark M. |
not exactly
|
Mark M. |
activities are perfectly capable of using background threads, like an AsyncTask
|
Mark M. |
services are in the background from a UI standpoint
|
Mark M. |
they are not automatically in the background from a threading standpoint
|
Mark M. |
but that is true for both the binding pattern and the command pattern
|
Ryan H. |
OK. I'm putting my DB writes in AsyncTasks, and DB reads to update views in Loaders and it seems to be working OK
|
Mark M. |
that sounds reasonable
|
Ryan H. |
Alright, I didn't have many questions, just came to watch
|
Mark M. |
alas, not much watching going on today
|
Ryan H. |
Have a good week
|
Mark M. |
you too!
|
Sep 18 | 8:30 PM |
Mark M. |
that's a wrap for today's chat
|
Mark M. |
next one is tomorrow, also at 7:30pm Eastern
|
Mark M. |
have a pleasant day!
|
Ryan H. | has left the room |
Mark M. | turned off guest access |