diff --git a/data/src/main/java/one/nem/lacerta/data/utils/UtilsImpl.java b/data/src/main/java/one/nem/lacerta/data/utils/UtilsImpl.java index e0605730..ec1591be 100644 --- a/data/src/main/java/one/nem/lacerta/data/utils/UtilsImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/utils/UtilsImpl.java @@ -1,4 +1,28 @@ package one.nem.lacerta.data.utils; -public class UtilsImpl { +import android.content.Context; + +import java.nio.file.Path; +import java.util.Objects; + +import javax.inject.Inject; + +import dagger.hilt.android.qualifiers.ApplicationContext; +import one.nem.lacerta.data.utils.UtilsRepo; +public class UtilsImpl implements UtilsRepo{ + + private final Context applicationContext; + + @Inject + public UtilsImpl(@ApplicationContext Context applicationContext) { + this.applicationContext = applicationContext; + } + + public Path getExternalFilesDirPath(String type) { + return Objects.requireNonNull(applicationContext.getExternalFilesDir(type)).toPath(); + } + + public Path getExternalFilesDirPath() { + return Objects.requireNonNull(applicationContext.getExternalFilesDir(null)).toPath(); + } } diff --git a/data/src/main/java/one/nem/lacerta/data/utils/UtilsModule.java b/data/src/main/java/one/nem/lacerta/data/utils/UtilsModule.java index 1ccc89d1..d03692e9 100644 --- a/data/src/main/java/one/nem/lacerta/data/utils/UtilsModule.java +++ b/data/src/main/java/one/nem/lacerta/data/utils/UtilsModule.java @@ -1,4 +1,16 @@ package one.nem.lacerta.data.utils; -public class UtilsModule { +import dagger.Binds; +import dagger.Module; +import dagger.hilt.InstallIn; +import one.nem.lacerta.data.utils.UtilsRepo; +import one.nem.lacerta.data.utils.UtilsImpl; +import dagger.hilt.components.SingletonComponent; + +@Module +@InstallIn(SingletonComponent.class) +abstract public class UtilsModule { + + @Binds + public abstract UtilsRepo bindUtils(UtilsImpl utilsImpl); } diff --git a/data/src/main/java/one/nem/lacerta/data/utils/UtilsRepo.java b/data/src/main/java/one/nem/lacerta/data/utils/UtilsRepo.java index 2a855990..1b148261 100644 --- a/data/src/main/java/one/nem/lacerta/data/utils/UtilsRepo.java +++ b/data/src/main/java/one/nem/lacerta/data/utils/UtilsRepo.java @@ -1,4 +1,10 @@ package one.nem.lacerta.data.utils; +import java.nio.file.Path; + public interface UtilsRepo { + + Path getExternalFilesDirPath(String type); + + Path getExternalFilesDirPath(); }