This file contains 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
class MainActivity : AppCompatActivity(), OnMapReadyCallback { | |
private var hMap: HuaweiMap? = null | |
companion object { | |
private const val MAPVIEW_BUNDLE_KEY = "MapViewBundleKey" | |
} | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) |
This file contains 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
/** | |
* Initialize dummy markers | |
*/ | |
private fun initMarkers() { | |
val markerDataList = createMarkerList() | |
markerDataList.forEachIndexed { index, markerOptions -> | |
val marker = hMap?.addMarker(markerOptions) | |
marker?.setMarkerAnchor(0.5f, 1f) // Set marker anchor point | |
marker?.tag = "$index Extra Info" // Set extra data with tag. This data can be a custom class | |
} |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:padding="4dp" | |
android:background="@android:color/white"> |
This file contains 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
class CustomInfoViewAdapter constructor(context : Context) : HuaweiMap.InfoWindowAdapter { | |
private var mWindow: View? = null | |
init { | |
mWindow = LayoutInflater.from(context).inflate(R.layout.custom_info_window_layout, null) | |
} | |
override fun getInfoWindow(marker: Marker?): View? { |
This file contains 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
@ExperimentalCoroutinesApi | |
suspend fun getUserData(id : String?) : Flow<Resource<User>> = withContext(ioDispatcher) { | |
callbackFlow { | |
if (id == null) { | |
offer(Resource.Error(Exception("Id must not be null"))) | |
return@callbackFlow | |
} | |
// 1- Create query |
This file contains 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
val subscription = cloudDBZone.subscribeSnapshot(query, CloudDBZoneQuery.CloudDBZoneQueryPolicy.POLICY_QUERY_FROM_CLOUD_PRIOR, | |
object : OnSnapshotListener<User> { | |
override fun onSnapshot(snapShot: CloudDBZoneSnapshot<User>?, error: AGConnectCloudDBException?) { | |
// do something | |
} | |
}) |
This file contains 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
@ExperimentalCoroutinesApi | |
suspend fun getUserDataChanges(id : String?) : Flow<Resource<User>> = withContext(ioDispatcher) { | |
callbackFlow { | |
if (id == null) { | |
offer(Resource.Error(Exception("Id must not be null"))) | |
return@callbackFlow | |
} | |
// 1- Create query |
OlderNewer