Skip to content

Instantly share code, notes, and snippets.

import android.os.Bundle
import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
@pbochenski
pbochenski / component.kt
Last active October 24, 2017 11:47
learning_dagger
@Component
interface AppComponent

Keybase proof

I hereby claim:

  • I am pbochenski on github.
  • I am pbochenski (https://keybase.io/pbochenski) on keybase.
  • I have a public key ASACh_c5xS4LldtUYAA93fRgyYJEQA_8FLHVaS-y5mdkYgo

To claim this, I am signing this object:

@pbochenski
pbochenski / ViewModel.kt
Last active July 22, 2019 00:22
LiveData meets RxJava
class MainViewModel(app: Application) : AndroidViewModel(app) {
private val postRepo = getApplication<App>().postRepo
private val LOAD_ITEM_COUNT = 15
fun getPosts(): LiveData<List<Post>> {
return postRepo.posts.map {
it.map { Post(it.id, it.title, it.url) }
}
}
@pbochenski
pbochenski / crash.md
Last active April 10, 2018 18:16
testing LiveData

java.lang.RuntimeException: Method getMainLooper in android.os.Looper not mocked. See http://g.co/androidstudio/not-mocked for details.
at android.os.Looper.getMainLooper(Looper.java)
at android.arch.core.executor.DefaultTaskExecutor.isMainThread(DefaultTaskExecutor.java:58)
at android.arch.core.executor.AppToolkitTaskExecutor.isMainThread(AppToolkitTaskExecutor.java:115)
at android.arch.lifecycle.LiveData.assertMainThread(LiveData.java:408)
at android.arch.lifecycle.LiveData.setValue(LiveData.java:290)
at android.arch.lifecycle.MutableLiveData.setValue(MutableLiveData.java:33)
at pl.pbochenski.archcomponentstest.MainViewModelTest.shouldGetPostsAndHaveACopyOfIt(MainViewModelTest.kt:48) ...

//private methods:
void readKeyboard();
void resetButtons();
void advanceButtons();
void pushToSerial();
byte getPitch(int i);
void midi_note_off(byte key);
void midi_note_on(byte key);