This file contains 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
data object Age { | |
private const val default : Int = 0 | |
fun printDefaultAge(): Int { | |
return default | |
} | |
} |
This file contains 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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
println(User.Name) | |
println(User.Age) | |
} | |
} |
This file contains 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
kotlinOptions { | |
jvmTarget = '1.8' | |
languageVersion = '1.8' | |
} |
This file contains 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
'org.jetbrains.kotlin.android' version '1.7.20' |
This file contains 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
class CustomBackgroundThread : Thread() { | |
private var handler: Handler? = null | |
override fun run() { | |
super.run() | |
Looper.prepare() // Prepare the looper and associate with current thread | |
handler = Handler() | |
Looper.loop() // Start the thread so that it can keep the thread active | |
} |
This file contains 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
class HandlerOne(handlerTag: String) : HandlerThread(handlerTag) { | |
private lateinit var handler : Handler | |
init { | |
start() | |
handler = Handler(looper) | |
} | |
fun execute( runnable: Runnable) : HandlerOne { |
This file contains 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
class CustomRunnableOne : Runnable { | |
override fun run() { | |
try { | |
val TAG_ONE = "one" | |
for (i in 0 until 5) { | |
Thread.sleep(500L) | |
println(TAG_NARUTO.plus("--$i--").plus("Current Runnable-->$TAG_ONE")) | |
} | |
}catch (ex:InterruptedException){ |
This file contains 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
class CustomThreadOne : Thread() { | |
override fun run() { | |
try { | |
val TAG_ONE = "one" | |
for (i in 0 until 5) { | |
Thread.sleep(500L) | |
println(TAG_SASUKE.plus("--$i--").plus(name).plus("--").plus(TAG_ONE)) | |
} | |
}catch (ex:InterruptedException){ | |
println(TAG_SASUKE.plus("--").plus("Thread named").plus("--").plus(name).plus("--").plus("is interrupted")) |
This file contains 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
sealed class Animal { | |
object Cat : Animal() // We can define a Object classes like this | |
data class Dog(val name: String) : Animal() // We can define data classes like this | |
} |
This file contains 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
data class FakeUser( | |
override val id: String = "", | |
override val firstName: String = "", | |
override val lastName: String = "", | |
override val email: String = "", | |
override val image: String = "", | |
override val mobile: Long = 0, | |
override val gender: String = "", | |
override val profileCompleted: Int = 0 | |
) : UserAbstract(id,firstName,lastName,email,image,mobile,gender,profileCompleted) |