-
Notifications
You must be signed in to change notification settings - Fork 32
99.Migrate from v1.x.x
The version 1.x.x is based on RxJava2, and version 3.x.x is based on RxJava3.
Compared with RxJava2, RxJava3 has changed a lot of package names (and a few API).
If you want to use the version 3.x.x, your APP must be upgraded to RxJava3, which will cause a large number of class errors in the APP.
So before upgrading to version 3.x.x, we provide a version of 1.x.x_rxjava3, so that the upgrade of RxJava3 can be completed first.
libraryCore_rxjava3_v1.1.9.aar:This aar is to help you update to RxJava3 first, when you go to the second step 2.Upgrade to 3.x.x, you should delete it.
Remove old libraryCore_v1.x.x.aar, changed to libraryCore_rxjava3_v1.x.x.aar. As follows:
dependencies {
//Required
implementation files('../aar/libraryCore_rxjava3_v1.1.9.aar')
implementation "io.reactivex.rxjava3:rxjava:3.1.5"
implementation "io.reactivex.rxjava3:rxandroid:3.0.2"
implementation "com.polidea.rxandroidble3:rxandroidble:1.17.2"
//Optional. Dfu function for Realtek chip
implementation files('../aar/libraryDfu_v1.0.5.aar')
//Optional. Dfu function for Nordic chip
implementation 'no.nordicsemi.android:dfu:1.10.3'
}
There are also some RxJava2 related libraries that need to be switched to RxJava3, which depends on the usage of their own APP. Such as:
implementation "androidx.room:room-rxjava3:2.4.3"
implementation "com.squareup.retrofit2:adapter-rxjava3:2.9.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx3:1.6.4"
Remove the dependency and aar of the version 1.x.x and change it to 3.x.x. As follows:
We also provide a sdk-fitcloud-v1.x.x-compat.aar for compatibility with 1.x.x apis. This way, you can minimize the changes as much as possible.
WristbandApplication class no longer has initialization function. Use the following method to initialize.
Call fitCloudSDKInit on you Application.onCreate(), then you can use WristbandApplication.getWristbandManager() to get the WristbandManager object.
WristbandApplication does not provide the getRxBleClient method. Please use FcSDK.getRxBleClient() to get it.
Package name is changed, please re-import it.
Please use this new api to determine whether the device supports a certain feature. For example:
if (syncDataRaw.getConfig().isSupportFeature(FcDeviceInfo.Feature.STEP_EXTRA)) {
items = DeviceDataUtils.mapStep(datas, device);
} else {
items = DeviceDataUtils.mapStep(datas, device, mStepLength, mWeight);
}
Use FcShape instead
Package name is changed, please re-import it.
DialDrawer.ScaleType.fromId removed. Use DialDrawer.ScaleType.fromOrdinal instead.
DialDrawer.Position.fromId removed. Use DialDrawer.Position.fromOrdinal instead.
DialView xml attribute dv_scale_type changed to dv_background_scale_type
The DialViewEngine class and DialView.setEngine() method was removed. You cannot directly use Uri to load background and style bitmap. Please load the bitmap yourself and set it to DialView. For example, use Glide to load bitmap:
import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.topstep.fitcloud.sdk.v2.utils.dial.DialView
object DialBitmapUtil {
fun glideLoadDialBackground(context: Context, dialView: DialView, uri: Any) {
Glide.with(context)
.asBitmap()
.load(uri)
.into(object : CustomTarget<Bitmap?>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap?>?) {
dialView.backgroundBitmap = resource
}
override fun onLoadCleared(placeholder: Drawable?) {
dialView.backgroundBitmap = null
}
})
}
fun glideLoadDialStyle(context: Context, dialView: DialView, uri: Any, styleBaseOnWidth: Int) {
Glide.with(context)
.asBitmap()
.load(uri)
.into(object : CustomTarget<Bitmap?>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap?>?) {
dialView.setStyleBitmap(resource, styleBaseOnWidth)
}
override fun onLoadCleared(placeholder: Drawable?) {
dialView.setStyleBitmap(null, styleBaseOnWidth)
}
})
}
}
Construction method changed:
dfuManager = DfuManager(fcSDK)
The upgrade method is changed. Use the new upgrade method of DfuManager:
public void upgrade(FcDfuManager.DfuType dfuType, Uri uri, byte binFlag)
AckException rename to FcAckException.
AuthenticatedException rename to FcAuthException.
EcgStartFailedException rename to FcEcgStartFailedException.
GSensorStartFailedException rename to FcGSensorStartFailedException.
PacketDataFormatException rename to FcFormatException.
SyncBusyException rename to FcSyncBusyException.
SyncStartFailedException rename to FcSyncStartFailedException.
SyncTerminateException rename to FcSyncTerminateException.
TemperatureRealTimeException rename to FcTemperatureRealTimeException.
WristbandException rename to FcException.
OperationBusyException class is removed.