This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Content() { | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text( | |
text = "Hello,", | |
modifier = Modifier.padding(bottom = 8.dp), | |
style = MaterialTheme.typography.h5 | |
) | |
OutlinedTextField( | |
value = "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Content() { | |
var name by remember { mutableStateOf("") } | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text( | |
text = "Hello, $name", | |
modifier = Modifier.padding(bottom = 8.dp), | |
style = MaterialTheme.typography.h5 | |
) | |
OutlinedTextField( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun HomeScreen() { | |
var name by remember { mutableStateOf("") } | |
Content(name = name, onNameChange = { name = it }) | |
} | |
@Composable | |
fun Content(name: String, onNameChange: (String) -> Unit) { | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Person(val name: String, val email: String, val age: Int) | |
fun search() { | |
val henry = Person(name = "Henry", email = "[email protected]", age = 24) | |
val robert = Person(name = "Robert", email = "[email protected]", age = 22) | |
val tom = Person(name = "Tom", email = "[email protected]", age = 25) | |
val listOfPerson = listOf(henry, robert, tom) | |
val searchUtil = SearchUtil(list = listOfPerson) | |
searchUtil.searchItem(element = henry) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchUtil(private val list: List<Int>) { | |
fun searchItem(element: Int, foundItem: (element: Int?) -> Unit) { | |
val itemFoundList = list.filter { | |
it == element | |
} | |
if (itemFoundList.isNullOrEmpty()) | |
foundItem(null) | |
else | |
foundItem(itemFoundList.first()) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Before | |
fun setUp() { | |
areaRepository = Mockito.mock(AreaRepository::class.java) | |
Mockito.`when`(areaRepository.calculateArea(3.5)).thenReturn(38.465) | |
areaViewModel = AreaViewModel(areaRepository) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car { | |
var fuel = 0 | |
fun addFuel(){ | |
CoroutineScope(Dispatchers.IO).launch { | |
fuel = 50 | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car { | |
var isEngineTurnedOn = false | |
suspend fun turnOnEngine(){ | |
delay(4000) | |
isEngineTurnedOn = true | |
} | |
} | |
class CarTest { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
@InstallIn(SingletonComponent::class) | |
object RepositoryModule { | |
@Provides | |
fun provideImageRepository(imageApiService: ImageApiService): ImageRepository { | |
return ImageRepository(imageApiService) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
@InstallIn(SingletonComponent::class) | |
object NetworkModule { | |
@Provides | |
@Singleton | |
fun provideHttpClient(): OkHttpClient { | |
return OkHttpClient.Builder().apply { | |
this.addInterceptor(Interceptor { chain -> | |
val original = chain.request() | |
val request = original.newBuilder() |