Skip to content

Instantly share code, notes, and snippets.

View CostaFot's full-sized avatar
🍦

Costa Fotiadis CostaFot

🍦
View GitHub Profile
package com.shreyaspatil.callbackflownetwork
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.MutableStateFlow
@CostaFot
CostaFot / dependencies.gradle
Created June 20, 2019 22:07
Android common dependencies collection
allprojects {
ext {
// NEVER name this block 'android'. Never name *ANY* block android
androidVersions = [
// updated 17/3/2019
androidXVersion : "1.0.0",
livedata : '2.0.0-rc01',
minSdkVersion : 21,
targetSdkVersion : 28,
compileSdkVersion: 28,
@CostaFot
CostaFot / .gitignore
Created April 14, 2019 13:45
Android .gitignore template
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
@MikeFot
MikeFot / AppActivityLifecycleCallbacks.java
Created March 22, 2019 11:46
Activity Lifecycle Callbacks (for when you join a new company and you have no idea what fragment you are looking at)
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import timber.log.Timber;
@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)