Appearance
Mini Program Loading Page Style Config
1. Effect show
FinClip mini program SDK supports personalized configuration of loading pages and error pages. Among them:
- Loading page means: when launching the mini program, if the mini program is not downloaded to the device, the mini program container will start the loading page to prompt the user to wait, and when the mini program is installed to the device, the loading page will close and jump to the mini program. When users open the mini program for the first time, or after the mini program version update, the loading page will stay relatively long
- The error page is the page displayed to the user when the mini program fails to load or generates other unknown errors.
The specific UI effect can be seen in the following figure:
2. Coverage
This setting is implemented by the App, you can configure the view of loading page and error page, once set, all the mini programs in the App will be implemented according to this effect.
3. Android setup method
The SDK provides an abstract class IFinAppletLoadingPage
that developers can inherit from to implement their own loading page view and failure page view and configure the implementation class when initializing the SDK.
3.1 IFinAppletLoadingPage abstract method description
kotlin
/**
* Layout ID of the mini program in loading
*/
abstract fun getLoadingLayoutRes(): Int
/**
* Layout ID for mini program load failure
*/
abstract fun getFailureLayoutRes(): Int
/**
* Mini program load failure callback
*
* @param msg Error message
*/
@Deprecated("No more callbacks since version 2.36.3, please use onLoadingFailure(title: String, msg: String)")
abstract fun onLoadingFailure(msg: String)
/**
* mini program load failure callback
*
* @param title Wrong title
* @param msg Error message
*/
abstract fun onLoadingFailure(title: String, msg: String)
/**
* Update the information about the mini program, the parameters are the basic information of the mini program, it will call back several times,
* May be empty at the initial callback (e.g. the mini program is launched for the first time and basic information has not been downloaded),
* Developers are required to perform their own nulling.
*
* @param appTitle app name
* @param appAvatarUrl app icon link
*/
abstract fun onUpdate(appTitle: String, appAvatarUrl: String)
This class provides two layout instances:
failureLayout
The layout of the error page file returned by the getFailureLayoutRes method
loadingLayout
Corresponds to the layout file layout of the loading page returned by the getLoadingLayoutRes method
3.2 Custom loading page complete implementation example
Node
Since the SDK internally uses reflection techniques to instantiate the implementation class, the load page implementation class must contain only Context
as a parameter to the constructor.
Examples are as follows:
kotlin
class CustomLoadingPage constructor(context: Context) : IFinAppletLoadingPage(context) {
override fun getFailureLayoutRes(): Int {
// Error page layout resource file
return R.layout.layout_applet_failure
}
override fun getLoadingLayoutRes(): Int {
// Load page layout resource file
return R.layout.layout_applet_loading
}
override fun onLoadingFailure(msg: String) {
// This method is deprecated, please use the following onLoadingFailure(title: String, msg: String)
}
override fun onLoadingFailure(title: String, msg: String) {
// Error page error message body
failureLayout.findViewById<TextView>(R.id.tvLoadingFailedTitle).text = title
failureLayout.findViewById<TextView>(R.id.tvLoadingFailedMsg).text = msg
}
override fun onUpdate(appTitle: String, appAvatarUrl: String) {
// Loading page mini program name
loadingLayout.findViewById<TextView>(R.id.tvTitle).text = appTitle
// Loading page mini program icon
ImageLoader.get(context).load(appAvatarUrl, object : DrawableCallback {
override fun onLoadFailure() {
}
override fun onLoadSuccess(r: Drawable) {
loadingLayout.findViewById<RoundedImageView>(R.id.ivAvatar).setImageDrawable(r)
}
})
}
}
3.3 Configure the loading page during SDK initialization
kotlin
val uiConfig = FinAppConfig.UIConfig()
// Configuring custom loading pages
uiConfig.setLoadingLayoutCls(CustomLoadingPage::class.java)
val config = FinAppConfig.Builder()
// Other configuration items omitted
.setUiConfig(uiConfig)
.build()
FinAppClient.init(application, config, object : FinCallback<Any?> {
override fun onSuccess(result: Any?) {
}
override fun onError(code: Int, error: String) {
}
override fun onProgress(status: Int, error: String) {
}
})