Skip to content

Instantly share code, notes, and snippets.

Avatar

Sewon Ann kingori

View GitHub Profile
View MainActivity.kt
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 Aug 28, 2018
kotlin data class copy by reflection
View DataObjCopy.kt
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 Feb 22, 2021
Live template for ConstraintLayout xml attributes for Android
View ConstraintLayout.xml
<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 Dec 12, 2017
var/val override test
View VarValTest.kt
interface A {
val myVal: Boolean
var myVar: Boolean
}
//no problem
class B : A {
override val myVal = false
override var myVar = false
}
View RxSingleTakeUntilTest.kt
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
View KakaoCodeFirst.kt
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)))
View WebViewActivity.java
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);
View AndroidManifest.xml
<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 Jul 10, 2014
WWDC 2014 advanced swift 정리
View wwdc_2014_advanced_swift.md

#Advanced swift ##Taking control of Syntax

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

class Thing {
  init(location: Thing?, name: String,
  longDescription: String) { ... }
View MainActivity.java
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();
}