Skip to content

Instantly share code, notes, and snippets.

View almozavr's full-sized avatar

Oleksii Malovanyi almozavr

  • Lviv, UA
View GitHub Profile
<?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"
@almozavr
almozavr / .gitconfig
Created August 19, 2013 11:42
Nice global git config
# core {{{
[core]
excludesfile = /Users/almozavr/.gitignore_global
pager=less -x4
quotepath = false
pager = less
autocrlf = true
#}}}
# user {{{
@almozavr
almozavr / Git aliases for code review
Created August 19, 2013 11:36
Git code review aliases
[alias]
log-branch-only = "!f() { arg1=$1; if [[ $# -lt 2 ]] || [[ $2 == -* ]] ; then arg2=$arg1; arg1='HEAD'; arg3=${*:2}; else arg2=$2; arg3=${*:3}; fi; hash=`git merge-base $arg1 $arg2`; git log $hash..$arg2 $arg3; }; f"
[alias]
diff-branch-only = "!f() { arg1=$1; if [[ $# -lt 2 ]] || [[ $2 == -* ]] ; then arg2=$arg1; arg1='HEAD'; arg3=${*:2}; else arg2=$2; arg3=${*:3}; fi; hash=`git merge-base $arg1 $arg2`; git diff $hash..$arg2 $arg3; }; f"
@Override
protected void onStart() {
super.onStart();
App.uiBus.registerSticky(this);
}
@Override
protected void onStop() {
super.onStop();
App.uiBus.unregister(this);
public class BusFragment extends Fragment {
@Override
public void onStart() {
super.onStart();
App.uiBus.registerSticky(this);
}
@Override
public void onStop() {
public List<Class<?>> getEventTypesBySubscriber(Object subscriber) {
List<SubscriberMethod> subscriberMethods = subscriberMethodFinder.findSubscriberMethods(subscriber.getClass(), defaultMethodName);
List<Class<?>> eventTypes = new ArrayList<Class<?>>(subscriberMethods.size());
for (SubscriberMethod method : subscriberMethods) {
eventTypes.add(method.eventType);
}
return eventTypes;
}
@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 / 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 / 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 / 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();