Created
May 27, 2020 15:28
-
-
Save giolaq/69b8c146f10a6205b614877ebd567416 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object DocumentTextRecognizerService { | |
| private fun getServiceType(context: Context) = when { | |
| isGooglePlayServicesAvailable( | |
| context | |
| ) -> ServiceType.GOOGLE | |
| isHuaweiMobileServicesAvailable( | |
| context | |
| ) -> ServiceType.HUAWEI | |
| else -> ServiceType.GOOGLE | |
| } | |
| private fun isGooglePlayServicesAvailable(context: Context): Boolean { | |
| return GoogleApiAvailability.getInstance() | |
| .isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS | |
| } | |
| private fun isHuaweiMobileServicesAvailable(context: Context): Boolean { | |
| return HuaweiApiAvailability.getInstance() | |
| .isHuaweiMobileServicesAvailable(context) == com.huawei.hms.api.ConnectionResult.SUCCESS | |
| } | |
| fun create(context: Context): DocumentTextRecognizer { | |
| val type = | |
| getServiceType( | |
| context | |
| ) | |
| if (type == ServiceType.HUAWEI) | |
| return HMSDocumentTextRecognizer() | |
| return GMSDocumentTextRecognizer() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment