(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/** | |
* 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) |
/* | |
* 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 |
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; |
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 { |
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) { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.