From 14a8b1a66dbbe95fc6c29e51b8e77007cbc640e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 11 Dec 2023 15:39:34 +0900 Subject: [PATCH] =?UTF-8?q?Inject=E3=81=97=E3=81=9F,=20=E4=BE=8B=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../debug/DebugPlayGroundFragment.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugPlayGroundFragment.java b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugPlayGroundFragment.java index 9ee534ba..1a35138c 100644 --- a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugPlayGroundFragment.java +++ b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugPlayGroundFragment.java @@ -7,14 +7,27 @@ import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; -/** - * A simple {@link Fragment} subclass. - * Use the {@link DebugPlayGroundFragment#newInstance} factory method to - * create an instance of this fragment. - */ +import one.nem.lacerta.data.repository.Documents; + +import one.nem.lacerta.data.repository.SharedPref; + +import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType; + +import javax.inject.Inject; + +import dagger.hilt.android.AndroidEntryPoint; + +@AndroidEntryPoint // HiltのDIを有効にするアノテーション public class DebugPlayGroundFragment extends Fragment { + @Inject // DI + Documents documents; + + @Inject // DI + SharedPref sharedPref; + public DebugPlayGroundFragment() { // Required empty public constructor } @@ -45,5 +58,8 @@ public class DebugPlayGroundFragment extends Fragment { // ここがいままでのonCreateと同等のものです。 // findViewById(R.id.hoge)とかは view.findViewById(R.id.hoge) と書き換える必要アリ // (viewは引数として受け取ってるviewなので、別メソッドに切り出したりするなら渡してあげる) + + // ShardPrefの要素数をトーストする例 + Toast.makeText(getContext(), "SharedPrefの要素数: " + sharedPref.getSharedPreferencesByTag(SharedPrefType.COMMON).getAll().size(), Toast.LENGTH_SHORT).show(); } } \ No newline at end of file