Skip to content

Instantly share code, notes, and snippets.

View antslava's full-sized avatar

Antonenko Viacheslav antslava

View GitHub Profile
@antslava
antslava / RxJavaExample.java
Created February 15, 2017 15:41
RxJava share()
package com.antmobile.java;
import rx.Observable;
import rx.Subscriber;
import rx.schedulers.Schedulers;
public class FirstTempClass {
public static void main(String[] args) {
final Observable<Long> observable = Observable.create(new Observable.OnSubscribe<Long>() {
@antslava
antslava / gist:4b0025f5ccc5a4b8906382c9d39d1ad9
Created August 1, 2016 12:21 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@antslava
antslava / AndroidApplication.java
Created July 21, 2016 11:41 — forked from android10/AndroidApplication.java
Android: how to know if your app is completely hidden
public class AndroidApplication extends MultiDexApplication {
public static final String TAG = AndroidApplication.class.getSimpleName();
@Override
public void onCreate() {
super.onCreate();
registerComponentCallbacks(new ComponentCallback());
}
private class ComponentCallback implements ComponentCallbacks2 {
@antslava
antslava / Interceptor.java
Created December 25, 2015 18:45 — forked from alex-shpak/Interceptor.java
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@antslava
antslava / BroadcastObservable.java
Created November 28, 2015 21:29 — forked from Diolor/BroadcastObservable.java
Retry with Connection
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Looper;
import rx.Observable;
import rx.Scheduler;
@antslava
antslava / FixedCheckedTextView.java
Last active May 13, 2016 05:22
CheckedTextView doesn't save checked state after rotation. Below you can find solution.
/**
* Fix issue with checked state.
*
* Created by Antonenko Viacheslav on 16/11/15.
*/
public class FixedCheckedTextView extends AppCompatCheckedTextView {
public FixedCheckedTextView(Context context) {
super(context);
}
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
Google Apps for Android 4.2 (https://www.androidfilehost.com/?fid=23060877490000128 - gapps-jb-20130812-signed.zip)
Google Apps for Android 4.1 (https://www.androidfilehost.com/?fid=22979706399755082 - gapps-jb-20121011-signed.zip)
@antslava
antslava / designer.html
Last active August 29, 2015 14:20
designer
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
package com.ryanharter.mediaroute.widgets;
import android.content.Context;
import android.support.v7.app.MediaRouteActionProvider;
import android.support.v7.app.MediaRouteButton;
/**
* A MediaRouteActionProvider that allows the use of a ThemeableMediaRouteButton.
*/
public class ThemeableMediaRouteActionProvider extends MediaRouteActionProvider {
package com.yourapp;
import java.io.File;
public final class RootStatus {
private static RootStatus instance;
private final boolean rooted;