/** This method must be invoked on the UI thread. */ public static void handlePostInit(String tag) { if (!sReservedObjects.containsKey(tag)) return; Log.d(TAG, "Post init xwalk core in " + tag); LinkedList<Object> reservedObjects = sReservedObjects.get(tag); for (Object object = reservedObjects.poll(); object != null; object = reservedObjects.poll()) { Log.d(TAG, "Init reserved object: " + object.getClass()); new ReflectMethod(object, "reflectionInit").invoke(); } LinkedList<ReflectMethod> reservedMethods = sReservedMethods.get(tag); for (ReflectMethod method = reservedMethods.poll(); method != null; method = reservedMethods.poll()) { Log.d(TAG, "Call reserved method: " + method.toString()); Object[] args = method.getArguments(); if (args != null) { for (int i = 0; i < args.length; ++i) { if (args[i] instanceof ReflectMethod) { args[i] = ((ReflectMethod) args[i]).invokeWithArguments(); } } } method.invokeWithArguments(); } sReservedActivities.remove(tag); sReservedMethods.remove(tag); sReservedObjects.remove(tag); }
public static void reserveReflectMethod(ReflectMethod method) { String tag = sReservedActivities.getLast(); Log.d(TAG, "Reserve method " + method.toString() + " to " + tag); sReservedMethods.get(sReservedActivities.getLast()).add(method); }