Skip to content

Outro

1. Defina a animação de comutação da atividade do applet

API

kotlin
/**
 * Set the toggle animation of the applet Activity
 *
 * @param anim [Anim] animation
 */
fun setActivityTransitionAnim(anim: Anim)

Exemplo de uma chamada para #### :::: tabs ::: tab "Kotlin"

kotlin
FinAppClient.appletApiManager.setActivityTransitionAnim(SlideFromRightToLeftAnim)

:::

::: tab "Java"

java
FinAppClient.INSTANCE.getAppletApiManager().setActivityTransitionAnim(SlideFromRightToLeftAnim.INSTANCE);

::: ::::

2. Envie eventos para applets nativamente

API

kotlin
/**
 * Send events to applets natively
 * @param appId
 * @param params event parameters
 */
fun sendCustomEvent(appId: String, params: String)

Ligue para o exmple

:::: tabs ::: tab "Kotlin"

kotlin
FinAppClient.appletApiManager.sendCustomEvent("app", "{\"test\":\"123\"}")

:::

::: tab "Java"

java
FinAppClient.INSTANCE.getAppletApiManager().sendCustomEvent("app", "{\"test\":\"123\"}")")

::: ::::

3. Crie uma instância [FinAppletWebView]

Este método é preterido como de 2.12.4 . Se você precisar usar FinAppletWebView Apenas instancie a classe.

API

kotlin
/**
 * Create a [FinAppletWebView] instance
 *
 * @param context [Context] object
 * @return a [FinAppletWebView] instance
 */
fun createFinAppletWebView(context: Context): FinAppletWebView

Ligue para o exmple

:::: tabs ::: tab "Kotlin"

kotlin
val finAppletWebView = FinAppClient.appletApiManager.createFinAppletWebView(this)

:::

::: tab "Java"

java
FinAppletWebView finAppletWebView = FinAppClient.INSTANCE.getAppletApiManager().createFinAppletWebView(context);

::: ::::

4. Chamando a Internet

4.1 Chamando processos de applet do processo principal

A chamada precisa ser feita no processo principal

kotlin
FinAppClient.appletApiManager.callInAppletProcess(
        FinAppClient.appletApiManager.getCurrentAppletId().orEmpty(),
         "Name of the method by which the main process calls the applet process" ,
         "Main process calling applet process parameters" ,
        object : FinCallback<String> {
            override fun onSuccess(result: String?) {
                toast( "The result returned by the applet process: $result" )
            }

            override fun onError(code: Int, error: String?) {

            }

            override fun onProgress(status: Int, info: String?) {

            }
        })

Receber necessidade de registrar um manipulador com o processo de applet pode ser determinado por FinAppClient.isFinAppProcess(context) if it is an applet process

kotlin
if (FinAppClient.isFinAppProcess(this)) {
    FinAppProcessClient.appletProcessApiManager.setMainProcessCallHandler(
        object : IAppletProcessApiManager.MainProcessCallHandler {
            override fun onMainProcessCall(
                name: String,
                params: String?
                callback: IApiCallback?
            ) {
                toast( "Main process calling applet process: name:$name,params:$params" )
                callback?.onSuccess( "Returning results to the main process" )
            }
        })
}

4.2 Calling the main process from an applet process

The call needs to be made in the applet process

kotlin
FinAppProcessClient.appletProcessApiManager.callInMainProcess(
     "Name of the method by which the applet process calls the main process" ,
     "Parameters for the applet process to call the main process" ,
    object : FinCallback<String> {
        override fun onSuccess(result: String?) {
            toast( "The applet process called the main process successfully: $result" )
        }

        override fun onError(code: Int, error: String?) {

        }

        override fun onProgress(status: Int, info: String?) {

        }
    })

Receive Handler method needs to be registered with the main process

kotlin
FinAppClient.appletApiManager.setAppletProcessCallHandler(
    object : IAppletApiManager.AppletProcessCallHandler {
        override fun onAppletProcessCall(
            name: String,
            params: String?
            callback: IApiCallback?
        ) {
            application.toast( "Applet process calling main process: name:$name,params:$params" )
            callback?.onSuccess( "Returning results to the applet process" )
        }
    })

5. call api in applet process

FINAPPCLIENT.APPLETAPIMANAGER can only be used in the main process

The methods in FINAPPROCESSCLIENT.APPletProcessapimanager Devem ser usados ​​no processo de applet.

Para exmple

kotlin
 FinAppProcessClient.appletProcessApiManager.getCurrentAppletId()

 FinAppProcessClient.appletProcessApiManager.getAppletInfo()

 FinAppProcessClient.appletProcessApiManager.sendCustomEvent(params)

*** Translated with www.DeepL.com/Translator (free version) ***