From: Arno P. <ar...@pu...> - 2011-03-24 07:28:25
|
that is certainly also an interesting alternative: instead of introducing a new interface NSSelector, simply use Runnable. Panayotis: what do you think? Arno On 3/23/11 4:59 PM, Paul Poley wrote: > Yep, I try to avoid reflection at all costs. I had made a similar class > so that there's only one place where reflection occurs. So instead of > performSelector..., I call performRunnable... > > package blah.blah.blah; > > > import org.xmlvm.iphone.NSObject; > > import blah.blah.Logger; > > > public class IPhoneUtil { > > private static final Logger log = new Logger(IPhoneUtil.class); > > > private static IPhoneUtil utilInstance = new IPhoneUtil(); > > > private IPhoneUtil() { > > > } > > > public static void performRunnableOnMainThread(Runnable runnable, > boolean waitUntilDone) { > > NSObject.performSelectorOnMainThread(utilInstance, "executeRunnable", > runnable, waitUntilDone); > > } > > > /** > > * Execute a runnable on the main thread. This is only called via reflection > > * using performSelectorOnMainThread > > * @param arg the Runnable object > > */ > > public void executeRunnable(Object arg) { > > if (arg instanceof Runnable) { > > Runnable r = (Runnable)arg; > > r.run(); > > } else { > > log.info("Could not execute Runnable. Unexpected parameter type: " > > + (arg == null ? null : arg.getClass().getName())); > > } > > } > > } > > > > On Wed, Mar 23, 2011 at 4:42 PM, Arno Puder <ar...@pu... > <mailto:ar...@pu...>> wrote: > > > > On 3/23/2011 2:40 PM, Panayotis Katsaloulis wrote: > > Right now the patch is half-ready. > > It is only a presentation of the API I propose (alongside the > necessary changes for Android to be compatible). > > There are not even bindings for the ObjC backend, so it still > needs a lot of work. > > > > I just wanted to be sure that you agree with this change before > spend more time with it. > > your patch is definitely going in the right direction. Time to get your > hands dirty with the C backend! :) > > Arno > |