This file contains 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
public interface OnClickListener { | |
void onClick(View v); | |
} | |
button.setOnClickListener(new OnClickListener() { | |
public void onClick(View v) { | |
//handle click | |
} | |
}); |
This file contains 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
protocol Grinder { | |
func grind(_ coffee: Coffee) | |
} | |
class GrinderMock: Grinder { | |
private(set) var timesUsed: Int = 0 | |
func grind(_ coffee: Coffee) { | |
timesUsed += 1 | |
} | |
} | |
class CoffeeMakerTest: XCTestCase { |
This file contains 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
protocol Shakeable { | |
func shake() | |
} | |
extension Shakeable where Self: UIView { | |
func shake() { | |
UIView.animate(... | |
} | |
} |
This file contains 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
interface ToastShowable { | |
fun showToast(context: Context, text: String) = ... | |
} | |
class MainActivity : ComponentActivity(), ToastShowable { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
//... | |
showToast(this, "Le toast") | |
} | |
} |
This file contains 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
interface Message { | |
val timestamp: DateTime | |
} | |
class TextMessage( | |
val text: String, | |
override val timestamp: DateTime | |
) : Message | |
class ImgMessage( |
This file contains 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
import android.text.Annotation | |
import android.text.SpannedString | |
import androidx.annotation.StringRes | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.platform.LocalContext | |
import androidx.compose.ui.text.AnnotatedString | |
import androidx.compose.ui.text.SpanStyle | |
import androidx.core.text.getSpans | |
@Composable |
This file contains 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
/* | |
* Copyright 2020 Google LLC | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains 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
private data class Border(val strokeWidth: Dp, val cornerRadius: Dp, val color: Color) | |
fun Modifier.bookCardBackground( | |
itemIndex: Int, | |
allItemsSize: Int | |
): Modifier { | |
val border = Border( | |
strokeWidth = 1.dp, | |
cornerRadius = 16.dp, |
This file contains 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
createPublisher(wrapper: observeUsersUseCase.observeUsers(usersCount: 5)) | |
.zip(createPublisher(wrapper: observeUsersUseCase.observeUsers(usersCount: 5))) | |
.sink( | |
receiveCompletion: { _ in }, | |
receiveValue: { user in | |
let user1 = user.0!.name | |
let user2 = user.1!.name | |
print("Date between \(user1) and \(user2)") | |
} | |
) |