mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 09:43:15 +00:00
ディレクトリ整理
This commit is contained in:
parent
14a8b1a66d
commit
85282a2a34
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user