Gav wrote:
>  * I am making an image filtering application for Android.
>  * I want to populate my ListActivity with the list of available
> filters.
>  * I don't want to maintain a static list of filters available
>  * I don't want to reference the concrete implementations but rather
> the interface. (e.g. Inverse not JNIInverse or NaiveInverse)

All noble goals, except maybe the no-static-list restriction.

> From my basic understanding of spring and guice and design patterns
> what I think I need is a registration object which is populated with
> all available filters on startup, it should be populated and injected
> into my main activity using a spring config file so as to decouple the
> main activity from the implementations of the filters (Which are
> subject to change). To get and use a filter I would then ask the
> registration component if it had a filter and return a not yet
> implemented message if it's not found.

Oof.

I'm not sure an IoC framework has been employed on Android just yet. It 
also feels rather heavyweight for a mobile device, though there may be a 
tiny enough one that you can make it work.

Bear in mind that battery-powered devices, well, run on batteries. The 
overall drive is move things out of runtime and into the build process, 
not the other way around. The less you can do on the wimpy device, and 
the more you can do on your super-powered development machine, the better.

>  * Does anyone have a better suggestion?

I'm not sure if it's "better", but it's the path I'd consider heading 
down if I were in your shoes...

Write a script that examines your source tree, derives the proper list 
of filters, and converts them into a string-array resource (if you only 
need the name) or an XML blob you dump into res/xml/. Have your code use 
that resource to drive your ListActivity contents. Put the script in 
your build process (e.g., add it as an Ant target, required before the 
aapt targets run). Given the name, you can use Class.forName() to get 
the Class, from which you can use reflection to create an instance.

Yes, this is a static list. However, it's not one you are directly 
maintaining, so you don't have to worry about forgetting items. And, the 
list is being derived at compile time, not at runtime, so IoC overhead 
goes out the window.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to