Skip to content

Instantly share code, notes, and snippets.

View oscarg798's full-sized avatar
👨‍💻

Oscar Gallon oscarg798

👨‍💻
View GitHub Profile
@oscarg798
oscarg798 / travis.yml
Created February 20, 2019 15:21
Travis Android unit tests config file
language: android
jdk: oraclejdk8
branches:
only:
- develop #or the branch you want to observe
notifications:
slack: #your_slack_id
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
apply from: "$rootProject.projectDir/common.gradle"
dependencies {
def acceptanceTesting = rootProject.ext.acceptanceTesting
testImplementation project(path: ':core')
androidTestImplementation 'net.rafaeltoledo.okir:library:0.0.1@aar'
val m : (Int, Int) -> Unit = {x, y ->
print("::::$x $y")
}
CoroutineScope(Dispatchers.Default).launch {
print("Corutine 1 $this\n")
val mm = this
withContext(Dispatchers.IO) {
print("Corutine 2 $this\n")
class ProductDiffUtilCallback(
private val oldProducts: List<ViewProduct>,
private val newProducts: List<ViewProduct>
) : DiffUtil.Callback() {
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
oldProducts[oldItemPosition].id == newProducts[newItemPosition].id
override fun getOldListSize(): Int = oldProducts.size
data class ViewProduct(
val id: String,
val name: String,
val description: String,
val quantity: Int
)
override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? {
val oldItem = oldProducts[oldItemPosition]
val newItem = newProducts[newItemPosition]
if (oldItem.quantityInCart != newItem.quantityInCart) {
return UPDATE_QUANTITY
}
return null
}
class ProductAdapter(
private val products: ArrayList<ViewProduct>
) : RecyclerView.Adapter<ProductViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductViewHolder {
return ProductViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.product_item, parent, false)
)
}
override fun onBindViewHolder(
holder: ProductViewHolder,
position: Int,
payloads: MutableList
) {
if (payloads.isEmpty()) {
onBindViewHolder(holder, position)
} else {
for (data in payloads) {
when (data as Int) {
@oscarg798
oscarg798 / Distribute with Firebase and Fastlane
Last active May 28, 2020 10:44
FastFile_for_Firebase_Distribution
fastlane_version "2.68.0"
default_platform :android
platform :android do
lane :firebase do
build_android_app(task: "assembleDebug")
firebase_app_distribution(