From 24332576e21d564f429792b629f73d1ed58e1b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Sun, 10 Dec 2023 18:27:14 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E5=90=8D=E3=81=AE=E3=83=9F=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?,=20DI=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 1 + .../main/java/one/nem/lacerta/MainActivity.java | 2 ++ data/build.gradle | 2 +- .../lacerta/data/ExampleInstrumentedTest.java | 4 ++-- .../nem}/lacerta/data/impl/DeviceMetaImpl.java | 4 ++-- .../lacerta/data/module/DeviceMetaModule.java | 8 +++----- .../nem}/lacerta/data/repository/DeviceMeta.java | 2 +- .../nem}/lacerta/data/ExampleUnitTest.java | 2 +- feature/debug/build.gradle | 1 - .../lacerta/feature/debug/DebugMenuFragment.java | 16 +++++++++++----- 10 files changed, 24 insertions(+), 18 deletions(-) rename data/src/androidTest/java/{com/example => one/nem}/lacerta/data/ExampleInstrumentedTest.java (84%) rename data/src/main/java/{com/example => one/nem}/lacerta/data/impl/DeviceMetaImpl.java (76%) rename data/src/main/java/{com/example => one/nem}/lacerta/data/module/DeviceMetaModule.java (63%) rename data/src/main/java/{com/example => one/nem}/lacerta/data/repository/DeviceMeta.java (66%) rename data/src/test/java/{com/example => one/nem}/lacerta/data/ExampleUnitTest.java (91%) diff --git a/app/build.gradle b/app/build.gradle index 89166fec..92befcda 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,6 +57,7 @@ dependencies { // implementation project(':data:source:database') // implementation project(':data:source:preference') // + implementation project(':data') // Hilt (DI) implementation libs.com.google.dagger.hilt.android annotationProcessor libs.com.google.dagger.hilt.compiler diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index b541757e..50c3be6d 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -12,6 +12,8 @@ import android.widget.Toast; import com.google.android.material.bottomnavigation.BottomNavigationView; + + import dagger.hilt.android.AndroidEntryPoint; import javax.inject.Inject; diff --git a/data/build.gradle b/data/build.gradle index b138dbe9..f333a071 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -4,7 +4,7 @@ plugins { } android { - namespace 'com.example.lacerta.data' + namespace 'one.nem.lacerta.data' compileSdk 34 defaultConfig { diff --git a/data/src/androidTest/java/com/example/lacerta/data/ExampleInstrumentedTest.java b/data/src/androidTest/java/one/nem/lacerta/data/ExampleInstrumentedTest.java similarity index 84% rename from data/src/androidTest/java/com/example/lacerta/data/ExampleInstrumentedTest.java rename to data/src/androidTest/java/one/nem/lacerta/data/ExampleInstrumentedTest.java index 1e26c06e..20b7a66e 100644 --- a/data/src/androidTest/java/com/example/lacerta/data/ExampleInstrumentedTest.java +++ b/data/src/androidTest/java/one/nem/lacerta/data/ExampleInstrumentedTest.java @@ -1,4 +1,4 @@ -package com.example.lacerta.data; +package one.nem.lacerta.data; import android.content.Context; @@ -21,6 +21,6 @@ public class ExampleInstrumentedTest { public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.example.lacerta.data.test", appContext.getPackageName()); + assertEquals("one.nem.lacerta.data.test", appContext.getPackageName()); } } \ No newline at end of file diff --git a/data/src/main/java/com/example/lacerta/data/impl/DeviceMetaImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/DeviceMetaImpl.java similarity index 76% rename from data/src/main/java/com/example/lacerta/data/impl/DeviceMetaImpl.java rename to data/src/main/java/one/nem/lacerta/data/impl/DeviceMetaImpl.java index 59c56256..650a7ccc 100644 --- a/data/src/main/java/com/example/lacerta/data/impl/DeviceMetaImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/DeviceMetaImpl.java @@ -1,6 +1,6 @@ -package com.example.lacerta.data.impl; +package one.nem.lacerta.data.impl; -import com.example.lacerta.data.repository.DeviceMeta; +import one.nem.lacerta.data.repository.DeviceMeta; import javax.inject.Inject; diff --git a/data/src/main/java/com/example/lacerta/data/module/DeviceMetaModule.java b/data/src/main/java/one/nem/lacerta/data/module/DeviceMetaModule.java similarity index 63% rename from data/src/main/java/com/example/lacerta/data/module/DeviceMetaModule.java rename to data/src/main/java/one/nem/lacerta/data/module/DeviceMetaModule.java index dd77caee..21693156 100644 --- a/data/src/main/java/com/example/lacerta/data/module/DeviceMetaModule.java +++ b/data/src/main/java/one/nem/lacerta/data/module/DeviceMetaModule.java @@ -1,9 +1,7 @@ -package com.example.lacerta.data.module; +package one.nem.lacerta.data.module; -import android.app.Application; - -import com.example.lacerta.data.impl.DeviceMetaImpl; -import com.example.lacerta.data.repository.DeviceMeta; +import one.nem.lacerta.data.impl.DeviceMetaImpl; +import one.nem.lacerta.data.repository.DeviceMeta; import dagger.Binds; import dagger.Module; diff --git a/data/src/main/java/com/example/lacerta/data/repository/DeviceMeta.java b/data/src/main/java/one/nem/lacerta/data/repository/DeviceMeta.java similarity index 66% rename from data/src/main/java/com/example/lacerta/data/repository/DeviceMeta.java rename to data/src/main/java/one/nem/lacerta/data/repository/DeviceMeta.java index 552d1b77..6d6bc2b2 100644 --- a/data/src/main/java/com/example/lacerta/data/repository/DeviceMeta.java +++ b/data/src/main/java/one/nem/lacerta/data/repository/DeviceMeta.java @@ -1,4 +1,4 @@ -package com.example.lacerta.data.repository; +package one.nem.lacerta.data.repository; public interface DeviceMeta { String getDeviceId(); diff --git a/data/src/test/java/com/example/lacerta/data/ExampleUnitTest.java b/data/src/test/java/one/nem/lacerta/data/ExampleUnitTest.java similarity index 91% rename from data/src/test/java/com/example/lacerta/data/ExampleUnitTest.java rename to data/src/test/java/one/nem/lacerta/data/ExampleUnitTest.java index 2a0cd4ed..2dfc33a8 100644 --- a/data/src/test/java/com/example/lacerta/data/ExampleUnitTest.java +++ b/data/src/test/java/one/nem/lacerta/data/ExampleUnitTest.java @@ -1,4 +1,4 @@ -package com.example.lacerta.data; +package one.nem.lacerta.data; import org.junit.Test; diff --git a/feature/debug/build.gradle b/feature/debug/build.gradle index 54c974db..4ef20d55 100644 --- a/feature/debug/build.gradle +++ b/feature/debug/build.gradle @@ -45,7 +45,6 @@ dependencies { // 内部モジュール // data - implementation project(':data') diff --git a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugMenuFragment.java b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugMenuFragment.java index d0d8187d..5135617f 100644 --- a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugMenuFragment.java +++ b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugMenuFragment.java @@ -13,6 +13,9 @@ import android.widget.Toast; import dagger.hilt.android.AndroidEntryPoint; import javax.inject.Inject; +import one.nem.lacerta.data.repository.DeviceMeta; + + /** * A simple {@link Fragment} subclass. * Use the {@link DebugMenuFragment#newInstance} factory method to @@ -22,6 +25,9 @@ import javax.inject.Inject; @AndroidEntryPoint public class DebugMenuFragment extends Fragment { + @Inject + DeviceMeta deviceMeta; + // TODO: Rename parameter arguments, choose names that match // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER @@ -74,11 +80,11 @@ public class DebugMenuFragment extends Fragment { public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); -// Button button = view.findViewById(R.id.button_di_test); -// // Lambda -// button.setOnClickListener(v -> { -// Toast.makeText(getContext(), testData.getTestData(), Toast.LENGTH_SHORT).show(); -// }); + Button button = view.findViewById(R.id.button_di_test); + // Lambda + button.setOnClickListener(v -> { + Toast.makeText(getContext(), deviceMeta.getDeviceId(), Toast.LENGTH_SHORT).show(); + }); } } \ No newline at end of file