mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
パッケージ名のミスを修正, DI実装
This commit is contained in:
parent
15ee6f344f
commit
24332576e2
|
@ -57,6 +57,7 @@ dependencies {
|
||||||
// implementation project(':data:source:database')
|
// implementation project(':data:source:database')
|
||||||
// implementation project(':data:source:preference')
|
// implementation project(':data:source:preference')
|
||||||
//
|
//
|
||||||
|
implementation project(':data')
|
||||||
// Hilt (DI)
|
// Hilt (DI)
|
||||||
implementation libs.com.google.dagger.hilt.android
|
implementation libs.com.google.dagger.hilt.android
|
||||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||||
|
|
|
@ -12,6 +12,8 @@ import android.widget.Toast;
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'com.example.lacerta.data'
|
namespace 'one.nem.lacerta.data'
|
||||||
compileSdk 34
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.lacerta.data;
|
package one.nem.lacerta.data;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
|
||||||
public void useAppContext() {
|
public void useAppContext() {
|
||||||
// Context of the app under test.
|
// Context of the app under test.
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
assertEquals("com.example.lacerta.data.test", appContext.getPackageName());
|
assertEquals("one.nem.lacerta.data.test", appContext.getPackageName());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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;
|
import javax.inject.Inject;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.example.lacerta.data.module;
|
package one.nem.lacerta.data.module;
|
||||||
|
|
||||||
import android.app.Application;
|
import one.nem.lacerta.data.impl.DeviceMetaImpl;
|
||||||
|
import one.nem.lacerta.data.repository.DeviceMeta;
|
||||||
import com.example.lacerta.data.impl.DeviceMetaImpl;
|
|
||||||
import com.example.lacerta.data.repository.DeviceMeta;
|
|
||||||
|
|
||||||
import dagger.Binds;
|
import dagger.Binds;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.lacerta.data.repository;
|
package one.nem.lacerta.data.repository;
|
||||||
|
|
||||||
public interface DeviceMeta {
|
public interface DeviceMeta {
|
||||||
String getDeviceId();
|
String getDeviceId();
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.lacerta.data;
|
package one.nem.lacerta.data;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -45,7 +45,6 @@ dependencies {
|
||||||
|
|
||||||
// 内部モジュール
|
// 内部モジュール
|
||||||
// data
|
// data
|
||||||
|
|
||||||
implementation project(':data')
|
implementation project(':data')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ import android.widget.Toast;
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import one.nem.lacerta.data.repository.DeviceMeta;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
* Use the {@link DebugMenuFragment#newInstance} factory method to
|
* Use the {@link DebugMenuFragment#newInstance} factory method to
|
||||||
|
@ -22,6 +25,9 @@ import javax.inject.Inject;
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
public class DebugMenuFragment extends Fragment {
|
public class DebugMenuFragment extends Fragment {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DeviceMeta deviceMeta;
|
||||||
|
|
||||||
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
// TODO: Rename parameter arguments, choose names that match
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
// 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) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
// Button button = view.findViewById(R.id.button_di_test);
|
Button button = view.findViewById(R.id.button_di_test);
|
||||||
// // Lambda
|
// Lambda
|
||||||
// button.setOnClickListener(v -> {
|
button.setOnClickListener(v -> {
|
||||||
// Toast.makeText(getContext(), testData.getTestData(), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), deviceMeta.getDeviceId(), Toast.LENGTH_SHORT).show();
|
||||||
// });
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user