Skip to content

Instantly share code, notes, and snippets.

class TestThread:Thread(){
override fun run() {
Thread.sleep(10000)
}
}
val myThread = TestThread()
myThread.start()
myThread.interrupt()
package com.henrykvdb.tttremote
import android.annotation.SuppressLint
import android.app.Activity
import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.util.Log
import android.view.GestureDetector
import android.view.MotionEvent
import android.widget.ImageView
private fun updateLayout() {
//Clear layout
devicesLayout.removeAllViews()
//Add all the devices
if (devices.size > 0) {
for (device in devices) {
devicesLayout.addView(TextView(this).apply {
text = device.name + "\n" + device.address
setTextSize(TypedValue.COMPLEX_UNIT_SP, 18f)
while (true)
{
board = board.copy();
List<Byte> moves = board.availableMoves();
Byte move = moves.get(rand.nextInt(moves.size()));
board.play(move);
if (firstChoice == null)
firstChoice = board;
val deviceInfo = ("\n /** please do not remove this block, technical info: "
+ "os version: ${System.getProperty("os.version")}(${android.os.Build.VERSION.INCREMENTAL})"
+ ", API: ${android.os.Build.VERSION.SDK_INT}"
+ try {
", app version: ${packageManager.getPackageInfo(packageName, 0).versionName}"
} catch (e: PackageManager.NameNotFoundException) {
""
} + "**/")
var deviceInfo = ("\n /** please do not remove this block, technical info: "
+ "os version: ${System.getProperty("os.version")}(${android.os.Build.VERSION.INCREMENTAL})"
+ ", API: ${android.os.Build.VERSION.SDK_INT}")
try {
val pInfo = packageManager.getPackageInfo(packageName, 0)
deviceInfo += ", app version: ${pInfo.versionName}"
} catch (e: PackageManager.NameNotFoundException) {
//Add nothing
}
deviceInfo += "**/"
class LinkView(context: Context, attrs: AttributeSet) : TextView(context, attrs) {
init {
movementMethod = LinkMovementMethod.getInstance()
text = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) Html.fromHtml(text.toString())
else Html.fromHtml(text.toString(), Html.FROM_HTML_MODE_LEGACY)
}
}
enum class RemoteMessage(val index:Int) {
UNDO(0),
SETUP(1),
BOARD_UPDATE(2);
companion object{
fun fromIndex(index:Int): RemoteMessage {
RemoteMessage.values().filter { it.index == index }.forEach { return it }
throw IllegalArgumentException("$index is not a valid RemoteMessage")
}
@henrykvdb
henrykvdb / Broken.txt
Created November 28, 2017 07:51
Broken and working build.gradle's
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.2-M1'
repositories {
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2' }
mavenCentral()
maven {url "https://plugins.gradle.org/m2/"}
}
293,236,176,162,112,72,51,50,50,49,48,48,47,44,41,39,39,38,37,37,36,35,35,34,33,30,29,29,28,27,26,26,26,26,26,25,25,25,25,24,24,24,24,24,24,23,23,23,22,22,21,21,20,20,20,19,19,19,19,19,19,19,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,