/** *This method shows a marker for Service Provider location on HMS Map */ private fun addDestinationMarker(latLng: LatLng) { if (null != mMarkerDestination) { mMarkerDestination?.remove() } mMarkerDestination = hMap?.addMarker( MarkerOptions().position(latLng).anchorMarker(0.5f, 0.9f).title(storeName) .snippet(storeAddress) ) }
/** * This method is used to open Cloud DB zone. */ public void openCloudDBZoneV2() { mConfig = new CloudDBZoneConfig(AppConstants.URBAN_HOME_SERVICES, CloudDBZoneConfig.CloudDBZoneSyncProperty.CLOUDDBZONE_CLOUD_CACHE, CloudDBZoneConfig.CloudDBZoneAccessProperty.CLOUDDBZONE_PUBLIC); mConfig.setPersistenceEnabled(true); Task<CloudDBZone> openDBZoneTask = mCloudDB.openCloudDBZone2(mConfig, true); openDBZoneTask.addOnSuccessListener(cloudDBZone -> { Log.w(TAG, "open clouddbzone success"); mCloudDBZone = cloudDBZone; // Add subscription after opening cloudDBZone success mUiCallBack.onInitCloud(); addSubscription(); }).addOnFailureListener(e -> Log.w(TAG, "open clouddbzone failed for")); }
写入数据
您可以使用executeUpsert()接口向当前Cloud DB zone中写入一个或一组对象。
/** * This method is used to insert data into Cloud DB. */ public void insertDbZoneInfo(T objectInfo) { if (mCloudDBZone == null) { Log.w(TAG, "CloudDBZone is null, try re-open it"); return; } Task<Integer> upsertTask = mCloudDBZone.executeUpsert(objectInfo); upsertTask.addOnSuccessListener(cloudDBZoneResult -> { mUiCallBack.onInsertSuccess(cloudDBZoneResult); }).addOnFailureListener(e -> { mUiCallBack.updateUiOnError("Insert table info failed"); }); }
/** * This method is used delete table data on Cloud DB. */ public void deleteTableData(List<T> tableObject) { if (mCloudDBZone == null) { Log.w(TAG, "CloudDBZone is null, try re-open it"); return; } Task<Integer> deleteTask = mCloudDBZone.executeDelete(tableObject); if (deleteTask.getException() != null) { mUiCallBack.updateUiOnError("Delete service type table failed"); return; } mUiCallBack.onDelete(tableObject); } }
编辑数据
您可以使用editService()方法编辑修理工的信息。
/** * This method is used to edit Service details. */ override fun editService(listObject: ServiceType) { val intent = Intent(this, AddServiceActivity::class.java) intent.apply { putExtra(AppConstants.CATEGORY_NAME, listObject.cat_name) putExtra(AppConstants.PROVIDER_PH_NUM, listObject.phone_number.toString()) putExtra(AppConstants.PROVIDER_MAIL_ID, listObject.email_id) putExtra(AppConstants.PROVIDER_COUNTRY, listObject.country) putExtra(AppConstants.PROVIDER_ID, listObject.id) putExtra(AppConstants.PROVIDER_NAME, listObject.service_provider_name) putExtra(AppConstants.PROVIDER_CITY, listObject.city) putExtra(AppConstants.PROVIDER_STATE, listObject.state) } startActivity(intent) }