Skip to content

Instantly share code, notes, and snippets.

View korniltsev's full-sized avatar
🏳️‍🌈
s/jz/jnz/

Tolya Korniltsev korniltsev

🏳️‍🌈
s/jz/jnz/
View GitHub Profile

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code.

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here

@korniltsev
korniltsev / introrx.md
Last active August 29, 2015 14:21 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class StringUtils {
private StringUtils() { /* No op */ }
public static String from(InputStream is) {
byte[] buffer = new byte[1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@korniltsev
korniltsev / how.go
Created September 8, 2015 15:32
how
func foo(ss ...string) {
fmt.Println(ss)
}
func bar(ss ...string) {
foo(ss)
}
/*
* Copyright (C) 2016 Jesse Wilson
*
* 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
@korniltsev
korniltsev / CenterCropDrawable.java
Created September 8, 2016 13:38
CenterCropDrawable
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
public class CenterCropDrawable extends Drawable {
private final Drawable drawable;
# init
repo init -u https://android.googlesource.com/platform/manifest
# the same but depth=1 for faster clone
repo init --depth=1 -u https://android.googlesource.com/platform/manifest
# sync network in 4 threads and sync local in 16 threads
repo sync -n -j 4 && repo sync -l -j 16
# the same but sync only current branch -c
@korniltsev
korniltsev / GOD.java
Created September 30, 2016 09:21
GOD.java
package ru.ok.android.bus.gen;
import android.content.Context;
import android.support.annotation.AnyRes;
import android.support.annotation.NonNull;
import android.util.Pair;
import java.lang.Boolean;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
@korniltsev
korniltsev / God2.java
Created October 4, 2016 07:40
God2.java
@NonNull
public static StreamViewHolder getViewHolder(LayoutInflater li,
/* parent */ ViewGroup p, int viewType, StreamItemViewController streamItemViewController) {
View v = null;
StreamViewHolder vh = null;
switch (viewType) {
case VIEW_TYPE_HEADER:
v = StreamFeedHeaderItem.newView(li, p);
vh = StreamFeedHeaderItem.newViewHolder(v, streamItemViewController);
@korniltsev
korniltsev / GammaEvaluator.java
Created October 15, 2016 12:33 — forked from FrancoisBlavoet/GammaEvaluator.java
Correct color interpolation
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import static java.lang.Math.pow;
public class GammaEvaluator implements TypeEvaluator {
private static final GammaEvaluator sInstance = new GammaEvaluator();
/**