Skip to content

Commit

Permalink
Map Helper & Messaging Service were updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
halilozel1903 committed Apr 26, 2022
1 parent d13db13 commit 795e251
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
15 changes: 9 additions & 6 deletions app/src/google/java/com/veripark/buildvariantapp/MapHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ import com.google.android.gms.maps.model.MarkerOptions

class MapHelper(activity: AppCompatActivity) {

private lateinit var map : GoogleMap
private var mActivity : AppCompatActivity = activity
private lateinit var map: GoogleMap
private var mActivity: AppCompatActivity = activity

init {
initMap()
}
private fun initMap()
{
val mapFragment = (mActivity.supportFragmentManager.findFragmentById(R.id.mapFragment) as SupportMapFragment)

private fun initMap() {
val mapFragment =
(mActivity.supportFragmentManager.findFragmentById(R.id.mapFragment) as SupportMapFragment)
mapFragment.getMapAsync {
map = it
map.addMarker(MarkerOptions().position(LatLng(40.9808142, 28.7119718)).title("Google Map"))?.snippet = "Welcome to Heaven"
map.addMarker(
MarkerOptions().position(LatLng(40.9808142, 28.7119718)).title("Google Map")
)?.snippet = "Welcome to Heaven"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.google.firebase.messaging.RemoteMessage

class MyFirebaseMessagingService : FirebaseMessagingService() {

companion object{
companion object {
private const val TAG = "FirebaseMessagingService"
}

Expand All @@ -31,8 +31,10 @@ class MyFirebaseMessagingService : FirebaseMessagingService() {
private fun showNotification(title: String?, body: String?) {
val intent = Intent(this, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
val pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT)
val pendingIntent = PendingIntent.getActivity(
this, 0, intent,
PendingIntent.FLAG_ONE_SHOT
)

val soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val notificationBuilder = NotificationCompat.Builder(this)
Expand All @@ -43,7 +45,8 @@ class MyFirebaseMessagingService : FirebaseMessagingService() {
.setSound(soundUri)
.setContentIntent(pendingIntent)

val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(0, notificationBuilder.build())
}
}
13 changes: 8 additions & 5 deletions app/src/huawei/java/com/veripark/buildvariantapp/MapHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ import com.huawei.hms.maps.model.MarkerOptions

class MapHelper(activity: AppCompatActivity) {

private lateinit var map : HuaweiMap
private var mActivity : AppCompatActivity = activity
private lateinit var map: HuaweiMap
private var mActivity: AppCompatActivity = activity

init {
initMap()
}

private fun initMap(){
val mapFragment = (mActivity.supportFragmentManager.findFragmentById(R.id.mapFragment) as SupportMapFragment)
private fun initMap() {
val mapFragment =
(mActivity.supportFragmentManager.findFragmentById(R.id.mapFragment) as SupportMapFragment)
mapFragment.getMapAsync {
map = it
map.addMarker(MarkerOptions().position(LatLng(40.9808142, 28.7119718)).title("Huawei Map Kit")).snippet = "Welcome to Hell"
map.addMarker(
MarkerOptions().position(LatLng(40.9808142, 28.7119718)).title("Huawei Map Kit")
).snippet = "Welcome to Hell"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.huawei.hms.push.RemoteMessage

class MyHuaweiMessagingService : HmsMessageService() {

companion object{
companion object {
private const val TAG = "MyHuaweiMessagingService"
}

Expand All @@ -30,8 +30,10 @@ class MyHuaweiMessagingService : HmsMessageService() {
private fun showNotification(title: String?, body: String?) {
val intent = Intent(this, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
val pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT)
val pendingIntent = PendingIntent.getActivity(
this, 0, intent,
PendingIntent.FLAG_ONE_SHOT
)

val soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val notificationBuilder = NotificationCompat.Builder(this)
Expand All @@ -42,7 +44,8 @@ class MyHuaweiMessagingService : HmsMessageService() {
.setSound(soundUri)
.setContentIntent(pendingIntent)

val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(0, notificationBuilder.build())
}
}

0 comments on commit 795e251

Please sign in to comment.