InternalUtilsなモジュールに移植WIP

This commit is contained in:
ろむねこ 2023-12-12 11:00:26 +09:00
parent 6bc741d0b0
commit 119140a6bc
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
5 changed files with 68 additions and 2 deletions

View File

@ -8,5 +8,4 @@ public interface UtilsRepo {
Path getExternalFilesDirPath();
}

View File

@ -1,10 +1,21 @@
package one.nem.lacerta.source.jgit;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
public class RepoUtils {
// Internal Utils
public static String getRepoName(Repository repo) {
public Repository createRepo(String id, ) {
Repository repository = FileRepositoryBuilder.create(
)
}
public Repository getRepo(String id) {
// WIP
}
public String getRepoName(Repository repo) {
return repo.getDirectory().getParentFile().getName();
}

View File

@ -0,0 +1,29 @@
package oen.nem.lacerta.utils.impl;
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

@ -0,0 +1,16 @@
package oen.nem.lacerta.utils.module;
import dagger.Binds;
import dagger.Module;
import dagger.hilt.InstallIn;
import dagger.hilt.components.SingletonComponent;
import one.nem.lacerta.data.utils.UtilsImpl;
import one.nem.lacerta.data.utils.UtilsRepo;
@Module
@InstallIn(SingletonComponent.class)
abstract public class UtilsModule {
@Binds
public abstract UtilsRepo bindUtils(UtilsImpl utilsImpl);
}

View File

@ -0,0 +1,11 @@
package oen.nem.lacerta.utils.repository;
import java.nio.file.Path;
public interface UtilsRepo {
Path getExternalFilesDirPath(String type);
Path getExternalFilesDirPath();
}