Skip to content

Instantly share code, notes, and snippets.

View arranlomas's full-sized avatar

Arran Lomas arranlomas

View GitHub Profile
data class MainViewState(
val error: Throwable? = null
val loading: Boolean = false,
val teamAScore: Int = 0,
val teamBScore: Int = 0)
private void showTask(Task task) {
// The view may not be able to handle UI updates anymore
if (mAddTaskView.isActive()) {
mAddTaskView.setTitle(task.getTitle());
mAddTaskView.setDescription(task.getDescription());
}
mIsDataMissing = false;
}
package com.example.android.architecture.blueprints.todoapp.addedittask;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.example.android.architecture.blueprints.todoapp.UseCase;
import com.example.android.architecture.blueprints.todoapp.UseCaseHandler;
import com.example.android.architecture.blueprints.todoapp.addedittask.domain.usecase.GetTask;
import com.example.android.architecture.blueprints.todoapp.addedittask.domain.usecase.SaveTask;
import com.example.android.architecture.blueprints.todoapp.tasks.domain.model.Task;
package com.example.android.architecture.blueprints.todoapp.addedittask;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
Observable.fromIterable(listOf(1,2,3,4,5))
.map { number -> number*5 } // 1,2,3,4,5 -> 5, 10, 15, 20, 25
.map { multipliedNumber -> multipliedNumber.toString() } // 5, 10, 15, 20, 25 -> "5", "10", "15", "20", "25"
.filter { it.endsWith("0") } // "5", "10", "15", "20", "25" -> "10", "20"
.subscribe { result -> println(result) } // "10", "20"
@arranlomas
arranlomas / problem.kt
Created January 29, 2018 06:38
Issue with mvi action processor trying to make it generic
package com.freelancer.android.observablemergetest
import io.reactivex.Observable
import io.reactivex.ObservableTransformer
fun masterActionProcessor(): ObservableTransformer<Action, Result> =
ObservableTransformer { action: Observable<Action> ->
action.publish { shared ->
Observable.merge(
shared.ofType(Action.Action1::class.java).compose(action1Processor()),
@arranlomas
arranlomas / project root build.gradle
Created December 13, 2017 22:38
shows the root build.gradle file for a multi-project build using the dependencies.gradle file
//This is where we tell gradle that we have added an extra build file
apply from: 'gradle/dependencies.gradle'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
@arranlomas
arranlomas / sub-project build.gradle
Created December 13, 2017 22:35
showing the build.gradle file for a sub project using a dependencies.gradle file in a multi-project build
apply plugin: 'com.android.library'
//Declaring a variable to points to the ext list we added to in the dependencies.gradle
def globalConf = rootProject.ext
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
@arranlomas
arranlomas / dependencies.gradle
Created December 13, 2017 22:19
Example of a dependencies.gradle file for adding dependencies to a multiproject build
ext {
kotlin_version = "1.2.0"
commonDependencies = [
appCompat : 'com.android.support:appcompat-v7:26.+',
jUnit : 'junit:junit:4.12',
kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version",
rxJava : 'io.reactivex.rxjava2:rxjava:2.1.6',
espressoCore : 'com.android.support.test.espresso:espresso-core:2.2.2',
]
: panic: page 4 already freed
09-18 22:31:51.694 24945-0/com.arran.cloudburst E/Go: goroutine 15750 [running]:
09-18 22:31:51.694 24945-0/com.arran.cloudburst E/Go: github.com/boltdb/bolt.(*freelist).free(0x4420151470, 0x5, 0x7f7ceb4000)
09-18 22:31:51.694 24945-0/com.arran.cloudburst E/Go: D:/Go/projects/src/github.com/boltdb/bolt/freelist.go:121 +0x274
09-18 22:31:51.694 24945-0/com.arran.cloudburst E/Go: github.com/boltdb/bolt.(*node).spill(0x44203f6380, 0x442091a738, 0x14)
09-18 22:31:51.694 24945-0/com.arran.cloudburst E/Go: D:/Go/projects/src/github.com/boltdb/bolt/node.go:363 +0x190
09-18 22:31:51.694 24945-0/com.arran.cloudburst E/Go: github.com/boltdb/bolt.(*Bucket).spill(0x4420281100, 0x44208ce900, 0x442091ab20)
09-18 22:31:51.694 24945-0/com.arran.cloudburst E/Go: D:/Go/projects/src/github.com/boltdb/bolt/bucket.go:570 +0x354
09-18 22:31:51.694 24945-0/com.arran.cloudburst E/Go: github.com/boltdb/bolt.(*Bucket).spill(0x442035a1d8, 0x68d7af7b9, 0x7f7e054800)
09-18 22:31:51.694 24945-0/com.arran.c