Skip to content

Instantly share code, notes, and snippets.

View webserveis's full-sized avatar

Webserveis webserveis

View GitHub Profile
@webserveis
webserveis / RVEmptyObserver.java
Last active February 1, 2021 18:02 — forked from sheharyarn/RVEmptyObserver.java
Set Empty Layout for RecyclerViews in Android
/**
* https://stackoverflow.com/questions/28217436/how-to-show-an-empty-view-with-a-recyclerview
*
* Custom implementation of AdapterDataObserver to show empty layouts
* for RecyclerView when there's no data
*
* Usage:
*
* adapter.registerAdapterDataObserver(new RVEmptyObserver(recyclerView, emptyView));
*/
@webserveis
webserveis / MainActivity.kt
Created October 12, 2020 18:19
StateLayout mostrar diferentes vistas en Android Kotlin
package com.webserveis.app.testapp
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.DrawableRes
import androidx.appcompat.app.AppCompatActivity
@webserveis
webserveis / KIntent.kt
Created August 14, 2020 13:40 — forked from passsy/KIntent.kt
Kotlin extension functions to start a generic Activity
package com.pascalwelsch.extensions
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
/**
* Extensions for simpler launching of Activities
@webserveis
webserveis / areadmer.md
Last active June 9, 2020 15:08
Week Day Selector

Crear un selector de dias, de forma circular

Añadir en ele directorio drawable weekday_selector_text.xml y weekday_selector_bg.xml

En styles.xml definir el estilo

<style name="WeekDaySelector" parent="AppTheme.DayNight">
    <item name="android:textColor">@drawable/weekday_selector_text</item>
 @drawable/weekday_selector_bg
@webserveis
webserveis / RevelaCicleView.kt
Created May 12, 2020 09:54
RevelCicleView reveal effect for show view
package com.webserveis.testbannerview
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.content.Context
import android.os.Handler
import android.os.Parcel
import android.os.Parcelable
import android.util.AttributeSet
import android.util.Log
@webserveis
webserveis / JaroWinklerScore.java
Last active February 8, 2022 10:50
String similary algoritms
public class JaroWinklerScore {
/**
* Applies the Jaro-Winkler distance algorithm to the given strings, providing information about the
* similarity of them.
*
* @param s1 The first string that gets compared. May be <code>null</node> or empty.
* @param s2 The second string that gets compared. May be <code>null</node> or empty.
* @return The Jaro-Winkler score (between 0.0 and 1.0), with a higher value indicating larger similarity.
*
* @author Thomas Trojer <thomas@trojer.net>
@webserveis
webserveis / UseCase.kt
Created April 22, 2020 15:33 — forked from DenysZP/UseCase.kt
The implementation of the base UseCase with kotlin coroutines.
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
abstract class UseCase<T, Params : Any> {
private lateinit var parentJob: Job
private lateinit var params: Params
private var isAttachedToLifecycle = false
private val backgroundContext: CoroutineContext = Dispatchers.IO
private val foregroundContext: CoroutineContext = Dispatchers.Main
@webserveis
webserveis / readme.md
Last active April 15, 2020 20:29
Storage Acces Android Kotlin

Abrir selector de archivos

private val PICK_FILE_REQUEST_CODE = 0x100
...
fun openFilePicker() {
   val intent = Intent(Intent.ACTION_GET_CONTENT)
   intent.type = "*/*"
   //intent.type = "text/plain"
   //intent.type = "text/html"
@webserveis
webserveis / PassCodeDotsIndicator.kt
Created April 15, 2020 11:23
Component PassCodeDotsIndicator
class PassCodeDotsIndicator @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
annotation class IndicatorType {
@IntDef(FIXED, FILL, FILL_WITH_ANIMATION)
@Retention(AnnotationRetention.SOURCE)
annotation class override
@webserveis
webserveis / BluetoothHelper.kt
Last active June 23, 2020 08:29
Bluetooth Helper implement bluetooth in your Android app
package com.webserveis.mqtthomepresence.helpers
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.util.Log