Skip to content

Instantly share code, notes, and snippets.

Avatar

Oleksii Malovanyi almozavr

  • Lviv, UA
View GitHub Profile
@almozavr
almozavr / FixedSwitchPreference.java
Last active Aug 29, 2015
FixedSwitchPreference
View FixedSwitchPreference.java
public class FixedSwitchPreference extends SwitchPreference {
/**
* Construct a new SwitchPreference with the given style options.
*
* @param context The Context that will style this preference
* @param attrs Style attributes that differ from the default
* @param defStyle Theme attribute defining the default style options
*/
public FixedSwitchPreference(Context context, AttributeSet attrs, int defStyle) {
View gist:f4d990fef964d0a1d4bd
public class PositionResizeAnimator {
public static Animator createAnimator(Holder srcHolder, Holder targetHolder, final View animateView) {
ValueAnimator heightAnimator = ValueAnimator.ofInt(srcHolder.height, targetHolder.height);
heightAnimator.addUpdateListener(
new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int val = (Integer) animation.getAnimatedValue();
ViewGroup.LayoutParams layoutParams = animateView.getLayoutParams();
@almozavr
almozavr / open_db.sh
Created Oct 1, 2014
Downloads db from non-root devices and opens it via provided sqlite-viewer.
View open_db.sh
#!/bin/sh
# Script for getting database form device via adb and open in sqlite_client(work with not rooted devices)
#
# While you aren't breaking script execution(CTLR+C),
# each closing of sqlite_client will be download and open database again and again.
#
# Note: if you don't have installed sqliteman override sqlite_client variable with your favorite client
#
# Usage: open_db.sh {app_package} {db_name} {app}
View blur static method
private static WeakReference<RenderScript> rsRef = new WeakReference<>(null);
private static WeakReference<ScriptIntrinsicBlur> blurScriptRef = new WeakReference<>(null);
/**
* Use {@link RenderScript} to blur bitmap.
*
* @param bitmap to be blurred
* @param radius of blur
* @throws RSRuntimeException when some .so libs are not available (e.g. on Genymotion emulator)
*/
@almozavr
almozavr / .gitconfig
Last active Aug 29, 2015
Basic config with great aliases
View .gitconfig
# core {{{
[core]
excludesfile = ~/.gitignore_global
pager=less -x4
quotepath = false
pager = less
autocrlf = input
#}}}
# user {{{
@almozavr
almozavr / Script to start-stop Genymotion with connection to ADB
Last active Aug 29, 2015
Start(resume)/stop virtual machine by serial number and connect/disconnect with adb. Could be useful to control remote CI Genymotion instance
View Script to start-stop Genymotion with connection to ADB
#!/bin/bash
#=====EXAMPLE OF USAGE===============
# $ ./scripts/gm.sh -r 526d4be6-9964-4a84-83fd-31af8029cf44
# $ ./gradlew clean connectedAndroidTest
# $ ./scripts/gm.sh -s 526d4be6-9964-4a84-83fd-31af8029cf44
#====================================
#===========
# VM helpers
@almozavr
almozavr / app_build.gradle
Created Jun 26, 2014
Workaround to bypass library's BuildConfig.DEBUG (always true, always release build type) via custom variable
View app_build.gradle
// Application
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
@almozavr
almozavr / .gitconfig
Created Jun 10, 2014
global git config
View .gitconfig
# core {{{
[core]
excludesfile = /Users/almozavr/.gitignore_global
pager=less -x4
quotepath = false
pager = less
autocrlf = input
#}}}
# user {{{
@almozavr
almozavr / gist:7692154
Created Nov 28, 2013
Launchrock mail with bad encoding for cyrillic texts
View gist:7692154
Delivered-To: almozavr@gmail.com
Received: by 10.42.87.141 with SMTP id y13csp11267icl;
Thu, 28 Nov 2013 05:45:34 -0800 (PST)
X-Received: by 10.194.185.73 with SMTP id fa9mr36830100wjc.29.1385646333791;
Thu, 28 Nov 2013 05:45:33 -0800 (PST)
Return-Path: <bounces+30137-5591-komanda=ecodnepr.org@email.launchrock.com>
Received: from li298-54.members.linode.com (li298-54.members.linode.com. [178.79.160.54])
by mx.google.com with ESMTP id pr7si23213775wjc.164.2013.11.28.05.45.33
for <almozavr@gmail.com>;
Thu, 28 Nov 2013 05:45:33 -0800 (PST)
View activity_login
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<ImageView
android:id="@+id/head_logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"