Skip to content

Instantly share code, notes, and snippets.

Avatar

Vitaliy ultraon

View GitHub Profile
@ultraon
ultraon / build.gradle
Last active Mar 30, 2016
Example for building android library module (in project) with custom variant
View build.gradle
//snippet from library module
android {
defaultPublishConfig "productionRelease"
publishNonDefault true
productFlavors {
alpha {
}
production {
}
@ultraon
ultraon / ReflectionUtils.java
Last active Jun 15, 2016
The reflection utils for convenient working with java reflection operations
View ReflectionUtils.java
package utils;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.lang.reflect.Field;
/**
* The utility class with reflection convenient methods.
*/
@ultraon
ultraon / HandledClickUrlTextView.java
Last active Jun 15, 2016
The HandledClickUrlTextView is an extended TextView for supporting custom handler for link clicks
View HandledClickUrlTextView.java
package presentation.view;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@ultraon
ultraon / ChildrenViewStateHelper.java
Last active Aug 3, 2016
Example of ChildrenViewStateHelper for saving view states with the same id in ViewGroup
View ChildrenViewStateHelper.java
package mypackage.presentation.utils.view;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.SparseArray;
import android.view.ViewGroup;
public class ChildrenViewStateHelper {
@ultraon
ultraon / HorizontalOverScrollView.java
Created Dec 9, 2016
Bouncable HorizontalScrollView
View HorizontalOverScrollView.java
public class HorizontalOverScrollView extends HorizontalScrollView {
private static final int WIDTH_DEVIDER_OVERSCROLL_DISTANCE = 3;
private TimeInterpolator mInterpolator;
private int mMaxOverscrollDistance;
private int mAnimTime;
private long mStartTime;
/**
* Instantiates {@link HorizontalOverScrollView} object.
@ultraon
ultraon / reset_routing_table.sh
Created Mar 6, 2017 — forked from midwire/reset_routing_table.sh
Reset routing table on OSX
View reset_routing_table.sh
#!/usr/bin/env bash
# Reset routing table on OSX
# display current routing table
echo "********** BEFORE ****************************************"
netstat -r
echo "**********************************************************"
for i in {0..4}; do
sudo route -n flush # several times
@ultraon
ultraon / bash-cheatsheet.sh
Created Mar 17, 2017 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
View bash-cheatsheet.sh
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@ultraon
ultraon / RuntimeTypeAdapterFactory.java
Last active May 23, 2017
RuntimeTypeAdapterFactory with fixed issue: com.google.gson.JsonParseException
View RuntimeTypeAdapterFactory.java
/*
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ultraon
ultraon / StateHandler.java
Last active May 24, 2017
Special class that can handle {@link Runnable} actions that started after {@link android.app.Activity#onPause()}, in this case state handler remembers all actions and starts them after {@link android.app.Activity#onResume()}. All methods should be called from UI thread otherwise an exception will be thrown. This class has very convenient usage w…
View StateHandler.java
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import io.reactivex.functions.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.Queue;
@ultraon
ultraon / build.gradle.txt
Last active May 24, 2017
Adds support for splitted Apkes by abi (arch platform), creates renameApk task (supports the android.split feature), see https://developer.android.com/studio/build/gradle-tips.html
View build.gradle.txt
apply plugin: 'com.android.application'
//...
//Adds support for splitted Apkes by abi (arch platform)
android {
//...
splits {
// Configures multiple APKs based on ABI.
abi {
You can’t perform that action at this time.