Skip to content

Instantly share code, notes, and snippets.

View monxalo's full-sized avatar

Gonçalo Ferreira monxalo

  • Waterdog
  • Portugal
View GitHub Profile
import android.view.View
import androidx.recyclerview.widget.RecyclerView
abstract class BindableAdapter<T, VH: BindableAdapter.ViewHolder<T>>: RecyclerView.Adapter<VH>() {
private val items: MutableList<T> = mutableListOf()
open fun changeData(items: List<T>) {
changeData(items, true)
}
@monxalo
monxalo / commit-msg
Last active November 5, 2020 18:48
JIRA issue pre commit hook
#!/bin/sh
COMMIT_FILE=$1
COMMIT_MSG=$(cat $1)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
JIRA_ID=$(echo "$CURRENT_BRANCH" | grep -Eo "[A-Z0-9]{1,10}-?[A-Z0-9]+-\d+")
if [ ! -z "$JIRA_ID" ]; then
echo "[$JIRA_ID] $COMMIT_MSG" > $COMMIT_FILE
echo "JIRA ID '$JIRA_ID' prepended to commit message."
@monxalo
monxalo / HighlightedDrawable.java
Last active October 1, 2020 20:54
A StateListDrawable that automatically adds a pressed state to a drawable, it applies a dark or light filter for this state.
package pt.eco.mobile.android.ui.drawable;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import androidx.annotation.DrawableRes;

Keybase proof

I hereby claim:

  • I am monxalo on github.
  • I am monxalo (https://keybase.io/monxalo) on keybase.
  • I have a public key whose fingerprint is 40F6 2874 1C35 7DAE 317D B562 8151 47DA 3AEC B9B1

To claim this, I am signing this object:

@monxalo
monxalo / CheckableLinearLayout.java
Created November 30, 2014 20:14
CheckableLinearLayout
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.LinearLayout;
public class CheckableLinearLayout extends LinearLayout implements Checkable {
private Drawable mBackgroundCheck;
private boolean mChecked;
@monxalo
monxalo / CircleImageTransformation.java
Last active August 29, 2015 14:06
Circle image mask for Picasso
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Shader;
import com.squareup.picasso.Transformation;
public class CircleImageTransformation implements Transformation {
private int mBorderWidth;