mirror of
				https://github.com/lacerta-doc/Lacerta.git
				synced 2025-10-31 07:20:48 +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:preference') | ||||
| // | ||||
|     implementation project(':data') | ||||
|     // Hilt (DI) | ||||
|     implementation libs.com.google.dagger.hilt.android | ||||
|     annotationProcessor libs.com.google.dagger.hilt.compiler | ||||
|  | ||||
| @ -12,6 +12,8 @@ import android.widget.Toast; | ||||
| import com.google.android.material.bottomnavigation.BottomNavigationView; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| import dagger.hilt.android.AndroidEntryPoint; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
|  | ||||
| @ -4,7 +4,7 @@ plugins { | ||||
| } | ||||
| 
 | ||||
| android { | ||||
|     namespace 'com.example.lacerta.data' | ||||
|     namespace 'one.nem.lacerta.data' | ||||
|     compileSdk 34 | ||||
| 
 | ||||
|     defaultConfig { | ||||
|  | ||||
| @ -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()); | ||||
|     } | ||||
| } | ||||
| @ -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; | ||||
| 
 | ||||
| @ -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; | ||||
| @ -1,4 +1,4 @@ | ||||
| package com.example.lacerta.data.repository; | ||||
| package one.nem.lacerta.data.repository; | ||||
| 
 | ||||
| public interface DeviceMeta { | ||||
|     String getDeviceId(); | ||||
| @ -1,4 +1,4 @@ | ||||
| package com.example.lacerta.data; | ||||
| package one.nem.lacerta.data; | ||||
| 
 | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| @ -45,7 +45,6 @@ dependencies { | ||||
| 
 | ||||
|     // 内部モジュール | ||||
|     // data | ||||
| 
 | ||||
|     implementation project(':data') | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -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(); | ||||
|         }); | ||||
| 
 | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user