Skip to content

Instantly share code, notes, and snippets.

View babedev's full-sized avatar

Christopher Ng babedev

  • BabeDev
  • Bangkok, Thailand
View GitHub Profile
import kotlinx.cinterop.*
import hello.*
fun main(args: Array<String>) {
print(hello()?.toKString())
}
group 'com.babedev'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
#ifndef HELLO_H_
#define HELLO_H_
char * hello();
#endif
#include "hello.h"
char * hello() {
return "Hello World\n";
}
fun main(args: Array<String>) {
print("Hello Native")
}
group 'com.babedev'
version '1.0-SNAPSHOT'
buildscript {
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
}
var Hello = require('./dist/hello.js')
console.log(Hello.com.babedev.playground.greet())
Hello.com.babedev.playground.sayHello("Hello Kotlin")
package com.babedev.playground
fun greet() = "Hello"
@JsName("sayHello")
fun greet(text: String) {
console.log(text)
}
private fun generateActivity() {
val onCreate = FunSpec.builder("onCreate")
.addModifiers(KModifier.OVERRIDE, KModifier.PUBLIC)
.addParameter("savedInstanceState", Bundle::class)
.addStatement("super.onCreate(savedInstanceState)")
.addComment("TODO setContentView()")
.addStatement("mPresenter = %T()", presenterType)
.addStatement("mPresenter.attachView(this)")
.build()
@babedev
babedev / ViewExt.kt
Last active February 16, 2018 12:15
Show image with Glide and start intent with Anko
fun ImageView.show(imageUrl: String = "") {
if (imageUrl.isBlank()) return
if (context == null) return
if (context is Activity && ((context as Activity).isFinishing || (context as Activity).isDestroyed)) return
Glide.with(context)
.load(imageUrl)
.crossFade()