Skip to content

Instantly share code, notes, and snippets.

View dominicthomas's full-sized avatar

Dominic Thomas dominicthomas

View GitHub Profile
@dominicthomas
dominicthomas / multiple_filters_ffmpeg
Created November 12, 2015 14:15
Small snippet of doing multiple filter calls on an ffmpeg command... using the android ffmpeg wrapper
cmd.add("movie=" + imagePath + " [overlay]; " +
"[in] transpose=1 [a]; " +
"[a] scale=360:-1 [b]; " +
"[b] crop=360:360:" + String.valueOf(cropX) + ":" + String.valueOf(cropY) + " [c]; " +
"[c] [overlay] overlay=" + overlayX + ":" + overlayY + " [out]");
@dominicthomas
dominicthomas / getdevelop.sh
Created March 23, 2016 17:52
Useful script to checkout and pull new changes on develop for a repo and all submodules... This will need to be adapted to the environment it is required in.
#/bin/bash
cd $1
if [ -d $1 ]; then
echo "Changing Directory too: " $1
else
echo "Directory does not exist"
exit 1
fi
@dominicthomas
dominicthomas / CompatGlobalLayoutListener.java
Created June 23, 2016 15:10
A useful abstract class that wraps in global layout listener functionality to support older android versions.
public abstract class CompatGlobalLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener {
private final View view;
public CompatGlobalLayoutListener(@NonNull final View view) {
this.view = view;
}
protected abstract void onGlobalLayoutReady();
@dominicthomas
dominicthomas / jackson_guava_optional.txt
Created July 19, 2016 12:29
Jackson Guava Optional<T> Deserialization
Dependencies:
=============================================
compile "com.google.guava:guava:19.0"
compile 'com.fasterxml.jackson.datatype:jackson-datatype-guava:2.7.3'
Deserializer:
=============================================
@dominicthomas
dominicthomas / TextInputOnKeyChangedListener.java
Created September 23, 2016 14:49
Useful to listen to just key up and back key events for a text input or edittext. Turns out it doesn't work on some devices as some send hardware key events and some send soft keyboard events. This doesn't work with soft keyboard events.
public class TextInputOnKeyChangedListener implements EditText.OnKeyListener {
private EditText editText;
private OnKeyChangedListener onKeyChangedListener;
public interface OnKeyChangedListener {
void onKeyUp(String text);
void onBackPressed();
@dominicthomas
dominicthomas / PhoneNumberFormatter.java
Created October 7, 2016 12:43
Simple class to format and convert to E164, mobile phone numbers for the UK and the US.
public class PhoneNumberFormatter {
private final String simCountryIso;
private final Map<String, String> countryCodeMap = Collections.unmodifiableMap(
new HashMap<String, String>() {{
put("GB", "44");
put("US", "1");
}});
@dominicthomas
dominicthomas / PhoneNumberFormatter.java
Last active October 7, 2016 12:45
Simple class to format and convert to E164, mobile phone numbers for the UK and the US. Probably better to just use google libphonenumber.
public class PhoneNumberFormatter {
private final String simCountryIso;
private final Map<String, String> countryCodeMap = Collections.unmodifiableMap(
new HashMap<String, String>() {{
put("GB", "44");
put("US", "1");
}});
@dominicthomas
dominicthomas / adb_iso_country.txt
Created November 3, 2016 14:31
This enables you to change the sim country iso of the android emulator. This and more info here: http://stackoverflow.com/questions/2637606/how-do-i-change-the-mobile-country-code-mcc-in-the-android-emulator
adb shell setprop gsm.sim.operator.iso-country gb
@dominicthomas
dominicthomas / gradle_fabric_upload.txt
Created November 25, 2016 10:54
Code to upload a build to crashlytics even when setting a custom apk name.
android {
...
debug {
debuggable true
...
ext.betaDistributionGroupAliases = "Android-Test"
}
...
project.android.applicationVariants.all { variant ->
variant.preBuild.doLast {
@dominicthomas
dominicthomas / max_height_linear_layout.txt
Created December 8, 2016 12:23
Enables you to set a max height for a linear layout while also using wrap content.. this means the layout will be collapsable but also have height constraints!
public class MaxHeightLinearLayout extends LinearLayout {
private int maxHeightDp;
public MaxHeightLinearLayout(Context context) {
super(context);
}
public MaxHeightLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);