This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ObservableValue<T> { | |
| private T t; | |
| private final Subject<T, T> subject = new SerializedSubject<>(PublishSubject.create()); | |
| public Observable<T> observable() { | |
| return subject; | |
| } | |
| public T value() { | |
| return t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package jp.hoge | |
| import android.support.annotation.NonNull; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import rx.Observable; | |
| import rx.subjects.PublishSubject; | |
| import rx.subjects.SerializedSubject; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package jp.sample.android.lib.type; | |
| import android.support.annotation.NonNull; | |
| public final class SuccessFailure<Success, Failure> { | |
| public interface SuccessResult<Success> { | |
| void result(Success successResult); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.hkusu.example.lib.type; | |
| import android.support.annotation.NonNull; | |
| import java.util.LinkedHashSet; | |
| import java.util.Set; | |
| public class ImmutableSet<T> { | |
| private final Set<T> set = new LinkedHashSet<>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.hkusu.sample.android.lib.rx; | |
| import rx.Observable; | |
| import rx.subjects.PublishSubject; | |
| import rx.subjects.SerializedSubject; | |
| import rx.subjects.Subject; | |
| public class Event<T> { | |
| private final Subject<T, T> subject = new SerializedSubject<>(PublishSubject.create()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fun <T, U> LiveData<T>.map( | |
| scope: CoroutineScope, | |
| crossinline block: suspend (T) -> U | |
| ): LiveData<U> { | |
| val result = MediatorLiveData<U>() | |
| result.addSource(this) { | |
| scope.launch { | |
| result.postValue(block.invoke(it)) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun onButtonClicked(view: View?) { // unitテスト時はnullを渡す | |
| view?.disableContinuousClicks() | |
| // do something.. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| github.dismiss_out_of_range_messages | |
| # ktlint | |
| Dir.glob("**//build/reports/ktlint-results.xml").each { |report| | |
| checkstyle_format.base_path = Dir.pwd | |
| checkstyle_format.report report.to_s | |
| } | |
| # Android Lint | |
| Dir.glob("**//build/reports/lint-results*.xml").each { |report| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.hkusu.sample.ext | |
| import androidx.lifecycle.LiveData | |
| import androidx.lifecycle.MediatorLiveData | |
| import androidx.lifecycle.Observer | |
| import kotlinx.coroutines.CoroutineScope | |
| import kotlinx.coroutines.launch | |
| import kotlin.coroutines.CoroutineContext | |
| inline fun <T, U> LiveData<T>.mapNotNull( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.hkusu.sample.ui | |
| import android.os.Bundle | |
| import android.view.View | |
| import androidx.fragment.app.Fragment | |
| import io.github.hkusu.sample.databinding.MainFragmentBinding | |
| class MainFragment : Fragment(R.layout.main_fragment) { | |
| private val binding: MainFragmentBinding by viewBinding() |