This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package evalu.com.evalu.utils.rx; | |
| import android.content.Context; | |
| import android.os.Build; | |
| import android.support.annotation.RequiresApi; | |
| import android.util.AttributeSet; | |
| import android.view.MotionEvent; | |
| import android.widget.ScrollView; | |
| import io.reactivex.subjects.PublishSubject; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CatPresenter{ | |
| BehaviorSubject<List<Cat>> catsSubject = BehaviorSubject.create(); | |
| Disposable catsDisposable; | |
| void onCreate(){ | |
| someClient.subscribe( cats -> { catsSubject.onNext(cats) }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package xD; | |
| import android.content.Context; | |
| import android.content.res.AssetFileDescriptor; | |
| import android.media.MediaPlayer; | |
| import android.util.Log; | |
| import hugo.weaving.DebugLog; | |
| import io.reactivex.Observable; | |
| import io.reactivex.ObservableEmitter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.bluetooth.BluetoothGatt; | |
| import android.bluetooth.BluetoothGattCharacteristic; | |
| import android.bluetooth.BluetoothGattDescriptor; | |
| import android.support.annotation.NonNull; | |
| import android.util.Log; | |
| import java.util.UUID; | |
| /** | |
| * Helper which enables or disables BLE gatt updates from connected peripheral, not tested in production | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.emil.android.util; | |
| import android.content.Context; | |
| import android.net.ConnectivityManager; | |
| import android.net.NetworkInfo; | |
| import android.telephony.TelephonyManager; | |
| /** | |
| * Check device's network connectivity and speed | |
| * @author emil http://stackoverflow.com/users/220710/emil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @author Lukasz Marczak | |
| * @since 28.09.16. | |
| */ | |
| import android.graphics.Bitmap; | |
| import android.graphics.BitmapFactory; | |
| import android.os.Bundle; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.util.Log; | |
| import android.view.View; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int threadCt = Runtime.getRuntime().availableProcessors() + 1; | |
| ExecutorService executor = Executors.newFixedThreadPool(threadCt); | |
| Schedulers scheduler = Schedulers.from(executor); | |
| Observable.range(1,1000) | |
| .groupBy(i -> batch.getAndIncrement() % threadCt ) | |
| .flatMap(g -> g.observeOn(scheduler) | |
| .map(i -> intenseCalculation(i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void main(String[] argv) { | |
| new CesarCipher().solve(); | |
| } | |
| public void solve() { | |
| Scanner in = new Scanner(System.in); | |
| int t = Integer.valueOf(in.nextLine()); | |
| String line = in.nextLine(); | |
| StringBuilder sb = new StringBuilder(); | |
| String keys = in.nextLine(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String[] getIds = new String[]{"id:0", "id:1", "id:2", "id:3"}; | |
| rx.Observable.just(getIds) | |
| .flatMap(new Func1<String[], Observable<String>>() { | |
| @Override | |
| public Observable<String> call(String[] strings) { | |
| //dla kazdego id odpytaj api | |
| return Observable.from(strings); | |
| } | |
| }).flatMap(new Func1<String, Observable<Integer>>() { | |
| @Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rx.Observable.range(1, 100).map(i -> String.valueOf(i).concat( | |
| (i % 15 == 0 ? "FizzBuzz" : i % 3 == 0 ? "Fizz" : i % 5 == 0 ? "Buzz" : ""))) | |
| .subscribe(System.out::println); | |
| OR, more readable: | |
| rx.Observable.range(1, 100).map(i -> i + suffixFor(i)).subscribe(System.out::println); | |
| ... |