Skip to content

Instantly share code, notes, and snippets.

View alorma's full-sized avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.Canvas;
@alorma
alorma / RetryClickListener.java
Created December 4, 2014 16:24
Class that allows to check number of clicks available on a view
public class RetryClickListener implements View.OnClickListener {
private int maxRetries;
private int current = 0;
private OnRetryClickListener onRetryClickListener;
public RetryClickListener(int maxRetries, OnRetryClickListener onRetryClickListener) {
this.maxRetries = maxRetries;
this.onRetryClickListener = onRetryClickListener;
}
@alorma
alorma / SlidingTabLayout.java
Created December 10, 2014 18:22
Cuustom slidng tabs more material
package com.alorma.github.ui.view;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.TypedValue;
private class FakeAdapter extends RecyclerView.Adapter<FakeAdapter.VH> {
private final LayoutInflater inflater;
public FakeAdapter(Context context) {
this.inflater = LayoutInflater.from(context);
}
@Override
public VH onCreateViewHolder(ViewGroup parent, int viewType) {
public void setIconDrawable(@NonNull Drawable iconDrawable) {
if (mIconDrawable != iconDrawable) {
mIcon = 0;
Bitmap bitmap = Bitmap.createBitmap(iconDrawable.getIntrinsicWidth(), iconDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
iconDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
iconDrawable.draw(canvas);
mIconDrawable = new BitmapDrawable(getResources(), bitmap);
updateBackground();
<resources>
<string name="app_name">WearFace</string>
<string name="hour_00">DOTZE</string>
<string name="hour_01">UNA</string>
<string name="hour_02">DUES</string>
<string name="hour_03">TRES</string>
<string name="hour_04">QUATRE</string>
<string name="hour_05">CINC</string>
<string name="hour_06">SIS</string>
<string name="hour_07">SET</string>
public class FontUtils {
public static void wrap(TextView textView) {
if (textView != null) {
try {
String fontName = FontUtils.fontName(textView);
if (fontName != null) {
Typeface typeface = Typeface.createFromAsset(textView.getContext().getAssets(), "fonts/" + fontName);
textView.setTypeface(typeface);
}
public class ObservableWebView extends WebView {
public ObservableWebView(Context context) {
this(context, null);
}
public ObservableWebView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ObservableWebView(Context context, AttributeSet attrs, int defStyle) {
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.IntEvaluator;
import com.nineoldandroids.animation.ObjectAnimator;
import com.nineoldandroids.animation.ValueAnimator;
/**
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.RelativeSizeSpan;
import android.text.style.SuperscriptSpan;
/**
* Created by a557114 on 02/02/2015.
*/
public class MoneyUtils {