This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import androidx.lifecycle.Lifecycle | |
| import androidx.lifecycle.LifecycleObserver | |
| import androidx.lifecycle.OnLifecycleEvent | |
| import io.reactivex.disposables.CompositeDisposable | |
| import io.reactivex.subjects.BehaviorSubject | |
| import java.util.concurrent.TimeUnit | |
| class ClickUtil(lifecycle: Lifecycle, private val delay: Long = 1000L) : LifecycleObserver { | |
| private lateinit var compositeDisposable: CompositeDisposable | |
| private lateinit var clickSubject: BehaviorSubject<(() -> Unit)> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import androidx.lifecycle.Lifecycle | |
| import androidx.lifecycle.LifecycleObserver | |
| import androidx.lifecycle.OnLifecycleEvent | |
| import io.reactivex.disposables.CompositeDisposable | |
| import io.reactivex.subjects.BehaviorSubject | |
| import java.util.concurrent.TimeUnit | |
| class ClickUtil(lifecycle: Lifecycle, private val delay: Long = 1000L) : LifecycleObserver { | |
| private lateinit var compositeDisposable: CompositeDisposable | |
| private lateinit var clickSubject: BehaviorSubject<(() -> Unit)> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // in activity | |
| class SettingInFingerActivity : AppCompatActivity() { | |
| private val click by lazy { ClickUtil(this.lifecycle) } | |
| // (생략) | |
| private fun initListener() { | |
| testButton.SetOnClickListener { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // in koin module | |
| val viewModelModule = module { | |
| viewModel { MainViewModel() } | |
| } | |
| // in activity | |
| val mainViewModel by viewModel<MainViewModel>() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 확장함수 정의 | |
| fun Date.convert(): String { | |
| val diff = (Date().time - this.time) / 1000 | |
| return when (diff) { | |
| in 0 until 10 -> "지금 막" | |
| in 10 until 60 -> "${diff}초 전" | |
| in 60 until 60 * 60 -> "${diff / 60}분 전" | |
| in 60 * 60 until 60 * 60 * 24 -> "${diff / (60 * 60)}시간 전" | |
| in 60 * 60 * 24 until 60 * 60 * 48 -> "어제" | |
| in 60 * 60 * 48 until 60 * 60 * 24 * 7 -> "${diff / (60 * 60 * 24)}일 전" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package kr.co.seoft.ah | |
| import org.junit.Test | |
| import org.junit.Assert.* | |
| import java.text.SimpleDateFormat | |
| import java.util.* | |
| /** | |
| * Example local unit test, which will execute on the development machine (host). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val items = listOf("AA", "BB", "CC", "DD", "EE", "FF") | |
| val findItems = setOf("CCa", "DD") | |
| val whetherOneOrMoreFindItemInItems = items.any { it in findItems } | |
| assertEquals(true, whetherOneOrMoreFindItemInItems) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @GET("api/emptyResponse") | |
| fun getEmptyResponse(): Single<Response<Unit>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Animal(val type: String) | |
| data class Cat constructor(val age: Int) : Animal("cat") | |
| data class Dog constructor(val weight: Int) : Animal("dog") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun combineVoteItems(): List<VoteItem> { | |
| return LiveDataUtil.convertToTypeList(title, contens, optionEdit, optionMultiple, optionOverlap) ?: return emptyList() | |
| } |