Skip to content

Instantly share code, notes, and snippets.

View dimanem's full-sized avatar

Dima Nemets dimanem

View GitHub Profile
fun <TResult> Task<TResult>.asObservable(): Observable<TResult> {
return Observable.create<TResult> { emitter ->
this.addOnSuccessListener {
emitter.onNext(it)
emitter.onComplete()
}
this.addOnFailureListener {
emitter.onError(it)
}
}
public class MyAPI {
@GET("{path}")
Call<List<Data>> getData(@Path("path") String pathValue);
}
public class Repo {
private Context _context;
private List<Data> _loadedData;
private MyRetrofitService _retrofitService;
@dimanem
dimanem / setStatusBarColor
Created December 13, 2017 09:01
Set Status Bar Color programatially
private void setStatusBarColor(int color) {
if (color == Color.TRANSPARENT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().setStatusBarColor(color);
}
}
@dimanem
dimanem / 0_reuse_code.js
Last active August 29, 2015 14:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dimanem
dimanem / Google Play Services crash when sharing text using google+
Last active August 29, 2015 14:10
Google+ API for Android - crash when trying to share text
Google Play Services Has Stopped!
Logcat:
E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.google.android.gms.ui, PID: 3883
java.lang.IllegalArgumentException
at com.google.k.a.aj.a(SourceFile:72)
at com.google.android.gms.plus.audience.a.e.<init>(SourceFile:63)
at com.google.android.gms.plus.audience.a.e.<init>(SourceFile:53)
at com.google.android.gms.plus.audience.a.d.<init>(SourceFile:28)