2025-07-03 21:13:23 -04:00
|
|
|
package com.mattintech.lchat.di
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
2025-07-03 21:43:49 -04:00
|
|
|
import androidx.room.Room
|
|
|
|
|
import com.mattintech.lchat.data.db.LChatDatabase
|
|
|
|
|
import com.mattintech.lchat.data.db.dao.MessageDao
|
2025-07-03 21:13:23 -04:00
|
|
|
import com.mattintech.lchat.network.WifiAwareManager
|
|
|
|
|
import dagger.Module
|
|
|
|
|
import dagger.Provides
|
|
|
|
|
import dagger.hilt.InstallIn
|
|
|
|
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
|
|
|
import dagger.hilt.components.SingletonComponent
|
|
|
|
|
import javax.inject.Singleton
|
|
|
|
|
|
|
|
|
|
@Module
|
|
|
|
|
@InstallIn(SingletonComponent::class)
|
|
|
|
|
object AppModule {
|
|
|
|
|
|
|
|
|
|
@Provides
|
|
|
|
|
@Singleton
|
|
|
|
|
fun provideWifiAwareManager(
|
|
|
|
|
@ApplicationContext context: Context
|
|
|
|
|
): WifiAwareManager {
|
|
|
|
|
return WifiAwareManager(context)
|
|
|
|
|
}
|
2025-07-03 21:43:49 -04:00
|
|
|
|
|
|
|
|
@Provides
|
|
|
|
|
@Singleton
|
|
|
|
|
fun provideLChatDatabase(
|
|
|
|
|
@ApplicationContext context: Context
|
|
|
|
|
): LChatDatabase {
|
|
|
|
|
return Room.databaseBuilder(
|
|
|
|
|
context,
|
|
|
|
|
LChatDatabase::class.java,
|
|
|
|
|
"lchat_database"
|
|
|
|
|
).build()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Provides
|
|
|
|
|
fun provideMessageDao(database: LChatDatabase): MessageDao {
|
|
|
|
|
return database.messageDao()
|
|
|
|
|
}
|
2025-07-03 21:13:23 -04:00
|
|
|
}
|