
package com.jfixby.scarabei.red.flutter.plugins.android.sys;

import java.lang.reflect.Method;

import com.jfixby.scarabei.api.collections.Collections;
import com.jfixby.scarabei.api.flutter.plugins.FlutterPluginSpecs;
import com.jfixby.scarabei.api.json.Json;
import com.jfixby.scarabei.api.log.L;
import com.jfixby.scarabei.api.sys.settings.SystemSettings;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;

public class SharedPreferencesPlugin implements MethodCallHandler {

	public static FlutterPluginSpecs filloutRegistration (final FlutterPluginSpecs specs) {
		specs.methodCallHandler = new SharedPreferencesPlugin();
		return specs;
	}

	@Override
	public void onMethodCall (final MethodCall call, final MethodChannel.Result result) {
		final String jsonString = (String)call.argument("jsonString");
		L.d("jsonString", jsonString);
		final FlutterMethodCall flutterCall = Json.deserializeFromString(FlutterMethodCall.class, jsonString);
		L.d("flutterCall.arguments", flutterCall.arguments);
		final Class<SystemSettings> klass = SystemSettings.class;
		final Class<?>[] argTypes = flutterCall.listArgumetTypes();
		final Object[] argValues = flutterCall.listArgumetValues();
		L.d("argTypes", Collections.newList(argTypes));
		L.d("argValues", Collections.newList(argValues));
		final String methodName = flutterCall.methodName;
		try {
			final Object invokeResult;
			if (argTypes.length == 0) {
				final Method registerWith = klass.getMethod(methodName);
				invokeResult = registerWith.invoke(null);
			} else {
				final Method registerWith = klass.getMethod(methodName, argTypes);
				invokeResult = registerWith.invoke(null, argValues);
			}
			L.d("invokeResult", invokeResult);
			result.success(invokeResult);
		} catch (final Exception e) {
			result.error(e.toString(), L.stackTraceToString(e), e);
			return;
		}

	}

}

@@ -1866,16 +1866,27 @@
 on e) %7B%0A
+%09%09%09L.e(e);%0A
 %09%09%09resul
@@ -1932,17 +1932,39 @@
 ing(e), 
-e
+L.stackTraceToString(e)
 );%0A%09%09%09re

fix delivery