Receiver vs. return value:
Returns block result | Returns receiver | |
---|---|---|
Receiver available as it |
let |
also |
Receiver available as this |
run |
apply |
How to read the table:
<!-- You can change the parent around to whatever you normally use --> | |
<style name="DebugColors" parent="Theme.AppCompat"> | |
<!-- System colors --> | |
<item name="android:windowBackground">@color/__debugWindowBackground</item> | |
<item name="android:colorPressedHighlight">#FF4400</item> | |
<item name="android:colorLongPressedHighlight">#FF0044</item> | |
<item name="android:colorFocusedHighlight">#44FF00</item> | |
<item name="android:colorActivatedHighlight">#00FF44</item> |
/** | |
* Show the activity over the lockscreen and wake up the device. If you launched the app manually | |
* both of these conditions are already true. If you deployed from the IDE, however, this will | |
* save you from hundreds of power button presses and pattern swiping per day! | |
*/ | |
public static void riseAndShine(Activity activity) { | |
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED); | |
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE); | |
PowerManager.WakeLock lock = |
import android.graphics.Rect; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; | |
public class ItemDecoration extends RecyclerView.ItemDecoration { | |
/** | |
* | |
* {@link #startPadding} and {@link #endPadding} are final and required on initialization | |
* because {@link android.support.v7.widget.RecyclerView.ItemDecoration} are drawn |
Receiver vs. return value:
Returns block result | Returns receiver | |
---|---|---|
Receiver available as it |
let |
also |
Receiver available as this |
run |
apply |
How to read the table:
import android.arch.lifecycle.GenericLifecycleObserver | |
import android.arch.lifecycle.Lifecycle | |
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY | |
import android.arch.lifecycle.LifecycleOwner | |
import kotlinx.coroutines.experimental.CoroutineScope | |
import kotlinx.coroutines.experimental.Dispatchers | |
import kotlinx.coroutines.experimental.Job | |
import kotlinx.coroutines.experimental.android.Main | |
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job { |
package com.zachklipp.coroutines | |
import kotlinx.coroutines.experimental.DisposableHandle | |
import kotlinx.coroutines.experimental.intrinsics.startCoroutineCancellable | |
import kotlinx.coroutines.experimental.selects.SelectClause0 | |
import kotlinx.coroutines.experimental.selects.SelectClause1 | |
import kotlinx.coroutines.experimental.selects.SelectClause2 | |
import kotlinx.coroutines.experimental.selects.SelectInstance | |
/** |
import android.content.Context | |
import android.util.Log | |
import com.android.billingclient.api.BillingClient | |
import com.android.billingclient.api.BillingClientStateListener | |
import com.android.billingclient.api.Purchase | |
import com.wacom.cloud.billing.manager.BillingManagerAliPay | |
import com.wacom.cloud.billing.manager.BillingManagerPlayStore | |
import kotlinx.coroutines.experimental.Dispatchers | |
import kotlinx.coroutines.experimental.withContext | |
import kotlin.coroutines.experimental.suspendCoroutine |
/* Copyright 2019 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, |
package i_love_companion_objects | |
suspend fun main() { | |
// Discoverability is easy with the companion object | |
// (although autocomplete could use some performance improvements...) | |
doStuff(SomeInterface.createWithDefaults()) | |
val someInstance: SomeInterface = SomeInterface.create( | |
parameterOne = 0, | |
parameterTwo = 1 | |
) |