View WeatherItemAdapter.kt
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 WeatherItemAdapter : | |
ListAdapter<Weather, WeatherItemAdapter.WeatherItemViewHolder>(DiffCallback) { | |
// Other implementation for DiffCallback | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WeatherItemViewHolder { | |
when (viewType) { | |
WeatherViewType.DAY.ordinal -> { | |
val view = LayoutInflater.from(parent.context).inflate(R.layout.weather_day_item, parent, false) | |
return WeatherDayItemViewHolder(view) |
View OrderDao.kt
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
@Dao | |
interface OrderDao { | |
//Get an order along with its line items by orderId | |
@Transaction | |
@Query("SELECT * FROM orders WHERE orderId = :id") | |
fun getById(id: String): Flow<OrderWithLineItems> | |
//Get an order by its status | |
@Transaction | |
@Query("SELECT * FROM orders WHERE status = :status LIMIT 1 ") |
View LineItemDao.kt
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
@Dao | |
interface LineItemDao { | |
//Get all line item in along with its product | |
@Transaction | |
@Query("SELECT * FROM line_items ") | |
fun getAll(): Flow<List<LineItemAndProduct>> | |
//Get line item in an order by orderId | |
@Transaction | |
@Query("SELECT * FROM line_items WHERE orderId = :orderId") |
View OrderWithLineItem.kt
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 OrderWithLineItems( | |
@Embedded var order: Order, | |
@Relation( | |
parentColumn = "orderId", | |
entityColumn = "orderId", | |
entity = LineItem::class | |
) | |
val lineItemList: MutableList<LineItemAndProduct> | |
) |
View LineItemAndProduct.kt
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 LineItemAndProduct( | |
@Embedded val lineItem: LineItem?, | |
@Relation( | |
parentColumn = "productId", | |
entityColumn = "productId", | |
entity = Product::class | |
) | |
val product: Product? | |
) |
View order.kt
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
@Entity(tableName = "orders") | |
data class Order( | |
@PrimaryKey | |
@ColumnInfo(name = "orderId") | |
val id: String, | |
@ColumnInfo(name = "status") | |
var status: String, | |
@ColumnInfo(name = "address") |
View LineItem.kt
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
@Entity(tableName = "line_items") | |
data class LineItem( | |
@PrimaryKey(autoGenerate = true) | |
@ColumnInfo(name = "lineItemId") | |
val id: Long, | |
@ColumnInfo(name = "productId") | |
val productId: String, | |
@ColumnInfo(name = "orderId") |
View product.kt
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
@Entity(tableName = "products") | |
data class Product( | |
@PrimaryKey | |
@NonNull | |
@ColumnInfo(name = "productId") | |
val id: String, | |
@ColumnInfo(name = "name") | |
var name: String?, | |
View FluentBindingAdapterMvxRecyclerView.cs
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 class PersonItemAdapter : MvxRecyclerAdapter | |
{ | |
public PersonItemAdapter(IMvxAndroidBindingContext bindingContext) | |
: base(bindingContext) | |
{ | |
} | |
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) | |
{ | |
var itemBindingContext = new MvxAndroidBindingContext(parent.Context, BindingContext.LayoutInflaterHolder); |
View CountTripletsSolution.kt
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
// Complete the countTriplets function below. | |
fun countTriplets(arr: Array<Long>, r: Long): Long { | |
var befMap = HashMap<Long, Int>() | |
var aftMap = HashMap<Long, Int>() | |
for(num in arr) { | |
if(aftMap.containsKey(num)) aftMap[num] = aftMap[num]!! + 1 | |
else aftMap[num] = 1 | |
} | |
NewerOlder