Skip to content

Instantly share code, notes, and snippets.

View amilcar-sr's full-sized avatar

Amilcar Serrano amilcar-sr

View GitHub Profile
@amilcar-sr
amilcar-sr / FragmentUtils.java
Last active May 23, 2018 02:17
Utility class that helps with fragment manipulation
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
/**
* Set of methods that help with fragment manipulation.
*/
public class FragmentUtils {
package com.yourpackage.example;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportHeight="512"
android:viewportWidth="512">
<path
android:name="heart_stroke_left_atrium"
android:fillColor="#DF5F4E"
android:pathData="M376.071,56.717c-30.373,0-58.235,11.765-80.042,31.349c-0.476,1.087-1.03,2.152-1.707,3.175 l-34.157,51.588l34.157,51.589c4.631,6.993,4.632,16.08,0.001,23.073l-34.158,51.592l34.157,51.59 c4.631,6.993,4.632,16.079,0.001,23.072l-34.159,51.6l30.23,45.663c67.125-38.55,212.202-134.676,212.202-245.395 C502.596,118.903,445.949,56.717,376.071,56.717z"
<?xml version="1.0" encoding="utf-8"?>
<!--vector_heart.xml-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportHeight="32"
android:viewportWidth="32">
<path
android:fillColor="#C00000"
android:pathData="M20.5,9.5
@amilcar-sr
amilcar-sr / ConnectionReceiver.java
Last active May 23, 2016 23:20
BroadcastReceiver implementation to make your android app aware of internet connection changes.
//****************************** Class ******************************
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
* BroadcastReceiver that listens for internet connection changes and notifies these changes
* to the subscribers for ConnectionRestoredEvent and ConnectionLostEvent.
@amilcar-sr
amilcar-sr / ColorUtils.java
Last active December 1, 2022 16:18
ColorUtils class containing method to parse hexadecimal colors to int and method that determines whether a color is dark or light.
//------------------------------- Class -------------------------------------------
import android.graphics.Color;
import android.support.annotation.NonNull;
public class ColorUtils {
/**
* Luma Coefficients
*
* @see <a href="https://en.wikipedia.org/wiki/Luma_(video)</a> for further information about these values
@amilcar-sr
amilcar-sr / CallValidation.java
Last active June 10, 2021 19:34
Solution to avoid ActivityNotFoundException when attempting to start an activity with ACTION_DIAL. This problem is common in tablets with no call capabilities.
/**
* Method that checks whether the device has apps installed that can handle the Intents or not.
* @param intent Intent that will be checked.
* @return true if there are apps that can handle the Intent, false otherwise.
*/
private boolean checkAppsForIntent(Intent intent) {
PackageManager packageManager = getActivity().getPackageManager();
return intent.resolveActivity(packageManager) != null;
}
@amilcar-sr
amilcar-sr / dotted_line.xml
Last active October 21, 2019 00:34
dotted_line
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#000000"
android:dashWidth="1dp"
android:dashGap="4dp"
android:width="1dp"/>
</shape>
@amilcar-sr
amilcar-sr / 0_reuse_code.js
Created May 21, 2014 22:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@amilcar-sr
amilcar-sr / 0_reuse_code.js
Created May 13, 2014 16:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console