InternalUtils

This commit is contained in:
ろむねこ 2023-12-12 10:45:55 +09:00
parent 141bddd504
commit 729600917c
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
3 changed files with 44 additions and 2 deletions

View File

@ -1,4 +1,28 @@
package one.nem.lacerta.data.utils; 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();
}
} }

View File

@ -1,4 +1,16 @@
package one.nem.lacerta.data.utils; 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);
} }

View File

@ -1,4 +1,10 @@
package one.nem.lacerta.data.utils; package one.nem.lacerta.data.utils;
import java.nio.file.Path;
public interface UtilsRepo { public interface UtilsRepo {
Path getExternalFilesDirPath(String type);
Path getExternalFilesDirPath();
} }