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
android { | |
... | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
kotlinOptions { | |
jvmTarget = "1.8" | |
} | |
} |
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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
Text(text = "Hello, World") | |
} | |
} | |
} |
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
data class CoffeeDrink( | |
val name: String, | |
@DrawableRes val imageUrl: Int, | |
val description: String, | |
val ingredients: String | |
) |
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
fun getCoffeeDrinks(): List<CoffeeDrink> { | |
return listOf( | |
CoffeeDrink( | |
name = "Americano", | |
imageUrl = R.drawable.americano_small, | |
ingredients = "Espresso, Water" | |
), | |
CoffeeDrink( | |
name = "Cappuccino", | |
imageUrl = R.drawable.cappuccino_small, |
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
@Composable | |
fun CoffeeDrinkCard( | |
coffeeDrink: CoffeeDrinkModel | |
) { | |
Row { | |
Container(modifier = LayoutSize(80.dp), alignment = Alignment.Center) { | |
DrawImage(image = imageResource(coffeeDrink.imageUrl)) | |
} | |
Container( | |
alignment = Alignment.TopLeft, |
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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
CoffeeDrinksList(coffeeDrinks) | |
} | |
} | |
@Composable | |
fun CoffeeDrinkList( | |
coffeeDrinks: List<CoffeeDrink> |
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
@Composable | |
fun CoffeeDrinkCard( | |
coffeeDrink: CoffeeDrinkModel | |
) { | |
MaterialTheme { | |
Column { | |
Row { | |
CoffeeDrinkLogo(id = coffeeDrink.imageUrl) | |
Container(alignment = Alignment.TopLeft,modifier = LayoutFlexible(1f)) { | |
Column { |
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
package com.alexzh.recyclerviewsetemptyview; | |
import android.content.Context; | |
import android.support.annotation.Nullable; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; | |
public class EmptyRecyclerView extends RecyclerView { | |
private View mEmptyView; |
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
data class Restaurant( | |
val id: Long, | |
val name: String, | |
val openTime: Date, | |
val closeTime: Date | |
) { | |
private val deliveryTimeStep: Long = 15 * 60 * 1000 | |
fun getDeliveryTimeOptions(): DeliveryTimeOptions { | |
return openTime..closeTime step deliveryTimeStep |
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
package com.alexzh.composeplayground | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.size | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.tooling.preview.Preview | |
import androidx.compose.ui.unit.dp |