From 2188e55c5f19d3420e3ffad05fb19c364d224192 Mon Sep 17 00:00:00 2001 From: r-ca Date: Thu, 14 Dec 2023 03:43:20 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=93=E3=83=AB=E3=83=89=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=AE=E3=81=A7=E4=B8=80=E6=97=A6=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=82=A2=E3=82=A6=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../debug/DebugSharedPrefEditorFragment.java | 222 +++++++++--------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugSharedPrefEditorFragment.java b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugSharedPrefEditorFragment.java index 79100cf3..1826fe37 100644 --- a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugSharedPrefEditorFragment.java +++ b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugSharedPrefEditorFragment.java @@ -1,111 +1,111 @@ -package one.nem.lacerta.feature.debug; - -import android.os.Bundle; - -import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.RecyclerView; - -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.EditText; -import android.widget.RadioGroup; -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.repository.SharedPref; - -import javax.inject.Inject; - -import dagger.hilt.android.AndroidEntryPoint; - -/** - * A simple {@link Fragment} subclass. - * Use the {@link DebugSharedPrefEditorFragment#newInstance} factory method to - * create an instance of this fragment. - */ -@AndroidEntryPoint -public class DebugSharedPrefEditorFragment extends Fragment { - - @Inject - SharedPref sharedPref; - - SharedPrefType sharedPrefType = null; - - public DebugSharedPrefEditorFragment() { - // Required empty public constructor - } - - public static DebugSharedPrefEditorFragment newInstance() { - DebugSharedPrefEditorFragment fragment = new DebugSharedPrefEditorFragment(); - Bundle args = new Bundle(); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_debug_shared_pref_editor, container, false); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - EditText loadKeyEditText = view.findViewById(R.id.loadKeyEditText); - EditText saveKeyEditText = view.findViewById(R.id.saveKeyEditText); - - TextView prefItemTextView = view.findViewById(R.id.prefItemTextView); - - view.findViewById(R.id.loadButton).setOnClickListener(v -> { - String value = sharedPref.getSharedPreferencesByTag(sharedPrefType).getString(loadKeyEditText.getText().toString(), "null"); - ((TextView) view.findViewById(R.id.loadValueTextView)).setText(value); - }); - - view.findViewById(R.id.saveButton).setOnClickListener(v -> { - String[] split = saveKeyEditText.getText().toString().split(":"); - sharedPref.getSharedPreferencesByTag(sharedPrefType).edit().putString(split[0], split[1]).apply(); - updateList(prefItemTextView); - }); - - // ラジオボタンの変更を監視 - ((RadioGroup) view.findViewById(R.id.radioGroupPrefType)).setOnCheckedChangeListener((group, checkedId) -> { - if (checkedId == R.id.radioButtonCommon) { - sharedPrefType = SharedPrefType.COMMON; - updateList(prefItemTextView); - } else if (checkedId == R.id.radioButtonUserData) { - sharedPrefType = SharedPrefType.USERDATA; - updateList(prefItemTextView); - } else { - Log.e("DebugSharedPrefEditorFragment", "radioButtonのIDが不正です"); - } - updateList(prefItemTextView); - }); - - } - - public void updateList(TextView textView) { - // リストの更新 - Map resultMap = sharedPref.getSharedPreferencesByTag(sharedPrefType).getAll(); - StringBuilder sb = new StringBuilder(); - for (Map.Entry entry : resultMap.entrySet()) { - sb.append(entry.getKey()).append(":").append(entry.getValue().toString()).append("\n"); - } - - textView.setText(sb.toString()); - } -} \ No newline at end of file +//package one.nem.lacerta.feature.debug; +// +//import android.os.Bundle; +// +//import androidx.fragment.app.Fragment; +//import androidx.recyclerview.widget.RecyclerView; +// +//import android.util.Log; +//import android.view.LayoutInflater; +//import android.view.View; +//import android.view.ViewGroup; +//import android.widget.EditText; +//import android.widget.RadioGroup; +//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.repository.SharedPref; +// +//import javax.inject.Inject; +// +//import dagger.hilt.android.AndroidEntryPoint; +// +///** +// * A simple {@link Fragment} subclass. +// * Use the {@link DebugSharedPrefEditorFragment#newInstance} factory method to +// * create an instance of this fragment. +// */ +//@AndroidEntryPoint +//public class DebugSharedPrefEditorFragment extends Fragment { +// +// @Inject +// SharedPref sharedPref; +// +// SharedPrefType sharedPrefType = null; +// +// public DebugSharedPrefEditorFragment() { +// // Required empty public constructor +// } +// +// public static DebugSharedPrefEditorFragment newInstance() { +// DebugSharedPrefEditorFragment fragment = new DebugSharedPrefEditorFragment(); +// Bundle args = new Bundle(); +// fragment.setArguments(args); +// return fragment; +// } +// +// @Override +// public void onCreate(Bundle savedInstanceState) { +// super.onCreate(savedInstanceState); +// +// } +// +// @Override +// public View onCreateView(LayoutInflater inflater, ViewGroup container, +// Bundle savedInstanceState) { +// // Inflate the layout for this fragment +// return inflater.inflate(R.layout.fragment_debug_shared_pref_editor, container, false); +// } +// +// @Override +// public void onViewCreated(View view, Bundle savedInstanceState) { +// super.onViewCreated(view, savedInstanceState); +// +// EditText loadKeyEditText = view.findViewById(R.id.loadKeyEditText); +// EditText saveKeyEditText = view.findViewById(R.id.saveKeyEditText); +// +// TextView prefItemTextView = view.findViewById(R.id.prefItemTextView); +// +// view.findViewById(R.id.loadButton).setOnClickListener(v -> { +// String value = sharedPref.getSharedPreferencesByTag(sharedPrefType).getString(loadKeyEditText.getText().toString(), "null"); +// ((TextView) view.findViewById(R.id.loadValueTextView)).setText(value); +// }); +// +// view.findViewById(R.id.saveButton).setOnClickListener(v -> { +// String[] split = saveKeyEditText.getText().toString().split(":"); +// sharedPref.getSharedPreferencesByTag(sharedPrefType).edit().putString(split[0], split[1]).apply(); +// updateList(prefItemTextView); +// }); +// +// // ラジオボタンの変更を監視 +// ((RadioGroup) view.findViewById(R.id.radioGroupPrefType)).setOnCheckedChangeListener((group, checkedId) -> { +// if (checkedId == R.id.radioButtonCommon) { +// sharedPrefType = SharedPrefType.COMMON; +// updateList(prefItemTextView); +// } else if (checkedId == R.id.radioButtonUserData) { +// sharedPrefType = SharedPrefType.USERDATA; +// updateList(prefItemTextView); +// } else { +// Log.e("DebugSharedPrefEditorFragment", "radioButtonのIDが不正です"); +// } +// updateList(prefItemTextView); +// }); +// +// } +// +// public void updateList(TextView textView) { +// // リストの更新 +// Map resultMap = sharedPref.getSharedPreferencesByTag(sharedPrefType).getAll(); +// StringBuilder sb = new StringBuilder(); +// for (Map.Entry entry : resultMap.entrySet()) { +// sb.append(entry.getKey()).append(":").append(entry.getValue().toString()).append("\n"); +// } +// +// textView.setText(sb.toString()); +// } +//} \ No newline at end of file