Skip to content

Instantly share code, notes, and snippets.

View kingori's full-sized avatar

Sewon Ann kingori

View GitHub Profile
package com.example.myapplication
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
import java.io.Serializable
class MainActivity : AppCompatActivity() {
@kingori
kingori / DataObjCopy.kt
Last active August 28, 2018 08:51
kotlin data class copy by reflection
import org.junit.Assert
import org.junit.Test
import kotlin.reflect.KProperty
class DataClassTest {
@Test
fun copyObj() {
val data= Data1(1, "b", Value(3))
@kingori
kingori / ConstraintLayout.xml
Last active April 20, 2022 08:43
Live template for ConstraintLayout xml attributes for Android
<templateSet group="ConstraintLayout">
<template name="cbb" value="app:layout_constraintBottom_toBottomOf=&quot;$cursor$&quot;" description="constraint bottom to bottom of id" toReformat="true" toShortenFQNames="true">
<variable name="cursor" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML" value="true" />
<option name="XML_TEXT" value="false" />
</context>
</template>
<template name="cbp" value="app:layout_constraintBottom_toBottomOf=&quot;parent&quot;" description="constraint bottom to bottom of parent" toReformat="true" toShortenFQNames="true">
<context>
@kingori
kingori / VarValTest.kt
Last active December 12, 2017 09:48
var/val override test
interface A {
val myVal: Boolean
var myVar: Boolean
}
//no problem
class B : A {
override val myVal = false
override var myVar = false
}
@kingori
kingori / RxSingleTakeUntilTest.kt
Last active December 2, 2017 12:57
RxJava Single Test
import io.reactivex.Single
import io.reactivex.exceptions.UndeliverableException
import io.reactivex.schedulers.Schedulers
import org.junit.Assert
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Test
import java.util.concurrent.CancellationException
import java.util.concurrent.CountDownLatch
import java.util.concurrent.Executors
fun main(args: Array<String>) {
fun getMap(arg1: Array<Int>, arg2: Array<Int>) =
arg1.mapIndexed { index, v -> (v or arg2[index]).toString(2) }
.map {
it.map { if (it == '1') '#' else ' ' }
.toCharArray().joinToString(prefix = "\"", postfix = "\"", separator = "")
}
println(getMap(arrayOf(9, 20, 28, 18, 11), arrayOf(30, 1, 21, 17, 28)))
println(getMap(arrayOf(46, 33, 33, 22, 31, 50), arrayOf(27, 56, 19, 14, 14, 10)))
public class WebViewActivity extends Activity {
WebView wv;
LinkedList<JsResult> jsResults = new LinkedList<>();
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wv);
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kr.pe.kingori.silgeupgum">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
@kingori
kingori / wwdc_2014_advanced_swift.md
Created July 10, 2014 17:25
WWDC 2014 advanced swift 정리

#Advanced swift ##Taking control of Syntax

텍스트 머드 기반으로 설명을 하네~

class Thing {
  init(location: Thing?, name: String,
  longDescription: String) { ... }
public void pushFragments(String tag, Fragment fragment,
boolean shouldAnimate, boolean shouldAdd) {
if (shouldAdd)
mStacks.get(tag).push(fragment);
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction ft = manager.beginTransaction();
ft.replace(R.id.realtabcontent, fragment).addToBackStack(null);
ft.commit();
}