Skip to content

Instantly share code, notes, and snippets.

Oscar Gallon oscarg798

View GitHub Profile
@oscarg798
oscarg798 / Distribute with Firebase and Fastlane
Last active May 28, 2020
FastFile_for_Firebase_Distribution
View Distribute with Firebase and Fastlane
fastlane_version "2.68.0"
default_platform :android
platform :android do
lane :firebase do
build_android_app(task: "assembleDebug")
firebase_app_distribution(
View ProductAdapter_onBindViewHolder.kt
override fun onBindViewHolder(
holder: ProductViewHolder,
position: Int,
payloads: MutableList
) {
if (payloads.isEmpty()) {
onBindViewHolder(holder, position)
} else {
for (data in payloads) {
when (data as Int) {
View ProductAdapter.kt
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)
)
}
View ProductDiffUtilCallback_getChangePayload.kt
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
}
View ViewProduct.kt
data class ViewProduct(
val id: String,
val name: String,
val description: String,
val quantity: Int
)
View ProductDiffUtilCallback.kt
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
View Corutine Example
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")
View feature.gradle
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'
View common.gradle
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"
@oscarg798
oscarg798 / travis.yml
Created Feb 20, 2019
Travis Android unit tests config file
View travis.yml
language: android
jdk: oraclejdk8
branches:
only:
- develop #or the branch you want to observe
notifications:
slack: #your_slack_id
You can’t perform that action at this time.