Skip to content

Instantly share code, notes, and snippets.

Avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
View DividerItemDecoration.java
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 Dec 4, 2014
Class that allows to check number of clicks available on a view
View RetryClickListener.java
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 Dec 10, 2014
Cuustom slidng tabs more material
View SlidingTabLayout.java
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;
View FakeAdapter.java
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) {
View FabCorrections.java
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();
View hores_cats.xml
<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>
View ObservableWebView.java
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) {
View ViewUtils.java
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;
/**
View MoneyUtils.java
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 {
View FontUtils.java
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);
}