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 / SingleLineLinearLayout.kt
Created June 3, 2020 12:52
SingleLineLinearLayout
/**
* Class describing a SingleLineLinearLayout
*/
open class SingleLineLinearLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
var isChildRemoving = false
@sbelloz
sbelloz / SuggestionSearchView.java
Last active February 19, 2020 12:12
Suggestion search view collapsable
/**
* @author Simone Bellotti
*/
public class SuggestionSearchView extends LinearLayout {
private static final String TAG = "SuggestionSearchView";
private static final double COS_45 = Math.cos(Math.toRadians(45));
private static final boolean DEFAULT_ENABLED_BACK = true;
private static final boolean DEFAULT_WAIT_KEYBOARD_FOR_COLLAPSE = true;
@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
*
*/
@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 / 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 / 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 / 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 / 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 / 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 / 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;