Package 

Class OriginMobile


  • 
    public final class OriginMobile
    
                        

    Origin Mobile Software Development Kit (SDK) entry-point.

    The SDK entry-point must be initialized using an initializer. The initializer is used to configure, initialize, and install an SDK instance. After initialization, the SDK instance can be retrieved using current. At any given point in time, there may exist only one SDK instance per application instance.

    SDK instances can be shut down manually, by invoking shutdown. All SDK instances, however, are tied to the lifetime of their owning context. When the configured context is garbage-collected, the corresponding SDK instance will automatically perform a shut down.

    SDK instances provide a common facility for managing work. Work may be scheduled for delayed or immediate execution on the main (UI) thread or a pool of background threads, using and background, respectively.

    Modules are loaded into an SDK instance to provide extended functionality, such as ad rendering or auctioning. Modules are lazily loaded; however, they can be pre-loaded by specifying a modules' provider during initialization.

    • Method Detail

      • registerInstallCallback

         static void registerInstallCallback(Consumer<OriginMobile> cb)

        Register callback to invoke when an SDK instance is initialized and installed.

        Callbacks are identified by instance. As such, if {@code cb} was previouslyregistered, this simply returns. Otherwise, this registers {@code cb} as a callback toinvoke when an SDK instance is initialized and installed.

        Callbacks are invoked on the background work-pool of theSDK which they are called for. Additionally, if an SDK instance is currently installed and{@code cb} is not currently registered, then {@code cb} willbe scheduled for invocation on the background work-pool of the current SDK.

        Parameters:
        cb - callback to register
      • isShutdown

         boolean isShutdown()

        Test whether SDK instance has been shut down.

      • isTerminated

         boolean isTerminated()

        Test whether SDK instance has been shut down and all pending SDK tasks have completed.

      • startupId

         UUID startupId()

        Startup identifier.

        The identifier returned is a unique identifier for {@code this} instance.

      • removeSetting

         void removeSetting(String name)

        Remove setting value, if present.

        Parameters:
        name - setting to remove value of
      • getLongSetting

         long getLongSetting(String name, long dfl)

        Retrieve {@code long} setting value.

        Parameters:
        name - setting name
        dfl - default setting value
      • putLongSetting

         void putLongSetting(String name, long val)

        Update {@code long} setting value.

        Parameters:
        name - setting name
        val - setting value
      • foreground

         ListeningScheduledExecutorService foreground()

        Foreground work pool.

        The pool returned executes work on the main (or UI) thread.

      • background

         ListeningScheduledExecutorService background()

        Background work pool.

        The pool returned executes work on one or more background worker threads.

      • callInForeground

         <V> ListenableFuture<V> callInForeground(Callable<V> cmd)

        Execute command which computes a value, on main (UI) thread.

        Like runInForeground; however, the future returned, once successfullycompleted, will have the value computed by {@code cmd}.

        Parameters:
        cmd - command to call
      • runInBackground

         ListenableFuture<out Object> runInBackground(Runnable cmd)

        Execute command on non-main (UI) thread.

        If current thread is not the main (UI) thread, then {@code cmd} is executed immediately; otherwise, {@code cmd} is scheduled for immediateexecution on a background worker thread.

        Parameters:
        cmd - command to run
      • callInBackground

         <V> ListenableFuture<V> callInBackground(Callable<V> cmd)

        Execute command which computes a value, on non-main (UI) thread.

        Like runInBackground; however, the future returned, once successfullycompleted, will have the value computed by {@code cmd}.

        Parameters:
        cmd - command to call
      • runPunting

         ListenableFuture<out Object> runPunting(Runnable cmd)

        Schedule command, on main (UI) thread, for execution on non-main thread.

        This schedules {@code cmd}, on main thread, for immediateexecution on a background worker thread. This is useful when {@code cmd} performs some blocking task, but its execution should only happen when foregroundwork is allowed.

        Parameters:
        cmd - command to run
      • callPunting

         <V> ListenableFuture<V> callPunting(Callable<V> cmd)

        Schedule command which computes a value, on main (UI) thread, for execution on non-mainthread.

        Like runPunting; however, the future returned, once successfullycompleted, will have the value computed by {@code cmd}.

        Parameters:
        cmd - command to run
      • runPuntingDelayed

         ListenableFuture<out Object> runPuntingDelayed(Runnable cmd, long delay, TimeUnit unit)

        Schedule command, on main (UI) thread, for delayed execution on non-main thread.

        Like runPunting; however, the execution of {@code cmd} is delayed.

        Parameters:
        cmd - command to run
        delay - execution delay
        unit - unit {@code delay} is measured in
      • callPuntingDelayed

         <V> ListenableFuture<V> callPuntingDelayed(Callable<V> cmd, long delay, TimeUnit unit)

        Schedule command which computes a value, on main (UI) thread, for delayed execution onnon-main thread.

        Like runPuntingDelayed; however, the future returned,once successfully completed, will have the value computed by {@code cmd}.

        Parameters:
        cmd - command to run
        delay - execution delay
        unit - unit {@code delay} is measured in
      • schedulePuntingWithFixedDelay

         ListenableFuture<out Object> schedulePuntingWithFixedDelay(Runnable cmd, long initialDelay, long delay, TimeUnit unit)

        Schedule command, on main (UI) thread, for recurring execution on non-main thread.

        This schedules {@code cmd} for execution on background workerthread, with the execution being scheduled at the specified delay on the main thread.

        Parameters:
        cmd - command to run
        initialDelay - initial execution delay
        delay - recurring execution delay
        unit - unit {@code initialDelay} and {@code delay} are measured in
      • getModule

         <M extends OriginModule> M getModule(Class<M> type)

        Get module, failing if not already loaded.

        Parameters:
        type - module type class
      • getOrLoadModule

         <M extends OriginModule> void getOrLoadModule(Class<M> type, BiConsumer<M, out Object> cons)

        Get module, asynchronously loading it if not already loaded.

        Like getOrLoadModuleSync; however, this is safe for invocation onmain (UI) threads. If module for {@code type} has already been loaded, invokes {@code cons},with the loaded module, immediately; otherwise, this loads the module for {@code type} asynchronously, invoking {@code cons} with the load result.

        Parameters:
        type - module type class
        cons - consumer to invoke with load result
      • awaitTermination

         boolean awaitTermination(long timeout, TimeUnit unit)

        Await SDK termination.

        Parameters:
        timeout - maximum time to wait
        unit - unit of measurement {@code timeout} is specified in
      • shutdown

         void shutdown()

        Initiate SDK shut down.

        If shut down was previously initiated, this simply returns; otherwise, this initiatesthe SDK shutdown. The shut down completion of an SDK instance is asynchronous. As such,this always returns immediately. To await shut down completion, use .