Skip to content

Instantly share code, notes, and snippets.

View sbelloz's full-sized avatar
💻
Focusing

Simone Bellotti sbelloz

💻
Focusing
View GitHub Profile
@sbelloz
sbelloz / ResizeAnimation.java
Created July 28, 2014 09:37
A class that produce an animation when resizing a view
public class ResizeAnimation extends Animation {
// final int startWidth;
final int startHeight;
final int targetHeight;
// final int targetWidth;
View view;
public ResizeAnimation(View view, int targetWidth) {
this.view = view;
// this.targetWidth = targetWidth;
@sbelloz
sbelloz / CypherUtils.java
Last active August 29, 2015 14:04
Encryption and Decryption in Android
package it.bellotti.java.crypto;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.spec.KeySpec;
@sbelloz
sbelloz / Validator.java
Created August 11, 2014 10:09
a class that uses static methods for validate forms
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by SimoneBellotti on 30/04/14.
*/
public class Validator {
private static Pattern pattern;
private static Matcher matcher;
@sbelloz
sbelloz / ToastUtils.java
Last active August 29, 2015 14:06
Util class that shows a toast message
import android.app.Activity;
import android.widget.Toast;
/**
* Created with IntelliJ IDEA.
* User: SimoneBellotti
* Date: 23/12/2014
* Time: 17.26
*/
@sbelloz
sbelloz / GooglePlusAdapter.java
Created January 9, 2015 15:35
Google+ Listview Animation
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import it.tgs.wow.light.R;
/**
@sbelloz
sbelloz / MemoryUtils.java
Created November 2, 2015 02:49
Util class for check available free space in internal/external memory
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import java.io.File;
public class MemoryUtils {
public final static int MIN_SIZE_MB = 100;
@sbelloz
sbelloz / MPermissionsUtil.java
Last active February 29, 2016 10:14
Util class for request and check Android M permissions
package it.immobiliare.getrix.utils;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;
/**
@sbelloz
sbelloz / CollectionUtils.java
Created April 20, 2016 11:16 — forked from mmarcon/CollectionUtils.java
Maps are not Parcelable and this is an issue in Android when they need to be passed to activities and services via Intents. The corresponding Map-like object in Android is the Bundle. Bundle is a more generic container, it doesn't enforce types via generics and isn't supported natively by JSON deserializers such as Gson. This utility class expos…
package es.cloudey.pagespeed.util;
import java.util.HashMap;
import java.util.Map;
import android.os.Bundle;
import android.os.Parcelable;
public class CollectionUtils {
public static Bundle toBundle(Map<String, ? extends Parcelable> input) {
@sbelloz
sbelloz / TextStyler.java
Created October 20, 2016 15:11
Utils class for styling text in Android
/**
* @author Simone Bellotti
*/
public class TextStyler {
/**
* Returns a CharSequence that concatenates the specified array of CharSequence
* objects and then applies a list of zero or more tags to the entire range.
*
* @param content an array of character sequences to apply a style to
@sbelloz
sbelloz / ViewStubExt.java
Last active September 3, 2021 16:21
Deflate the lazy view previously inflated, and reinflate a new ViewStub
public class ViewStubExt {
/**
* Deflates the view inflated by {@link ViewStub#inflate()}
* and replace it with a new {@link ViewStub} in its parent.
*
* @param view the view lazily inflated previously
* @return the new ViewStub with backed parameters
*
*/