Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

부산대 Android_김주송_6주차 과제 (STEP2) #75

Open
wants to merge 120 commits into
base: jooiss
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
04c907f
Initial commit
MyStoryG Jun 15, 2024
8b097b3
Initial commit
MyStoryG Jun 15, 2024
eeebf44
docs: Update README.md
jooiss Jul 2, 2024
c032344
feat: Design search layout
jooiss Jul 2, 2024
f011ead
feat: Add place database
jooiss Jul 2, 2024
a289932
fix: Add trigger to prevent storing duplicate data
jooiss Jul 3, 2024
121176b
feat: Design search recyclerView and place recyclerView
jooiss Jul 3, 2024
05af938
feat: Set the layout to be displayed
jooiss Jul 3, 2024
166b988
docs: Update README.md
jooiss Jul 3, 2024
34627be
feat: Add search function of place list
jooiss Jul 3, 2024
ca0170c
refactor: change place list item
jooiss Jul 3, 2024
400b36f
refactor: resize search list item layout
jooiss Jul 4, 2024
cf1cfe3
feat: Add storing function of record list
jooiss Jul 5, 2024
bbf77e9
Initial commit
MyStoryG Jul 7, 2024
e0916b7
fix: Resolve conflict
jooiss Jul 8, 2024
df4cb5e
fix: Exclude kakao map dependency
jooiss Jul 8, 2024
c86d1d0
docs: Update README.md
jooiss Jul 8, 2024
3242db7
feat: Add database insert function
jooiss Jul 9, 2024
fd929f2
fix: Resolve screen-off feature
jooiss Jul 9, 2024
d50c57e
feat: Set API key value for kakao API integration
jooiss Jul 10, 2024
93f3d31
feat: Add data transfer object file
jooiss Jul 10, 2024
3b25cb4
feat: Add retrofit interface
jooiss Jul 10, 2024
0ae951c
refactor: Combine data activity and place activity
jooiss Jul 10, 2024
3d9c0a1
feat: Add retrofit object
jooiss Jul 10, 2024
55aef9e
feat: Update network security configuration
jooiss Jul 10, 2024
7381db6
feat: Add database insertion function
jooiss Jul 10, 2024
e52f182
refactor: Extract string to file
jooiss Jul 10, 2024
bf0301d
refactor: Change the search item design
jooiss Jul 10, 2024
ac3b1a5
feat: Reset the data at first
jooiss Jul 10, 2024
67f2174
feat: Change to category search
jooiss Jul 11, 2024
bb02709
docs: Update README.md
jooiss Jul 11, 2024
381d789
feat: Add kakao native app key
jooiss Jul 11, 2024
160ca07
feat: Add dependency about kakao map SDK
jooiss Jul 11, 2024
75e407a
feat: Design map layout
jooiss Jul 11, 2024
311395a
feat: Add map view function using the kakao map API
jooiss Jul 11, 2024
6ef3184
fix: Resolve file redundancy
jooiss Jul 11, 2024
ff3d529
fix: set text to be written in one line
jooiss Jul 11, 2024
f1e692d
refactor: Change DTO file name
jooiss Jul 12, 2024
4cf9b86
fix: Make API key resource not be saved
jooiss Jul 12, 2024
68f9aa8
fix: Call MapView method in time for activity
jooiss Jul 12, 2024
51f84de
fix: Change lifecycle function about kakao map API
jooiss Jul 14, 2024
36b98d5
fix: Change CategoryGroup finding method
jooiss Jul 14, 2024
17351fa
refactor: Separate the Retrofit network-related function
jooiss Jul 15, 2024
858022d
fix: Resolve conflict
jooiss Jul 15, 2024
f1c101f
부산대 Android_김주송_4주차 과제 (STEP0) (#19)
jooiss Jul 15, 2024
1b66d98
docs: Update README.md
jooiss Jul 17, 2024
37bad8f
refactor: Delete unnecessary files
jooiss Jul 17, 2024
34e1c44
feat: Change search method by keyword
jooiss Jul 17, 2024
4f84a78
feat: Display search result on selecting a saved search record
jooiss Jul 17, 2024
305453d
Initial commit
MyStoryG Jul 18, 2024
4ef142d
feat: Display modal when clicking on place list
jooiss Jul 18, 2024
7cd48c3
feat: Show error message when onMapError
jooiss Jul 19, 2024
23e8fb5
feat: Resume from last position on restart
jooiss Jul 19, 2024
072cae8
test: Add UI test code for PlaceActivity
jooiss Jul 19, 2024
caeef42
test: Add UI test code for MapActivity
jooiss Jul 19, 2024
fa1b72e
test: Add unit test code for MapActivity
jooiss Jul 19, 2024
96d0b32
test: Add unit test code for PlaceActivity
jooiss Jul 19, 2024
32efd23
Merge branch 'jooiss' into jooiss-step2
jooiss Jul 19, 2024
262badf
fix: Update UI test code for PlaceActivity
jooiss Jul 19, 2024
b45160d
docs: Update README.md
jooiss Jul 19, 2024
fa6d396
부산대 Android_김주송_4주차 과제 (STEP1) (#71)
jooiss Jul 21, 2024
ce86697
Merge branch 'jooiss' into jooiss-step2
LeeOhHyung Jul 21, 2024
b031b03
fix: Resolve merge conflict
jooiss Jul 22, 2024
7b7d977
refactor: Reorganize files according to data/domain/UI layer
jooiss Jul 22, 2024
13d54b7
chore: Rename application file name
jooiss Jul 22, 2024
df99297
부산대 Android_김주송_5주차 과제 (STEP0) (#13)
jooiss Jul 22, 2024
9c1cc33
refactor: Reorganize files according to clean architecture
jooiss Jul 22, 2024
07ca11a
refactor: Apply DataBinding in MapActivity and PlaceActivity
jooiss Jul 22, 2024
3d3422f
docs: Update README.md
jooiss Jul 23, 2024
3da6e0a
feat: Add Place entity
jooiss Jul 23, 2024
1952a0c
feat: Add DAO interface
jooiss Jul 23, 2024
a4735b4
feat: Add Database
jooiss Jul 23, 2024
527049c
feat: Implement DBClient for managing Room database instance
jooiss Jul 23, 2024
0ce0756
refactor: Integrate Room database for data storage
jooiss Jul 23, 2024
732c846
test: Update test code for modified code
jooiss Jul 23, 2024
dea3346
refactor: Add dependency injection for Retrofit
jooiss Jul 23, 2024
0ea2c12
chore: Change Retrofit repository file name
jooiss Jul 23, 2024
7467bda
refactor: Add dependency injection for Database
jooiss Jul 23, 2024
545c937
refactor: Add dependency injection for SharedPreferences
jooiss Jul 23, 2024
cca9f1a
Merge branch 'jooiss' into jooiss-step1
jooiss Jul 23, 2024
820f7ce
fix: Resolve conflict
jooiss Jul 23, 2024
62b775e
refactor: Separate Domain and Data layers for Place representation
jooiss Jul 23, 2024
11b2476
feat: Handle duplicate entries to maintain data integrity
jooiss Jul 23, 2024
3cf9a2d
refactor: Remove unnecessary code
jooiss Jul 23, 2024
99d66d9
feat: Add indices on 'name' and 'address' columns in PlaceEntity
jooiss Jul 24, 2024
7a16ce0
refactor: Add dependency injection for latitude and longitude
jooiss Jul 24, 2024
6830125
부산대 Android_김주송_5주차 과제 (STEP1) (#27)
jooiss Jul 24, 2024
8af347a
docs: Update README.md
jooiss Jul 24, 2024
370283c
chore: Rename place layout file
jooiss Jul 25, 2024
81cfd65
refactor: Inject PlaceDao directly into PlaceRepository
jooiss Jul 25, 2024
36a37b2
refactor: Implement ViewModel and LiveData for PlaceActivity
jooiss Jul 25, 2024
1a2f184
refactor: Implement ViewModel and LiveData for MapActivity
jooiss Jul 25, 2024
82a42c4
refactor: Apply DataBinding for PlaceRecyclerViewAdapter
jooiss Jul 26, 2024
07fa517
refactor: Apply DataBinding for SearchRecyclerViewAdapter
jooiss Jul 26, 2024
3d492f3
refactor: Add notifyDataSetChanged in RecyclerViewAdapter
jooiss Jul 26, 2024
3d22b95
refactor: Apply DataBinding for map error situation
jooiss Jul 26, 2024
6894e95
refactor: Remove unnecessary code
jooiss Jul 26, 2024
8e6a69c
fix: Resolve conflict
jooiss Jul 28, 2024
26e3138
refactor: Replace startActivity with registerForActivityResult
jooiss Jul 29, 2024
938bbd7
refactor: Change LayoutManager configuration to XML
jooiss Jul 29, 2024
ccf29f9
refactor: Use coroutines for asynchronous network calls with Retrofit
jooiss Jul 29, 2024
8be1e46
refactor: Consolidate Place-related LiveData into PlaceUiModel data c…
jooiss Jul 29, 2024
f91ae8d
fix: Resolve conflict
jooiss Jul 29, 2024
90015ce
refactor: Remove unnecessary import
jooiss Jul 29, 2024
5a9603e
docs: Update README.md
jooiss Jul 29, 2024
83c7fc6
feat: Configure Firebase for development
jooiss Jul 29, 2024
0a733fe
feat: Add initial screen setup based on Firebase parameter value
jooiss Jul 29, 2024
dc3720b
chore: Remove unnecessary layout file
jooiss Jul 29, 2024
102d87f
chore: Change Splash activity and layout
jooiss Aug 1, 2024
cf7de19
refactor: Manage Remote config data using DI and ViewModel
jooiss Aug 1, 2024
9d326ac
docs: Update README.md
jooiss Aug 1, 2024
a0a778b
feat: Enable background notifications for FCM
jooiss Aug 2, 2024
3eb770e
feat: Enable foreground notifications for FCM
jooiss Aug 2, 2024
147ddf9
chore: Change foreground notification function name
jooiss Aug 2, 2024
314d5a4
Merge branch 'jooiss' into jooiss-step2
jooiss Aug 2, 2024
4792787
refactor: Change file package structure
jooiss Aug 3, 2024
ab1e21b
refactor: Devide serviceMessage livedata observer
jooiss Aug 4, 2024
6225a67
fix: Handle serviceMessage errors correctly
jooiss Aug 4, 2024
33cfdd6
refactor: Move Remote config initialization to Application class
jooiss Aug 5, 2024
efbaa88
refactor: Handle notification channel creation during notification re…
jooiss Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@
- `serviceState` == `ON_SERVICE`
- 초기 진입 화면에서 지도 화면으로 이동
- `serviceState` != `ON_SERVICE`
- `serviceMessage` 값을 초기 진입 화면 하단에 표시 + 지도 화면으로 이동 X
- `serviceMessage` 값을 초기 진입 화면 하단에 표시 + 지도 화면으로 이동 X

### 2단계 - 푸시 알림
- Firebase의 Cloud Messaging 설정
- 테스트 메시지 전송
- 백그라운드 상태 -> FCM 기본 값을 사용해 Notification 발생
- 포그라운드 상태 -> Custom Notification 발생
- Notification 창 선택 시 초기 진입 화면 호출
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id("kotlin-parcelize")
id("kotlin-kapt")
id("com.google.dagger.hilt.android")
//id("com.google.gms.google-services")
id("com.google.gms.google-services")
}

android {
Expand Down Expand Up @@ -77,6 +77,7 @@ dependencies {
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-config-ktx:22.0.0")
implementation("com.google.firebase:firebase-messaging-ktx:24.0.0")
implementation ("com.google.firebase:firebase-messaging-directboot:20.2.0")
testImplementation("androidx.room:room-testing:2.6.1")
testImplementation("junit:junit:4.13.2")
testImplementation("io.mockk:mockk-android:1.13.11")
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -18,8 +19,18 @@
android:supportsRtl="true"
android:theme="@style/Theme.Map"
tools:targetApi="31">
<service
android:name=".MapFirebaseMessagingService"
android:enabled="true"
android:exported="false"
android:directBootAware="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<activity
android:name=".ui.LoadingActivity"
android:name=".ui.SplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
35 changes: 34 additions & 1 deletion app/src/main/java/campus/tech/kakao/map/KakaoMapApplication.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
package campus.tech.kakao.map

import android.app.Application
import campus.tech.kakao.map.BuildConfig
import android.util.Log
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.remoteConfigSettings
import com.kakao.vectormap.KakaoMapSdk
import dagger.hilt.android.HiltAndroidApp


@HiltAndroidApp
class KakaoMapApplication : Application() {

override fun onCreate() {
super.onCreate()
initRemoteConfig()
fetchRemoteConfig()
KakaoMapSdk.init(this, BuildConfig.KAKAO_API_KEY)
}

private fun initRemoteConfig() {
remoteConfig = FirebaseRemoteConfig.getInstance()
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 0
}
remoteConfig.setConfigSettingsAsync(configSettings)
}

private fun fetchRemoteConfig() {
remoteConfig.fetchAndActivate().addOnCompleteListener { task ->
if (task.isSuccessful) {
val serviceState = remoteConfig.getString("serviceState")
val serviceMessage = remoteConfig.getString("serviceMessage")
Log.d("RemoteConfig", "Service State: $serviceState, Service Message: $serviceMessage")
}
else {
val serviceMessage = remoteConfig.getString("serviceMessage")
val e = task.exception
Log.e("RemoteConfig", "Fetch and activate failed", e)
}
}
}

companion object {
lateinit var remoteConfig: FirebaseRemoteConfig
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package campus.tech.kakao.map

import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.core.app.NotificationCompat
import campus.tech.kakao.map.ui.SplashActivity
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage

class MapFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
Comment on lines +13 to +15

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service의 경우는 어떤 패키지에 넣어야 할 지 잘 모르겠어 application처럼 밖으로 빼놨는데 비즈니스 로직을 처리하는 domain layer에 넣는 것이 맞나 하는 의문이 들었습니다

Service 컴포넌트는 ui 패키지와는 별도의 공간에 두는편입니다. (물론 정답은 없습니다.)
아래 3가지 정도가 제가 본 일반적인 방법들인것 같습니다.

  • Application 클래스와 동일하게 두는 방법
  • service를 모아두는 패키지를 만드는 방법
  • fcm 관련 클래스를 하나의 패키지로 만드는 방법

Log.d("notification", "From: ${remoteMessage.from}")

remoteMessage.notification?.let {
Log.d("notification", "Message Notification Body: ${it.body}")
}

if (remoteMessage.notification != null) {
createNotificationChannel()
sendNotification()
}
}

private fun sendNotification() {
val intent = Intent(this, SplashActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle("[중요] 포그라운드 알림")
.setContentText("앱이 실행 중입니다.")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntent)
.setStyle(
NotificationCompat.BigTextStyle()
.bigText("앱이 실행 중일 때는 포그라운드 알림이 발생합니다.")
)
.setAutoCancel(true)

val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(NOTIFICATION_ID, builder.build())
}

private fun createNotificationChannel() {
val name = getString(R.string.channel_name)
val descriptionText = getString(R.string.channel_description)
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel(CHANNEL_ID, name, importance)
channel.description = descriptionText
val notificationManager: NotificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
}


companion object {
private const val NOTIFICATION_ID = 1
private const val CHANNEL_ID = "notification_default_channel"
}

}
26 changes: 26 additions & 0 deletions app/src/main/java/campus/tech/kakao/map/data/SplashModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package campus.tech.kakao.map.data

import com.google.firebase.Firebase
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.remoteConfig
import com.google.firebase.remoteconfig.remoteConfigSettings
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object SplashModule {
@Provides
@Singleton
fun provideFirebaseRemoteConfig(): FirebaseRemoteConfig {
val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 0
}
remoteConfig.setConfigSettingsAsync(configSettings)
return remoteConfig
}
}
44 changes: 0 additions & 44 deletions app/src/main/java/campus/tech/kakao/map/ui/LoadingActivity.kt

This file was deleted.

50 changes: 50 additions & 0 deletions app/src/main/java/campus/tech/kakao/map/ui/MapActivity.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package campus.tech.kakao.map.ui

import android.app.Activity
import android.app.AlertDialog
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.util.Log
import android.widget.Toast
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import campus.tech.kakao.map.R
import campus.tech.kakao.map.databinding.ErrorLayoutBinding
import campus.tech.kakao.map.databinding.MapLayoutBinding
import campus.tech.kakao.map.domain.Place
import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.messaging.FirebaseMessaging
import com.kakao.vectormap.KakaoMap
import com.kakao.vectormap.KakaoMapReadyCallback
import com.kakao.vectormap.LatLng
Expand Down Expand Up @@ -57,6 +66,8 @@ class MapActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
askNotificationPermission()

mapBinding = DataBindingUtil.setContentView(this, R.layout.map_layout)
mapBinding.mapView.start(lifeCycleCallback, readyCallback)
activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
Expand Down Expand Up @@ -134,4 +145,43 @@ class MapActivity : AppCompatActivity() {
modal.show(supportFragmentManager, "modalBottomSheet")
}

private val requestPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission(), ) { isGranted: Boolean ->
if (isGranted) {
Toast.makeText(this, "Notifications permission granted", Toast.LENGTH_SHORT).show()
}
else {
Toast.makeText(this, "FCM can't post notifications without POST_NOTIFICATIONS permission", Toast.LENGTH_LONG).show()
}
}

private fun askNotificationPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
if (shouldShowRequestPermissionRationale(android.Manifest.permission.POST_NOTIFICATIONS)) {
showNotificationPermissionDialog()
}
else {
requestPermissionLauncher.launch(android.Manifest.permission.POST_NOTIFICATIONS)
}
}
}
}

private fun showNotificationPermissionDialog() {
AlertDialog.Builder(this@MapActivity).apply {
setTitle("알림 권한 설정")
setMessage(
String.format("다양한 알림 소식을 받기 위해 권한을 허용하시겠어요?\n(알림에서 %s의 알림 권한을 허용해주세요.)", getString(R.string.app_name))
)
setPositiveButton("네") { _, _ ->
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", packageName, null)
intent.data = uri
startActivity(intent)
}
setNegativeButton("아니요") { _, _ -> }
show()
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package campus.tech.kakao.map.domain
package campus.tech.kakao.map.ui

import campus.tech.kakao.map.domain.Place

data class PlaceUiModel(
val placeList: List<Place>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.lifecycle.viewModelScope
import campus.tech.kakao.map.data.NetworkRepository
import campus.tech.kakao.map.data.PlaceRepository
import campus.tech.kakao.map.domain.Place
import campus.tech.kakao.map.domain.PlaceUiModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/campus/tech/kakao/map/ui/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package campus.tech.kakao.map.ui

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import campus.tech.kakao.map.KakaoMapApplication
import campus.tech.kakao.map.R
import campus.tech.kakao.map.databinding.SplashLayoutBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@AndroidEntryPoint
class SplashActivity : AppCompatActivity() {

private lateinit var splashBinding: SplashLayoutBinding
private val splashDisplayLength: Long = 1000

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
splashBinding = DataBindingUtil.setContentView(this, R.layout.splash_layout)

val remoteConfig = KakaoMapApplication.remoteConfig
val serviceState = remoteConfig.getString("serviceState")
val serviceMessage = remoteConfig.getString("serviceMessage")

CoroutineScope(Dispatchers.Main).launch {
delay(splashDisplayLength)
if (serviceState == "ON_SERVICE") {
val intent = Intent(this@SplashActivity, MapActivity::class.java)
startActivity(intent)
finish()
}
else {
splashBinding.tvError.text = serviceMessage
}
}
}
}
Loading