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 final class CanvasExtensionsKt { | |
| public static final void runSafely(android.graphics.Canvas, kotlin.jvm.functions.Function1<? super android.graphics.Canvas, kotlin.Unit>); | |
| Code: | |
| // Some byte-code is hidden | |
| 13: invokevirtual #23 // Method android/graphics/Canvas.save:()I | |
| 16: istore_2 | |
| 17: aload_1 | |
| 18: aload_0 | |
| 19: invokeinterface #29, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object; | |
| 24: pop |
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
| protected void onDraw(android.graphics.Canvas); | |
| Code: | |
| // Some byte-code is hidden | |
| 18: invokestatic #31 // Method CanvasExtensionsKt.runSafely:(Landroid/graphics/Canvas;Lkotlin/jvm/functions/Function1;)V | |
| // ... |
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 Canvas.runSafely( | |
| lambda: Canvas.() -> Unit | |
| ) { | |
| val c = save() | |
| lambda.invoke(this) | |
| restoreToCount(c) | |
| } |
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
| protected void onDraw(android.graphics.Canvas); | |
| Code: | |
| // Some byte-code is hidden | |
| 14: invokevirtual #23 // Method android/graphics/Canvas.save:()I | |
| 17: istore_3 | |
| 18: aload_2 | |
| 19: astore 4 | |
| 21: ldc #25 // String test | |
| 23: astore 5 | |
| 25: getstatic #31 // Field java/lang/System.out:Ljava/io/PrintStream; |
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
| override fun onDraw(canvas: Canvas) { | |
| super.onDraw(canvas) | |
| // Invoke the inline function | |
| canvas.runSafely { | |
| println("test") | |
| } | |
| } |
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 Canvas.runSafely( | |
| lambda: Canvas.() -> Unit | |
| ) { | |
| val checkPoint = save() | |
| // "this" is Canvas | |
| lambda.invoke(this) | |
| restoreToCount(checkPoint) | |
| } |
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 getOrientation(attrs: AttributeSet?): Int { | |
| val b = context.theme.obtainStyledAttributes( | |
| attrs, | |
| intArrayOf(android.R.attr.orientation), 0, 0) | |
| val orientation = b.getInt(0, RecyclerView.VERTICAL) | |
| b.recycle() | |
| return orientation | |
| } |
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
| constructor(...) : super(...) { | |
| val a = context.theme.obtainStyledAttributes( | |
| attrs, | |
| R.styleable.StyledRecyclerView, 0, 0) | |
| decorateView(a, getOrientation(attrs)) | |
| a.recycle() | |
| } | |
| private fun decorateView( | |
| typedArray: TypedArray, |
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
| class TakeWhenObservableTest { | |
| @Test | |
| fun openThrottle_shouldSeeTheItemsAreSentThen() { | |
| val src = PublishSubject.create<Int>() | |
| val whenSrc = PublishSubject.create<Boolean>() | |
| val tester = TakeWhenObservable(src = src, | |
| whenSrc = whenSrc) | |
| .test() |
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
| // Activity or Fragment | |
| private val mResumeSignal = PublishSubject.create<Boolean>() | |
| private val mResultSignal = PublishSubject.create<Any>() | |
| override void onResume() { | |
| super.onResume(); | |
| mResumeSignal.onNext(true); | |
| } |