mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 09:43:15 +00:00
PrefのListを表示するように
This commit is contained in:
parent
00aa51e082
commit
7a3c6daf3d
|
@ -12,6 +12,10 @@ import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType;
|
import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType;
|
||||||
import one.nem.lacerta.source.pref.repository.Common; //TODO-rca: 名前変えるべきかも
|
import one.nem.lacerta.source.pref.repository.Common; //TODO-rca: 名前変えるべきかも
|
||||||
|
|
||||||
|
@ -68,6 +72,8 @@ public class DebugSharedPrefEditorFragment extends Fragment {
|
||||||
EditText loadKeyEditText = view.findViewById(R.id.loadKeyEditText);
|
EditText loadKeyEditText = view.findViewById(R.id.loadKeyEditText);
|
||||||
EditText saveKeyEditText = view.findViewById(R.id.saveKeyEditText);
|
EditText saveKeyEditText = view.findViewById(R.id.saveKeyEditText);
|
||||||
|
|
||||||
|
TextView loadValueTextView = view.findViewById(R.id.loadValueTextView);
|
||||||
|
|
||||||
view.findViewById(R.id.loadButton).setOnClickListener(v -> {
|
view.findViewById(R.id.loadButton).setOnClickListener(v -> {
|
||||||
String value = sharedPref.getSharedPreferencesByTag(sharedPrefType).getString(loadKeyEditText.getText().toString(), "null");
|
String value = sharedPref.getSharedPreferencesByTag(sharedPrefType).getString(loadKeyEditText.getText().toString(), "null");
|
||||||
((TextView) view.findViewById(R.id.loadValueTextView)).setText(value);
|
((TextView) view.findViewById(R.id.loadValueTextView)).setText(value);
|
||||||
|
@ -76,19 +82,27 @@ public class DebugSharedPrefEditorFragment extends Fragment {
|
||||||
view.findViewById(R.id.saveButton).setOnClickListener(v -> {
|
view.findViewById(R.id.saveButton).setOnClickListener(v -> {
|
||||||
String[] split = saveKeyEditText.getText().toString().split(":");
|
String[] split = saveKeyEditText.getText().toString().split(":");
|
||||||
sharedPref.getSharedPreferencesByTag(sharedPrefType).edit().putString(split[0], split[1]).apply();
|
sharedPref.getSharedPreferencesByTag(sharedPrefType).edit().putString(split[0], split[1]).apply();
|
||||||
|
updateList(loadValueTextView);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ラジオボタンの変更を監視
|
// ラジオボタンの変更を監視
|
||||||
view.findViewById(R.id.radioButtonCommon).setOnClickListener(v -> {
|
view.findViewById(R.id.radioButtonCommon).setOnClickListener(v -> {
|
||||||
sharedPrefType = SharedPrefType.COMMON;
|
sharedPrefType = SharedPrefType.COMMON;
|
||||||
|
updateList(loadValueTextView);
|
||||||
});
|
});
|
||||||
view.findViewById(R.id.radioButtonUserData).setOnClickListener(v -> {
|
view.findViewById(R.id.radioButtonUserData).setOnClickListener(v -> {
|
||||||
sharedPrefType = SharedPrefType.USERDATA;
|
sharedPrefType = SharedPrefType.USERDATA;
|
||||||
|
updateList(loadValueTextView);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRecyclerView(RecyclerView recyclerView) {
|
public void updateList(TextView textView) {
|
||||||
|
// リストの更新
|
||||||
|
Map<String, ?> resultMap = sharedPref.getSharedPreferencesByTag(sharedPrefType).getAll();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Map.Entry<String, ?> entry : resultMap.entrySet()) {
|
||||||
|
sb.append(entry.getKey()).append(":").append(entry.getValue().toString()).append("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user