Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 9110eb13 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor(install): move install persistence DI to data module

parent 078a320c
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
package foundation.e.apps.data.di.db

import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import foundation.e.apps.data.installation.local.AppInstallDAO
import foundation.e.apps.data.installation.local.AppInstallDatabase
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {
    @Singleton
    @Provides
    fun provideDatabaseInstance(@ApplicationContext context: Context): AppInstallDatabase {
        return AppInstallDatabase.getInstance(context)
    }

    @Singleton
    @Provides
    fun provideFusedDaoInstance(appInstallDatabase: AppInstallDatabase): AppInstallDAO {
        return appInstallDatabase.fusedDownloadDao()
    }
}
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2026 e Foundation
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */

package foundation.e.apps.data.installation.di

import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import foundation.e.apps.data.installation.local.AppInstallDAO
import foundation.e.apps.data.installation.local.AppInstallDatabase
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object AppInstallPersistenceModule {
    @Singleton
    @Provides
    fun provideDatabaseInstance(@ApplicationContext context: Context): AppInstallDatabase {
        return AppInstallDatabase.getInstance(context)
    }

    @Singleton
    @Provides
    fun provideFusedDaoInstance(appInstallDatabase: AppInstallDatabase): AppInstallDAO {
        return appInstallDatabase.fusedDownloadDao()
    }
}