Skip to content

Instantly share code, notes, and snippets.

Avatar

Pascal Welsch passsy

View GitHub Profile
@passsy
passsy / ViewModelExample.kt
Last active Sep 14, 2016
VPVM Example of a ViewModel which can be used inside a ThirtyInch TiPresenter. This is built with Kotlin and Rx. While you may not use those technologies in your app you get the idea
View ViewModelExample.kt
private class ViewModel {
private var changing = PublishSubject.create<Unit>()
fun observe(): Observable<ViewModel> {
return Observable.just(this).mergeWith(changing.map { this })
}
var results: List<SearchResult> by onChangeNotifySubject(emptyList(), changing,
{ p, o, newValue -> if (newValue.isEmpty()) selectedResult = null })
View HelloWorldActivity.java
public class HelloWorldActivity
extends TiActivity<HelloWorldPresenter, HelloWorldView>
implements HelloWorldView {
private TextView mOutput;
@NonNull
@Override
public HelloWorldPresenter providePresenter() {
return new HelloWorldPresenter();
@passsy
passsy / 1-global_build.gradle
Last active Sep 22, 2017
include git-versioner into your project
View 1-global_build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@passsy
passsy / build.gradle
Last active Jun 6, 2016
lazy versionCode with git versioner
View build.gradle
// Optional: configure the versioner (before applying the script)
/* ext.gitVersioner = [
defaultBranch : "develop", // default "master"
yearFactor : 1200, // default "1000", increasing every 8.57h
snapshotEnabled : false, // default false, the "-SNAPSHOT" postfix
localChangesCountEnabled: false // default false, the (<commitCount>) before -SNAPSHOT
] */
apply from: 'https://raw.githubusercontent.com/passsy/gradle-GitVersioner/master/git-versioner.gradle'
android {
@passsy
passsy / build.gradle
Last active Jan 15, 2021
lazy jake wharton versioning
View build.gradle
def versionMajor = 3
def versionMinor = 0
def versionPatch = 0
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
android {
defaultConfig {
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
}
@passsy
passsy / OperatorSemaphore.java
Created Apr 28, 2015
A Presenter when using RxAndroid which delays delivering to the View when the View isn't ready
View OperatorSemaphore.java
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Konstantin Mikheev sirstripy-at-gmail-com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@passsy
passsy / gist:9daebd806436ffb6dc02
Created Jan 27, 2015
elevatorsaga two queues
View gist:9daebd806436ffb6dc02
{
init: function(elevators, floors) {
_.each(elevators, function(elevator) {
elevator.goToFloor(0);
});
var upQueue = [];
var downQueue = [];
View gist:8e29670a3166ef4cb047
/**
* elevatorsaga level 10 - single queue
* http://play.elevatorsaga.com/#challenge=10
**/
{
init: function(elevators, floors) {
_.each(elevators, function(elevator) {
elevator.goToFloor(0);
});
@passsy
passsy / material text sizes.md
Last active Jan 22, 2021
Material font sizes
View material text sizes.md
@passsy
passsy / A_README.md
Last active Jan 17, 2020
Android Studio Light Theme
View A_README.md

Colorful Java (and Kotlin) Android Studio Theme

This Android Studio Theme (or IntelliJ in general) is based on many IDEs.

Previews