Skip to content

Instantly share code, notes, and snippets.

View pauloaapereira's full-sized avatar

Paulo Pereira pauloaapereira

View GitHub Profile
@pauloaapereira
pauloaapereira / example1.kt
Created July 23, 2021 16:02
Declarative UI Brief Analysis
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Text(
text = "Text1",
color = Color.Black,
fontSize = 21.sp
)
@pauloaapereira
pauloaapereira / example1.xml
Created July 23, 2021 15:34
Declarative UI Brief Analysis
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@pauloaapereira
pauloaapereira / declarative_2.kt
Created May 22, 2021 16:10
Declarative UI Analysis
val listOfNumbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val listOfEvenNumbers = listOfNumbers.filter { number -> number % 2 == 0 }
println(listOfEvenNumbers)
@pauloaapereira
pauloaapereira / declarative_1.kt
Created May 22, 2021 16:04
Declarative UI Analysis
val listOfNumbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val listOfEvenNumbers = mutableListOf<Int>()
for (number in listOfNumbers) {
if (number % 2 == 0) {
listOfEvenNumbers.add(number)
}
}
println(listOfEvenNumbers)
@pauloaapereira
pauloaapereira / solid_6.kt
Created May 16, 2021 16:24
Android SOLID Error Handling
class ErrorFragment : Fragment() {
private var _binding: FragmentErrorBinding? = null
private val binding get() = _binding!!
companion object {
private const val ERROR_KEY = "errorKey"
fun newError(error: ErrorView): ErrorFragment {
return ErrorFragment().apply {
@pauloaapereira
pauloaapereira / solid_5.kt
Created May 16, 2021 16:21
Android SOLID Error Handling
@Parcelize
class ServerError : ErrorView {
override fun setupView(binding: FragmentErrorBinding) {
binding.apply {
errorTitle.setText(R.string.key_error)
errorDescription.setText(R.string.key_server_error)
errorImage.setImageResource(R.drawable.ic_server)
}
}
@pauloaapereira
pauloaapereira / solid_4.kt
Last active May 16, 2021 16:34
Android SOLID Error Handling
@Parcelize
class InternetError(private val showWarning: Boolean) : ErrorViewWithWarning {
@IgnoredOnParcel
override var warning: Snackbar? = null
override fun setupView(binding: FragmentErrorBinding) {
binding.apply {
errorTitle.setText(R.string.key_error)
errorDescription.setText(R.string.key_internet_error)
@pauloaapereira
pauloaapereira / solid_3.kt
Created May 16, 2021 16:18
Android SOLID Error Handling
@Parcelize
class NotFoundError : ErrorView {
override fun setupView(binding: FragmentErrorBinding) {
binding.apply {
errorTitle.setText(R.string.key_error)
errorDescription.setText(R.string.key_not_found_error)
errorImage.setImageResource(R.drawable.ic_not_found)
}
}
}
@pauloaapereira
pauloaapereira / solid_2.kt
Created May 16, 2021 16:06
Android SOLID Error Handling
interface ErrorViewWithWarning : ErrorView {
var warning: Snackbar?
fun showWarning(root: View)
fun dismissWarning()
}
@pauloaapereira
pauloaapereira / solid_1.kt
Created May 16, 2021 16:00
Android SOLID Error Handling
interface ErrorView : Parcelable {
fun setupView(binding: FragmentErrorBinding)
}