Depracated - use Anko by jetbrains
A collection of Kotlin extensions for Android, based on KotlinAndroidLib and Android Kotlin Extensions.
| fun print(body: (Int, Int) -> Int) { | |
| println(body(5, 5)) | |
| } | |
| print({a,b-> a}) |
| public final void print(@NotNull Function2 body) { | |
| Intrinsics.checkParameterIsNotNull(body, "body"); | |
| Object result = body.invoke(1,2); //result 값은 1 | |
| System.out.println(result); | |
| } |
| private fun printResult(body: (Int, Int) -> Int) { | |
| println(body(10, 5)) | |
| } | |
| fun sum(a: Int, b: Int) = a + b | |
| fun subtract(a: Int, b: Int) = a - b | |
| printResult(::sum) //result = 15 | |
| printResult(::minus) //result 5 |
| import com.amazonaws.auth.profile.internal.{BasicProfile, ProfileStaticCredentialsProvider} | |
| import com.amazonaws.auth.profile.{ProfileCredentialsProvider, ProfilesConfigFile} | |
| import com.amazonaws.auth.{AWSCredentials, AWSCredentialsProvider, AWSStaticCredentialsProvider, BasicSessionCredentials, DefaultAWSCredentialsProviderChain} | |
| import com.amazonaws.services.s3.AmazonS3ClientBuilder | |
| import com.amazonaws.services.securitytoken.model.{AssumeRoleRequest, GetSessionTokenRequest} | |
| import com.amazonaws.services.securitytoken.{AWSSecurityTokenServiceClient, AWSSecurityTokenServiceClientBuilder} | |
| import scala.collection.JavaConversions._ | |
| object STSTesting { |
| // Added by Ben Yanke | |
| // from https://gist.github.com/benyanke/862e446e5a816551928d8acc2d98b752 | |
| console.log('Loading function'); | |
| const https = require('https'); | |
| const url = require('url'); | |
| // SETUP | |
| // urlToUse = in this environment variable, place the name of another environment variable which contains the key. | |
| // This allows easy dev/prod switching. |
| apply plugin: 'android' | |
| android { | |
| compileSdkVersion 19 | |
| buildToolsVersion "19.0.3" | |
| defaultConfig { | |
| minSdkVersion 14 | |
| targetSdkVersion 19 | |
| versionCode 23 |
| /** | |
| * ANY | |
| */ | |
| fun Any.toJson(): String = GsonInitializer.toJson(this) | |
| /** | |
| * VIEW | |
| */ | |
| fun View.toggleVisibility(setAsVisible: Boolean) = if (setAsVisible) this.visible() else this.gone() |
Depracated - use Anko by jetbrains
A collection of Kotlin extensions for Android, based on KotlinAndroidLib and Android Kotlin Extensions.
| service: service-name | |
| provider: | |
| name: aws | |
| runtime: nodejs6.10 | |
| functions: | |
| myfunc: | |
| handler: handler.myfunc |
| class AnkoViewHolder<out V : AnkoComponent<ViewGroup>>(val parent: ViewGroup, val createUI: () -> V) { | |
| class ViewHolder<out V : AnkoComponent<ViewGroup>>(val view: View, val ui: V) : RecyclerView.ViewHolder(view) | |
| val ankoContext by lazy { AnkoContext.createReusable(parent.context, parent) } | |
| val viewHolder by lazy { | |
| val ui = createUI() | |
| val view = ui.createView(ankoContext) | |
| view.setupTapEffectForBG(true) // default for every item in application | |
| // TODO some items may be disabled... | |
| ViewHolder(view, ui) |