Skip to content

Commit

Permalink
Updated Application class and other documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
myofficework000 committed Mar 12, 2024
1 parent e1c5dc9 commit 6d46881
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,39 @@ import com.google.android.libraries.places.api.Places
import com.stripe.android.PaymentConfiguration
import dagger.hilt.android.HiltAndroidApp

/**
* Main application class for the Android application.
*/
@HiltAndroidApp
class MainApp: Application() {
companion object{
class MainApp : Application() {
companion object {
/**
* Notification manager instance.
*/
lateinit var notificationManager: NotificationManager
}

override fun onCreate() {
super.onCreate()

// App is always above API 26
// Create notification channel
val notificationChannel = NotificationChannel(
"channel_id",
"channel_name",
NotificationManager.IMPORTANCE_HIGH
)
notificationChannel.description = "notification channel desc.."
notificationChannel.description = "Notification channel description"
notificationChannel.enableVibration(true)
notificationChannel.enableLights(true)
notificationChannel.vibrationPattern = longArrayOf(100,200,300,400,300,200,100)
notificationChannel.vibrationPattern = longArrayOf(100, 200, 300, 400, 300, 200, 100)

notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(notificationChannel)

// Initialize Google Places SDK
Places.initialize(applicationContext, resources.getString(R.string.GOOGLE_MAPS_API_KEY))

// Initialize Stripe SDK
PaymentConfiguration.init(applicationContext, STRIPE_PUBLISHABLE_KEY)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
* Dagger Hilt module for providing dependencies related to Room database.
*/
@Module
@InstallIn(SingletonComponent::class)
class RoomModules {
/**
* Provides an instance of the Room database.
* @param context Application context.
* @return Instance of the Room database.
*/
@Provides
@Singleton
fun provideAppDatabase(@ApplicationContext context: Context) = Room.databaseBuilder(
Expand All @@ -26,11 +34,21 @@ class RoomModules {
.addMigrations(migration1To2)
.build()

/**
* Provides an instance of the AlarmDao.
* @param db Instance of the Room database.
* @return Instance of the AlarmDao.
*/
@Provides
@Singleton
fun provideAlarmDao(db: AppDatabase) = db.getAlarmDao()

/**
* Provides an instance of the ProfileDao.
* @param db Instance of the Room database.
* @return Instance of the ProfileDao.
*/
@Provides
@Singleton
fun provideProfileDao(db: AppDatabase) = db.getProfileDao()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
* Dagger Hilt module for providing dependencies related to state management.
*/
@Module
@InstallIn(SingletonComponent::class)
class StateModule {
class StateModule {

@Singleton
@Provides
@MviNewsAPI
fun provideNewsStates(repository: RemoteNewRepository):NewsState{
return NewsState(repository)
}
}
/**
* Provides an instance of NewsState for MVI (Model-View-Intent) architecture.
* @param repository RemoteNewRepository instance.
* @return Instance of NewsState.
*/
@Singleton
@Provides
@MviNewsAPI
fun provideNewsStates(repository: RemoteNewRepository): NewsState {
return NewsState(repository)
}
}

0 comments on commit 6d46881

Please sign in to comment.