private AndroidJavaObject ShareConfigToJavaObject(MegacoolShareConfig config) { if (config == null) { return(null); } AndroidJavaObject jConfig = new AndroidJavaObject("co.megacool.megacool.ShareConfig"); if (config._HasRecordingId()) { jConfig.Call <AndroidJavaObject>("recordingId", config.RecordingId); } if (config._HasMessage()) { jConfig.Call <AndroidJavaObject>("message", config.Message); } if (config._HasStrategy()) { AndroidJavaClass strategyClass = new AndroidJavaClass("co.megacool.megacool.SharingStrategy"); AndroidJavaObject jStrategy; if (config.Strategy == MegacoolSharingStrategy.MEDIA) { jStrategy = strategyClass.GetStatic <AndroidJavaObject>("MEDIA"); } else { jStrategy = strategyClass.GetStatic <AndroidJavaObject>("LINK"); } jConfig.Call <AndroidJavaObject>("strategy", jStrategy); } if (config.FallbackImage != null) { jConfig.Call <AndroidJavaObject>("fallbackImageAsset", config.FallbackImage); } if (config.Url != null) { AndroidJavaClass jUriClass = new AndroidJavaClass("android.net.Uri"); AndroidJavaObject jUri = jUriClass.CallStatic <AndroidJavaObject>("parse", config.Url.ToString()); jConfig.Call <AndroidJavaObject>("url", jUri); } if (config.Data != null) { jConfig.Call <AndroidJavaObject>("dataAsJson", MegacoolThirdParty_MiniJSON.Json.Serialize(config.Data)); } if (config._HasModalTitle()) { jConfig.Call <AndroidJavaObject>("modalTitle", config.ModalTitle); } return(jConfig); }
private MCLShareConfig GetNativeShareConfig(MegacoolShareConfig config) { MCLShareConfig nativeConfig = new MCLShareConfig { strategy = -1, popover_source_rect = new MCLRect { x = -1, y = -1, width = -1, height = -1, }, popover_permitted_arrow_directions = -1, }; if (config._HasStrategy()) { nativeConfig.strategy = (int)config.Strategy; } if (config._HasMessage()) { nativeConfig.message = config.Message; } if (config._HasRecordingId()) { nativeConfig.recordingId = config.RecordingId; } if (config.Url != null) { nativeConfig.url = config.Url.ToString(); } if (config.FallbackImage != null) { nativeConfig.fallback_image = Application.streamingAssetsPath + "/" + config.FallbackImage; } if (config.Data != null) { nativeConfig.jsonData = Json.Serialize(config.Data); } if (config._HasModalLocation()) { nativeConfig.popover_source_rect.x = config.ModalLocation.x; nativeConfig.popover_source_rect.y = config.ModalLocation.y; nativeConfig.popover_source_rect.width = config.ModalLocation.width; nativeConfig.popover_source_rect.height = config.ModalLocation.height; } if (config._HasModalPermittedArrowDirections()) { nativeConfig.popover_permitted_arrow_directions = (int)config.ModalPermittedArrowDirections; } return(nativeConfig); }