ディレクトリ整理

This commit is contained in:
ろむねこ 2023-12-11 15:59:03 +09:00
parent 14a8b1a66d
commit 85282a2a34
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
11 changed files with 0 additions and 94 deletions

View File

@ -1,60 +0,0 @@
package one.nem.lacerta.source.pref.impl;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import dagger.hilt.android.qualifiers.ApplicationContext;
import one.nem.lacerta.source.pref.repository.Common;
public class CommonImpl implements Common {
Context applicationContext;
@Inject
public CommonImpl(@ApplicationContext Context applicationContext) {
this.applicationContext = applicationContext;
}
public String getStringValue(String key) {
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
return pref.getString(key, "");
}
public void setStringValue(String key, String value) {
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.putString(key, value);
editor.apply();
}
public boolean isExist(String key) {
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
return pref.contains(key);
}
public void remove(String key) {
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.remove(key);
editor.apply();
}
public ArrayList<String> getExistKeys() {
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
// キーだけをArrayListに切り出す
return new ArrayList<>(pref.getAll().keySet());
}
}

View File

@ -1,16 +0,0 @@
package one.nem.lacerta.source.pref.module;
import dagger.Binds;
import dagger.Module;
import dagger.hilt.InstallIn;
import dagger.hilt.components.SingletonComponent;
import one.nem.lacerta.source.pref.impl.CommonImpl;
import one.nem.lacerta.source.pref.repository.Common;
@Module
@InstallIn(SingletonComponent.class)
abstract public class CommonModule {
@Binds
public abstract Common bindCommon(CommonImpl commonImpl);
}

View File

@ -1,18 +0,0 @@
package one.nem.lacerta.source.pref.repository;
import java.util.ArrayList;
import java.util.List;
public interface Common {
// さまざまな用途で使うPref
String getStringValue(String key);
void setStringValue(String key, String value);
boolean isExist(String key);
void remove(String key);
ArrayList<String> getExistKeys();
}