Skip to content

Instantly share code, notes, and snippets.

View oscarcidcoder's full-sized avatar

Oscar Cid oscarcidcoder

View GitHub Profile
// https://medium.com/swlh/kotlin-sealed-class-for-success-and-error-handling-d3054bef0d4e
// https://medium.com/androiddevelopers/sealed-with-a-class-a906f28ab7b5
sealed class ResultOf<out T: Any> {
data class Success<out T: Any>(val value: T): ResultOf<T>()
data class Error(
val message: String?,
val throwable: Throwable?
): ResultOf<Nothing>()
object InProgress : ResultOf<Nothing>()
@oscarcidcoder
oscarcidcoder / FabBottomNavigationView.kt
Created August 12, 2019 13:16
FabBottomNavigationView Widget custom para el manejo del BottomNavigationBar con un FAB integrado con el mismo estilo de BottomApp Bar
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Paint
import android.util.AttributeSet
import androidx.core.animation.doOnEnd
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.floatingactionbutton.FloatingActionButton
@oscarcidcoder
oscarcidcoder / app.gradle
Created July 15, 2019 13:57
Gradle General con Signing
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
import groovy.swing.SwingBuilder
def keyPropertiesFile = rootProject.file("key.properties");
if (keyPropertiesFile == null || !keyPropertiesFile.exists()) {
throw new GradleException("key.properties file is missing that contains Pilgrim Keys.");
}
def keyProperties = new Properties();
@oscarcidcoder
oscarcidcoder / FontAwesomeIcon.java
Created April 17, 2019 13:41
Class to support TextView with FontAwesome
/**
* Clase para cargar los iconos de FontAwesome v4.7.0
* Usar {@link FontAwesomeIcon#setCodeText(String)} para hacer el set del texto en el codigo
* @author oscarcid
*/
public class FontAwesomeIcon extends AppCompatTextView {
int c1,c2,c3;
Shader shader;
@oscarcidcoder
oscarcidcoder / README.md
Last active November 14, 2018 16:11
Connection Changes Android

⚠️ Manifest

  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

⚠️ API < 24

public BroadcastReceiver connectionReceiver = new BroadcastReceiver() {
  
    @Override
    public void onReceive(Context context, Intent intent) {