Skip to content

Instantly share code, notes, and snippets.

View sebaslogen's full-sized avatar

Sebas LG sebaslogen

View GitHub Profile
@sebaslogen
sebaslogen / item-server-driven-ui.json
Last active September 12, 2019 13:56
Item from Server Driven UI JSON example for post
{
"title": "Dance - Smith Quartet",
"image": "https://demo.com/624.jpg",
"action": {
"type": "ComponentScreen",
"url": "/query/view/album/635212023624"
}
}

Keybase proof

I hereby claim:

  • I am sebaslogen on github.
  • I am sebaslogen (https://keybase.io/sebaslogen) on keybase.
  • I have a public key ASC32nccv5aNWfjyCGsuI4fwejoCRfoApEyoxnwE5TwRjgo

To claim this, I am signing this object:

@sebaslogen
sebaslogen / sdui-data-classes.kt
Last active August 9, 2019 13:58
Server Driven UI post: Kotlin data classes
data class ComponentScreen(val title: String?, val sections: List<Section> = emptyList())
sealed class Section
data class AlbumListSection(val title: String?, val items: List<AlbumListItem>) : Section()
data class ShelfSection(val shelfStyle: ShelfItemStyle, val items: List<ShelfItem>) : Section()
data class TrackListSection(val items: List<TrackListItem>) : Section()
data class AlbumListItem(val title: String, val image: String, val action: Action)
@sebaslogen
sebaslogen / server-driven-ui.json
Last active August 8, 2019 15:18
Server Driven UI simple JSON example for post
{
"type": "componentScreen",
"title": "Home",
"sections": [
{
"title": "New Releases",
"type": "album",
"items": [
{
"title": "Dance - Smith Quartet",
@sebaslogen
sebaslogen / old-style.json
Last active August 8, 2019 14:18
Old style json for Server Driven UI post
[
{
"id": 0362403,
"title": "Dance - Smith Quartet",
"image": "https://demo.com/03624.jpg"
},
{
"id": 06083706,
"title": "Sixteen Contemporary Love Songs for Piano",
"image": "https://demo.com/060837.jpg"
@sebaslogen
sebaslogen / LiveObservable.kt
Created July 9, 2017 21:15
LiveObservable: Android lifecycle aware wrapper for an RxJava Observable
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.OnLifecycleEvent
import com.jakewharton.rxrelay.BehaviorRelay
import rx.Observable
import rx.android.schedulers.AndroidSchedulers
import rx.functions.Action1
import rx.subscriptions.CompositeSubscription
@sebaslogen
sebaslogen / Toolbar.java
Last active March 3, 2018 14:43
Imaginary new Android Toolbar constructor
public class Toolbar extends ViewGroup {
public Toolbar(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, getToolbarStyle());
}
private static int getToolbarStyle() {
return (BuildConfig.VERSION_CODE >= Build.VERSION_CODES.O) ? R.attr.newCompatToolbarStyle : R.attr.toolbarStyle;
}
}
@sebaslogen
sebaslogen / Toolbar.java
Created March 3, 2018 10:46
Android Toolbar constructor
public class Toolbar extends ViewGroup {
public Toolbar(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.toolbarStyle);
}
}
@sebaslogen
sebaslogen / MyCustomView.kt
Created March 3, 2018 10:37
Kotlin Android CustomView with default parameters
class MyCustomView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr)
@sebaslogen
sebaslogen / RelaySharedWithMultipleProblematicOnSubscribeAndOnUnSubscribeEvents.java
Last active March 15, 2017 00:31
BehaviorRelay shared with multiple observers produces problematic onSubscribe and onUnSubscribe events
BehaviorRelay<Integer> brelay = BehaviorRelay.create();
Observable<Integer> relayObservable = brelay
.doOnSubscribe(() -> {
Log.i("RxExperiments", "BehaviorRelayProblem->doOnSubscribe");
}).doOnUnsubscribe(() -> {
Log.i("RxExperiments", "BehaviorRelayProblem->doOnUnsubscribe");
});
Log.i("RxExperiments", "BehaviorRelayProblem->observer-1 subscribes");
Subscription subscription1 = relayObservable.subscribe(i -> {