Skip to content

Instantly share code, notes, and snippets.

View thebestpol's full-sized avatar

Pol Gómez Guerrero thebestpol

  • Barcelona
View GitHub Profile
@thebestpol
thebestpol / AlarmService.java
Last active April 13, 2016 16:34
One way to capture Application lifecycle using a custom implementation of RxBus and using an Android Service
/**
* Alarm service subscriber to life cycle events,
*/
public class AlarmService extends Service {
@Inject
RxBus rxBus;
@Inject
LifeCycleController lifeCycleController;
@thebestpol
thebestpol / Countdown.java
Created March 22, 2016 10:53
Custom widget to show a countdown in a TextView
import android.widget.TextView;
public class Countdown implements Runnable {
private final TextView mView;
private final int mStartValue;
private final int mEndValue;
private final long mInterval;
private final int mDecrement;
private CountdownEndListener mListener;
@thebestpol
thebestpol / README
Created March 22, 2016 10:40
Icon tools: scripts to add a badge in the icon of an application. It's a good way to identify different types of builds, releases, etc to make easier the delivery to the client, testing, etc ASKME for the badges in .pdf format
HOW TO USE:
Parameters:
inputfile -- path to original file with extension
budget -- [debug, test, pilot, rc, rcg]
dimension -- dimension in number for generate output file
platform -- [ios, android]
outputfile -- path to outpuf file with extension
Example:
@thebestpol
thebestpol / source_code_packaging.sh
Created March 22, 2016 10:29
Script to make source code packaging easily
#!/bin/bash
# File: source_code_packaging.sh
# Script to generate the source code packaged for the client.
date=`date "+%Y_%m_%d"`;
commit=`git log -n 1 HEAD --format=%h`;
zip -9 -r "${date}_Android_source_code_${commit}.zip" \
.gradle/ \
.idea/ \
build.gradle \
@thebestpol
thebestpol / Log.java
Created March 22, 2016 10:13
Class to print logs friendly
/**
* Class to print logs friendly
*/
public class Log {
/**
* @return the current thread name and id
*/
public static String getThreadName() {
String name = Thread.currentThread().getName() + "(" + Thread.currentThread().getId() + ")";
@thebestpol
thebestpol / KeyInterceptEditText.java
Last active March 22, 2016 10:19
Custom widget, EditText, that intercepts key press events on the IME and calls the method. Provides a function to handle on hide soft input keyboard event.
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;
/**
* This EditText intercepts key press events on the IME and calls the method.
* <p>
* Provides a function to handle on hide soft input keyboard event.
*/
@thebestpol
thebestpol / gifit.sh
Created March 21, 2016 14:28
Pass it a mp4 and you will have a gif
# Description: pass it a mp4 and you will have a gif
# Dependencies: ffmpeg, gifsicle
if [ "$#" -le 1 ]; then
echo "\nUsage: sh gifit.sh <source path to original mp4> <delay between frames>"
echo "Warning! filenames shouldn't contain the extension\n"
exit 1
fi
ffmpeg -i $1.mp4 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=$2 > $1.gif
@thebestpol
thebestpol / remove_branches
Created March 21, 2016 14:23
Delete locally already merged branches on develop
$ git checkout develop
$ git branch --merged | grep -v "*" | grep -v -e "[develop|master]" | xargs -n 1 git branch -d
@thebestpol
thebestpol / rotate.xml
Created March 18, 2016 11:00
Simple rotate animation
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />
@thebestpol
thebestpol / shake.xml
Created March 18, 2016 10:59
Simple accelerated shake animation
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="50"
android:fromXDelta="-5"
android:interpolator="@android:anim/accelerate_interpolator"
android:repeatCount="5"
android:repeatMode="reverse"
android:toXDelta="5" />