mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
InternalUtils
This commit is contained in:
parent
141bddd504
commit
729600917c
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
package one.nem.lacerta.data.utils;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface UtilsRepo {
|
||||
|
||||
Path getExternalFilesDirPath(String type);
|
||||
|
||||
Path getExternalFilesDirPath();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user