One way to get rid of the switch is to turn it into an array of
Runnable instances.
Then, instead of doing:

switch (value)
{
    case 0: doSomething(); break;
    ...
}

you'll have:

runnables[value].run();

Of course, this requires that you create a runnable instance for each
block of code, currently executed in your switch statement, and cache
it in a member variable.

If your values are not sequential, you could do it with a HashMap.

HTH,
Stoyan

On Fri, Mar 27, 2009 at 12:06 AM, HotHeart <korshakov.ste...@gmail.com> wrote:
>
> I have switch with 255 cases in my project - DroidGear...
> How i could optimize it?
>
> Sorry for my english
> >
>

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

Reply via email to