Skip to content

Instantly share code, notes, and snippets.

View cavega's full-sized avatar

Carlos Vega II cavega

View GitHub Profile
@cavega
cavega / gist:581d3a1a452cc940f63c
Created June 10, 2015 21:42
Fragment Layout using CoordinatorLayout and AppBarLayout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
@cavega
cavega / KotlinTrait
Last active August 29, 2015 14:18
Kotlin Object with inner trait: instancing anonymous trait inside activity
// ** Kotlin implementation **
// Singleton with inner trait
object LastFmManager {
public trait TopArtistsFetchEvent {
public fun topArtistsFetchSucceeded(artists: List<LastFmArtist>)
public fun topArtistsFetchFailed(throwable: Throwable)
}
// Other logic here
@cavega
cavega / build.gradle
Created March 26, 2015 18:34
Kotlin Sample: Android Studio 1.2 Prev. 4
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.cavega.kotlinmusings"
minSdkVersion 16
@cavega
cavega / RxCombineApiCalls
Created March 23, 2015 13:50
Use RXJava for Merging Response of 2 API calls
Observable.combineLatest(
ApiProvider.requestSource1(param1),
ApiProvider.requestSource2(param2),
this::combinedResponses)
.map(responseObject -> saveResponse(responseObject, context))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(responseObject -> onResponseReceived(responseObject, listener),
null != errorCallback ? errorCallback : this::onFetchObjectFailed);