From 8ab1b9edf2da03a7f0072cbee66153067d3b24e3 Mon Sep 17 00:00:00 2001 From: Steve Hannah Date: Sun, 29 Oct 2023 13:55:15 -0700 Subject: [PATCH] Removed plugin support getInstance() and instead use Display.getPluginSupport() to obtain singleton reference. --- .../com/codename1/plugin/PluginSupport.java | 21 ------------- CodenameOne/src/com/codename1/ui/CN.java | 31 +++---------------- CodenameOne/src/com/codename1/ui/Display.java | 11 ++++++- 3 files changed, 14 insertions(+), 49 deletions(-) diff --git a/CodenameOne/src/com/codename1/plugin/PluginSupport.java b/CodenameOne/src/com/codename1/plugin/PluginSupport.java index 8d61755ad8..cafa0f268c 100644 --- a/CodenameOne/src/com/codename1/plugin/PluginSupport.java +++ b/CodenameOne/src/com/codename1/plugin/PluginSupport.java @@ -36,27 +36,6 @@ public class PluginSupport { private final List plugins = new ArrayList(); - private static PluginSupport instance; - - private static final Object instanceLock = new Object(); - - /** - * Gets shared instance of PluginSupport class. - * - * @return Singleton instance - */ - public static PluginSupport getInstance() { - if (instance == null) { - synchronized (instanceLock){ - if (instance == null) { - instance = new PluginSupport(); - } - } - } - - return instance; - } - /** * Registers a plugin with the Codename One runtime. * @param plugin The plugin to register. diff --git a/CodenameOne/src/com/codename1/ui/CN.java b/CodenameOne/src/com/codename1/ui/CN.java index daecc14968..cf87bf2575 100644 --- a/CodenameOne/src/com/codename1/ui/CN.java +++ b/CodenameOne/src/com/codename1/ui/CN.java @@ -1629,34 +1629,11 @@ public static BrowserComponent getSharedJavascriptContext() { } /** - * Registers a plugin with the runtime so that specific functionality can be overridden by the plugin. - * @param plugin The plugin to register. + * Returns the plugin support object for the current platform. Use this object for registering plugins. + * @return The plugin support object. * @since 8.0 - * @see PluginSupport#registerPlugin(Plugin) */ - public static void registerPlugin(Plugin plugin) { - PluginSupport.getInstance().registerPlugin(plugin); + public static PluginSupport getPluginSupport() { + return Display.INSTANCE.getPluginSupport(); } - - /** - * Deregisters a plugin from the runtime. - * @param plugin The plugin to deregister - * @see PluginSupport#deregisterPlugin(Plugin) - * @since 8.0 - */ - public static void deregisterPlugin(Plugin plugin) { - PluginSupport.getInstance().deregisterPlugin(plugin); - } - - /** - * Fires a plugin event to all registered plugins to give them an opportunity to handle the event. - * - * @param event The event to fire. - * @see PluginSupport#firePluginEvent(PluginEvent) - * @since 8.0 - */ - public static T firePluginEvent(T event) { - return PluginSupport.getInstance().firePluginEvent(event); - } - } diff --git a/CodenameOne/src/com/codename1/ui/Display.java b/CodenameOne/src/com/codename1/ui/Display.java index c60b0ace6d..13f99f2015 100644 --- a/CodenameOne/src/com/codename1/ui/Display.java +++ b/CodenameOne/src/com/codename1/ui/Display.java @@ -523,7 +523,7 @@ private Display() { public static void init(Object m) { if(!INSTANCE.codenameOneRunning) { INSTANCE.codenameOneRunning = true; - INSTANCE.pluginSupport = PluginSupport.getInstance(); + INSTANCE.pluginSupport = new PluginSupport(); INSTANCE.displayInitTime = System.currentTimeMillis(); //restore menu state from previous run if exists @@ -613,6 +613,15 @@ public static Display getInstance(){ return INSTANCE; } + /** + * Gets reference to plugin support object. + * @return The plugin support object. + * @since 8.0 + */ + public PluginSupport getPluginSupport() { + return pluginSupport; + } + /** * This method allows us to manipulate the drag started detection logic. * If the pointer was dragged for more than this percentage of the display size it