Skip to content

Instantly share code, notes, and snippets.

Avatar

Gerard Coll webserveis

View GitHub Profile
@webserveis
webserveis / MainActivity.kt
Last active Apr 28, 2022
ActionMode Primary Android Kotlin
View MainActivity.kt
package com.example.testmenu
import android.os.Bundle
import android.view.ActionMode
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
View YoutubeUtils.kt
import android.util.Patterns
import java.util.regex.Pattern
object YoutubeUtils {
private fun extractYoutubeId(url: String): String? {
val pattern = "([/|?|&]vi?[/|=]|youtu.be/|embed/)([a-zA-Z0-9_-]+)".toRegex()
return pattern.find(url)?.groupValues?.last()
@webserveis
webserveis / ClickManager.kt
Last active Apr 30, 2021
Computar clicks para publicidad Admob
View ClickManager.kt
class ClickManager(
private val sp: SharedPreferences,
private val triggerTask: (Int) -> Unit,
private val triggerClick: Int = TRIGGER_CLICK,
private val uid: String? = null
) {
companion object {
private const val KEY_CLICKS_COUNT = "clicks_count"
private val TRIGGER_CLICK = 5
}
View RadioGridGroupLayout.kt
package com.webserveis.app.testradiogridlayout
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.CompoundButton
import androidx.appcompat.widget.AppCompatRadioButton
@webserveis
webserveis / KIntent.kt
Created Feb 12, 2021 — forked from wajahatkarim3/KIntent.kt
Kotlin extension functions to start a generic Activity
View KIntent.kt
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 / RVEmptyObserver.java
Last active Feb 1, 2021 — forked from sheharyarn/RVEmptyObserver.java
Set Empty Layout for RecyclerViews in Android
View RVEmptyObserver.java
/**
* 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 Oct 12, 2020
StateLayout mostrar diferentes vistas en Android Kotlin
View MainActivity.kt
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 Aug 14, 2020 — forked from passsy/KIntent.kt
Kotlin extension functions to start a generic Activity
View KIntent.kt
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 Jun 9, 2020
Week Day Selector
View areadmer.md

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
RevelCicleView reveal effect for show view
View RevelaCicleView.kt
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