Skip to content

Instantly share code, notes, and snippets.

View alextcn's full-sized avatar
⛩️
focused

Alex Tkachenko alextcn

⛩️
focused
View GitHub Profile
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing
@mannodermaus
mannodermaus / MyActivity.java
Created April 6, 2016 22:12
Apply custom background color to Android Notification
package com.github.aurae.notifications;
import android.app.Notification;
import android.os.Bundle;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v7.app.AppCompatActivity;
public class MyActivity extends AppCompatActivity {
@Override protected void onCreate(Bundle savedInstanceState) {
@aashreys
aashreys / ChromeTabUtils.java
Last active November 20, 2019 06:00
Simple helper to check if Chrome Tabs is supported on a device and open urls.
public class ChromeTabUtils {
public static void openUrl(Context context, String url) {
if (isChromeTabSupported(context)) {
// Build intent to open Chrome Tab
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(getColor(context, R.color.toolbarBackground));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context, Uri.parse(url));
} else {
@julianfalcionelli
julianfalcionelli / RxErrorHandlingCallAdapterFactory.java
Last active June 21, 2022 08:55
Rx Error Handling for Retrofit2
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.Single;
import io.reactivex.SingleSource;
import io.reactivex.annotations.NonNull;
/*
* Copyright (C) 2017 The Android Open Source Project
*
* 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
@JoseAlcerreca
JoseAlcerreca / EventObserver.kt
Created April 26, 2018 12:14
An Observer for Events, simplifying the pattern of checking if the Event's content has already been handled.
/**
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has
* already been handled.
*
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled.
*/
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let { value ->
onEventUnhandledContent(value)