Skip to content

Instantly share code, notes, and snippets.

View gavelez's full-sized avatar

Giovanny Velez gavelez

View GitHub Profile
@gavelez
gavelez / RxJava.md
Created August 20, 2017 02:19 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@gavelez
gavelez / RandomCreditCardNumberGenerator.java
Created June 10, 2019 03:35
Credit Card Number Generator
import java.util.List;
import java.util.Stack;
import java.util.Vector;
/**
* See the license below. Obviously, this is not a Javascript credit card number
* generator. However, The following class is a port of a Javascript credit card
* number generator.
*
* @author robweber
@gavelez
gavelez / CollectionWrapper.kt
Last active November 28, 2019 18:13
Use of Generics with Gson
package com.example.util
import com.example.MyList
class CollectionWrapper<T> {
var type: Class<T>
var list: MyList<T>
constructor(valueType: Class<T>, list: MyList<T>) {
@gavelez
gavelez / AndroidManifest.xml
Last active December 23, 2019 20:08
ExoPlayer multiformat playing
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@gavelez
gavelez / AndroidManifest.xml
Created April 20, 2020 16:10
How to detect call state Android
<receiver android:name=".CallReceiver" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
package com.example.monpfe
import android.app.ProgressDialog
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.widget.Button
import android.widget.EditText
@gavelez
gavelez / PR_Template.md
Last active August 14, 2020 17:39
PR Template
@gavelez
gavelez / PlayingWithPaths.kt
Created September 2, 2020 23:49 — forked from alexjlockwood/PlayingWithPaths.kt
Implementation of a 'Playing with Paths' polygon animation
package com.alexjlockwood.playingwithpaths
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.animation.animatedFloat
import androidx.compose.animation.core.AnimationConstants
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.repeatable
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
@gavelez
gavelez / RV.java
Created October 15, 2020 18:21
Scroll Multiple RecyclerViews
recyclerView.addOnScrollListener(
new RecyclerView.OnScrollListener() {
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (isLastItemDisplaying(recyclerView)) {
//Calling the method getdata again getData();
}
}
}
);
@gavelez
gavelez / FragmentCheck.java
Created October 29, 2020 14:32
Validate if a Fragment is active
public static boolean isSafeFragment( Fragment frag )
{
return !(frag.isRemoving() || frag.getActivity() == null || frag.isDetached() || !frag.isAdded() || frag.getView() == null );
}