Skip to content

Instantly share code, notes, and snippets.

Avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
View FabricEventDsl.kt
import com.crashlytics.android.answers.*
import io.fabric.sdk.android.Fabric
import java.math.BigDecimal
import java.util.*
@DslMarker
annotation class FabricEventDsl
@FabricEventDsl
class CustomAttribute {
View DialogDsl.kt
import android.content.Context
import android.content.DialogInterface
import android.support.annotation.LayoutRes
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import android.view.View
import com.alorma.R
@DslMarker
View PermissionDsl.kt
import com.karumi.dexter.DexterBuilder
import com.karumi.dexter.PermissionToken
import com.karumi.dexter.listener.PermissionDeniedResponse
import com.karumi.dexter.listener.PermissionGrantedResponse
import com.karumi.dexter.listener.PermissionRequest
import com.karumi.dexter.listener.single.PermissionListener
@DslMarker
annotation class PermissionDsl
View RecyclerViewAdapterExt.kt
inline fun <reified T: View> T.asRecyclerViewCell(): T {
layoutParams = RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
return this
}
View RecyclerViewDividerExtension.kt
fun RecyclerView.divider(orientation: Int = DividerItemDecoration.VERTICAL,
@DrawableRes drawable : Int = R.drawable.list_divider) {
val itemDecoration = DividerItemDecoration(context, orientation).apply {
ContextCompat.getDrawable(context, drawable)?.let {
setDrawable(it)
}
}
addItemDecoration(itemDecoration)
}
View GenericSwipeCallback.kt
import android.graphics.Canvas
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.helper.ItemTouchHelper
import android.support.v7.widget.helper.ItemTouchHelper.*
import android.view.View
import com.stronix.lio.ui.features.broadcasts.BroadcastsSwipeCallback
abstract class GenericSwipeCallback(
private var swipeLeft: SwipeAction? = null,
View ResourceProvider.kt
class ResourcesProvider @Inject constructor(private val context: Context) {
fun getPlural(@PluralsRes plural: Int, number: Int, formatted: String): String
= context.resources.getQuantityString(plural, number, formatted)
fun getString(@StringRes stringId: Int): String
= context.resources.getString(stringId)
}
View pre-push
#!/bin/sh
./gradlew clean testDebug
View empty_pre_push.sh
#!/bin/sh
# Your code belongs here