Skip to content

Instantly share code, notes, and snippets.

View almozavr's full-sized avatar

Oleksii Malovanyi almozavr

  • Lviv, UA
View GitHub Profile
@almozavr
almozavr / .gitconfig
Last active August 29, 2015 14:06
Basic config with great aliases
# core {{{
[core]
excludesfile = ~/.gitignore_global
pager=less -x4
quotepath = false
pager = less
autocrlf = input
#}}}
# user {{{
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 / open_db.sh
Created October 1, 2014 16:08
Downloads db from non-root devices and opens it via provided sqlite-viewer.
#!/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}
@almozavr
almozavr / gist:f4d990fef964d0a1d4bd
Created October 5, 2014 14:29
PositionResizeAnimator
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 / FixedSwitchPreference.java
Last active November 28, 2022 15:46
FixedSwitchPreference
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) {
@almozavr
almozavr / ObjectGsonParceler.java
Last active September 30, 2020 16:53
Parcelable helper to wrap object convertable with gson
public class ObjectGsonParceler {
private final Gson gson;
public ObjectGsonParceler(Gson gson) {
this.gson = gson;
}
public Parcelable wrap(Object instance) {
try {
String json = encode(instance);
@almozavr
almozavr / AndroidPaletteCallback
Last active August 29, 2015 14:19 — forked from imminent/ExampleActivity.java
Gist for a modified approach to integrating Palette with Picasso proposed by Jake Wharton for the interim while Picasso doesn't have a supported way to pass meta data along the pipeline. http://jakewharton.com/coercing-picasso-to-play-with-palette/ Fork provides diff RoundedImageView support
package your.package;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.widget.ImageView;
public abstract class AndroidPaletteCallback extends PaletteCallback<ImageView> {
public AndroidPaletteCallback(@NonNull ImageView imageView) {
@almozavr
almozavr / ModalUrl
Last active August 29, 2015 14:19
Modal which preserves unique url via query, best with with routeProvider's reloadOnSearch: false
angular.module("services").factory('ModalUrl', [
'$rootScope', '$modal', '$location', '$routeParams', '$window', '$timeout',
($rootScope, $modal, $location, $routeParams, $window, $timeout) ->
modalInstance = null
checkModal = () ->
modalParam = decodeURIComponent($routeParams.modal)
if (modalParam != 'undefined')
optionsParam = decodeURIComponent($routeParams.options)
if (optionsParam != 'undefined')
options = JSON.parse(optionsParam)
@almozavr
almozavr / gist:fc76f605c03822a3ee14
Created July 13, 2015 17:36
Sms intent builder
public static Intent newSmsIntent(Context context, String body, String... phoneNumber) {
Uri smsUri;
if (phoneNumber == null) {
smsUri = Uri.parse("smsto:");
} else {
smsUri = Uri.parse("smsto:" + Uri.encode(TextUtils.join(",", phoneNumber)));
}
Intent intent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
intent = new Intent(Intent.ACTION_SENDTO, smsUri);
@almozavr
almozavr / build.gradle
Created May 5, 2016 12:14
AndroidTDDBootStrap app Flavor Dimensions test
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Piasy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is