Skip to content

Instantly share code, notes, and snippets.

View Tagakov's full-sized avatar
🦊

Vladimir Tagakov Tagakov

🦊
View GitHub Profile
@Tagakov
Tagakov / My SO question RxJava
Last active August 29, 2015 14:21
Stack overflow question about rxjava and retrofit. How to transform observable's error to another observable?
How do I transform observable's error to another observable?
I am trying to implement algorithm showed on scheme below:
![Block scheme][1]
[1]: http://i.stack.imgur.com/777p5.png
I am using a tutorial named Grokking RxJava to start my learning and found that flatMap operator can convert one Observable returning by Retrofit into another which allows me to do a chain of invocations of server methods. But in the tutorial chaining methods always return success result. **How I can do the same chaining if one of the remote methods returns error?**
@Tagakov
Tagakov / SectorClipProgress.java
Last active August 29, 2015 14:22
Example of clipPath like behavior with use of hardware accelerated Xfermode.
package com.tagakov.testapplication;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
@Tagakov
Tagakov / SectorClipProgress.java
Last active August 29, 2015 14:22
Example of clipPath like behavior with use of BItmapShader.
package com.tagakov.testapplication;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
@Tagakov
Tagakov / DevButton.java
Last active July 30, 2016 09:49
Hidden button for debugging purposes. Should be used with: debugCompile 'com.squareup:seismic:1.0.2'
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Vibrator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
public class PagerLayoutManager extends LinearLayoutManager {
private static final int SETTLE_DURATION = 600;
private static final float DEFAULT_FLING_THRESHOLD_DP = 10f;
private final int flingThreshold;
private int scrollState;
public PagerLayoutManager(Context context) {
@Tagakov
Tagakov / mainframer-init.sh
Last active January 19, 2017 17:01
Mainframer initialization script
#!/usr/bin/env bash
REMOTE_MACHINE=${1}
APPLICATION_MODULE=${2}
ASSEMBLE_COMMAND=${3}
ASSEMBLE_TESTS_COMMAND=${4}
ANDROID_SDK_VERSION=${5}
@Tagakov
Tagakov / Magic.kt
Last active May 23, 2017 20:02 — forked from nsk-mironov/Magic.kt
fun <T> magic(jobs: Observable<Completable>, hot: Observable<T>): Observable<T> {
return Observable.switchOnNext(jobs.map { it.andThen(hot) }.startWith(hot))
}
@Tagakov
Tagakov / FragmentsBug.java
Last active May 31, 2017 20:04
To reproduce bug:1. open app, 2. click on fullscreen button3. rotate device twice4. click back twice (exit app)5. look at logcat
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new FrameLayout(this) {{
setId(42);
}});
if (savedInstanceState == null) {
@Tagakov
Tagakov / EpicMiddleware.kt
Last active December 11, 2017 16:44
redux?
typealias Epic<State> = (actions: Observable<Action>, currentState: CurrentState<State>) -> Observable<Action>
typealias CurrentState<State> = () -> State
class EpicMiddleware<State: Any> constructor(): Middleware<State> {
private val epics = PublishSubject.create<Epic<State>>()
override fun invoke(store: Store<State>, nextDispatcher: Dispatcher) : Dispatcher {
val actions = PublishSubject.create<Action>()
epics