Skip to content

Instantly share code, notes, and snippets.

View alorma's full-sized avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
@gabrielemariotti
gabrielemariotti / README.md
Last active February 24, 2021 10:52
How to manage the support libraries in a multi-module projects. Thanks to Fernando Cejas (http://fernandocejas.com/)

Centralize the support libraries dependencies in gradle

Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.

A very good way is to separate gradle build files, defining something like:

root
  --gradleScript
 ----dependencies.gradle
package com.example.marcin.splitlayout;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Region;
@curioustechizen
curioustechizen / EnhancedCheckBox.java
Last active September 14, 2020 05:50
Android programmatically checkable widgets, differentiate between user clicks & programmatic setChecked calls. Based on this answer on StackOverflow: http://stackoverflow.com/a/14307643/570930. There are times when setting a switch to ON results in some action (Save to DB/ perform an HTTP POST etc). However, you want this action to happen only o…
/**
* An enhanced {@code CheckBox} that differentiates between user clicks and
* programmatic clicks. In particular, the {@code OnCheckedChangeListener} is
* <strong>not</strong> triggered when the state of the checkbox is changed
* programmatically.
*
*/
public class EnhancedCheckBox extends CheckBox implements ProgrammaticallyCheckable{
private CompoundButton.OnCheckedChangeListener mListener = null;
public EnhancedCheckBox(Context context) {
@chris95x8
chris95x8 / UIActivity.java
Created December 13, 2014 22:35
FAB expand
package com.materialdesign.chris.materialdesignexperimenting;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewAnimationUtils;
@rock3r
rock3r / ColorUtils.java
Last active February 25, 2020 09:06
ColorUtils: utilities for manipulating colours
package net.frakbot.util.color;
import android.graphics.Color;
/**
* The MIT License (MIT)
* <p/>
* Copyright (c) 2014 Sebastiano Poggi
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
@twiceyuan
twiceyuan / gist:0c1b7faa6fad2d3cad42
Last active April 23, 2019 14:31 — forked from z8888q/gist:7280681
[如何动态改变 App 图标] #Android How to change an application icon programmatically in Android
//1 . Modify your MainActivity section in AndroidManifest.xml, delete from it, line with MAIN category in intent-//filter section
<activity android:name="ru.quickmessage.pa.MainActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:theme="@style/CustomTheme"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
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;
@aballano
aballano / ThenRx.kt
Created November 16, 2018 09:09
Mockito & RxJava extensions to facilitate mocking
@JvmName("thenErrorObservable")
fun <T> OngoingStubbing<Observable<T>>.thenError(throwable: Throwable) {
thenReturn(Observable.error(throwable))
}
fun OngoingStubbing<Completable>.thenComplete() {
thenReturn(Completable.complete())
}
@JvmName("thenErrorCompletable")
STORE_FILE=/path/to/your.keystore
STORE_PASSWORD=yourkeystorepass
KEY_ALIAS=projectkeyalias
KEY_PASSWORD=keyaliaspassword
@rocboronat
rocboronat / DarkOrLightColour.java
Last active June 30, 2018 19:04
Know if a text on a dynamic background colour must be black or white to be easy to read
int color = palette.getVibrantColor(defaultColor);
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 0) & 0xFF;
row.setBackgroundColor(color);
//@see http://stackoverflow.com/questions/12043187/how-to-check-if-hex-color-is-too-black
double luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;