Skip to content

Instantly share code, notes, and snippets.

@MensObscura
MensObscura / DividerItemDecoration
Last active April 6, 2016 09:36 — forked from Jogan/DividerItemDecoration
DIviderItemDecoration updated without deprecation
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@MensObscura
MensObscura / AutoResizeTextView
Created March 18, 2016 07:39
AutoResize font size TextView
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.RectF;
import android.os.Build;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.SparseIntArray;
@MensObscura
MensObscura / CustomChooserIntent.java
Created March 31, 2016 12:21 — forked from Nutomic/CustomChooserIntent.java
Create Intent Chooser with Application Whitelist. Based on https://gist.github.com/mediavrog/5625602
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Parcelable;
import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@MensObscura
MensObscura / ExponentView
Last active April 6, 2016 09:09
to diplay some price with " ppD°° " 'pp' are the price in integer and 'D' the type of money like "€", and '°°' the decimals
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
@MensObscura
MensObscura / TextInputLayoutWithError
Last active April 6, 2016 09:34
TextInputLayout with red state
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.support.design.widget.TextInputLayout;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.EditText;
public class TextInputLayoutWithError extends TextInputLayout {
@MensObscura
MensObscura / Scrolling Header
Last active June 1, 2016 08:41
Scrolling Header with menu and Image background and text content
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
public static class BlurTransformation implements com.squareup.picasso.Transformation {
private final float radius;
private Context mContext;
// radius is corner radii in dp
public BlurTransformation(final float radius, Context context) {
this.radius = radius;
this.mContext = context;
}
public void movedListener() {
if (mImageFloating != null) {
final GestureDetector gestureDetector = new GestureDetector(getActivity(), new SingleTapConfirm());
final float maxWidth = UIUtils.getScreenWidthInPx(getContext()) - DisplayMetricsUtils.convertDpToPx(getContext(), 70);
final float maxHeight = UIUtils.getScreenHeightInPx(getContext()) - DisplayMetricsUtils.convertDpToPx(getContext(), 200);
final float minWidth = DisplayMetricsUtils.convertDpToPx(getContext(), 10);
final float minHeight = minWidth;
mImageFloating.setOnTouchListener(new View.OnTouchListener() {
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.ImageView;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.WindowManager;
public class SplashActivity extends Activity {