Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I'm grateful when for one drop in glass. Since I knw exactly what to do with it

Devrath devrath

💭
I'm grateful when for one drop in glass. Since I knw exactly what to do with it
View GitHub Profile
@devrath
devrath / ProgressTimer.kt
Last active Nov 19, 2021
Timer logic defined using the coroutines
View ProgressTimer.kt
class ProgressTimer(
private val player: Player,
private val positionListener: PositionListener,
@IoDispatcher private val ioDispatcher: CoroutineDispatcher
) {
companion object {
const val PROGRESS_TRACK_DURATION : Long = 1000
}
@devrath
devrath / ProgressJobTracker.kt
Created Nov 8, 2021
How to call the periodic callback of progress of Exo player
View ProgressJobTracker.kt
class ProgressJobTracker(
private val player: Player,
private val positionListener: PositionListener,
@IoDispatcher private val ioDispatcher: CoroutineDispatcher
) {
companion object {
const val PROGRESS_TRACK_DURATION : Long = 1000
}
@devrath
devrath / YoutubeSegmentedSeekBar.kt
Created Oct 23, 2021
Segmented seek bar for chapters in video
View YoutubeSegmentedSeekBar.kt
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatSeekBar
import androidx.core.content.ContextCompat
import com.example.code.R
enum class SeekbarElementType { PROGRESS_BAR, PROGRESS_INDICATOR, PROGRESS_DIVIDER }
View MainActivity.kt
package com.example.code.percentSeekBar
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.example.code.R
import com.example.code.percentSeekBar.PercentSeekBar
import com.example.code.percentSeekBar.ProgressItem
import java.util.ArrayList
View activityhelpersuspend.kt
class LegacyCallbackSampleTwo(
override val coroutineContext: CoroutineContext
) : CoroutineScope {
fun initiateDemo() {
launch {
val user = getUser("111")
println(user.userName)
}
}
View activitysuspent.kt
class SuspendingFuncActivity : BaseActivity() {
override fun getToolbarTitle() = "Suspending Functions"
private lateinit var binding: ActivitySuspendingFuncBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySuspendingFuncBinding.inflate(layoutInflater)
setContentView(binding.root)
View functionReturningFunction.kt
private fun simpleDemo() {
retrieveUserFromNetwork("111") {
println(it.userName)
}
}
private fun retrieveUserFromNetwork(
userId:String,
userRetrieved:(user:User) -> Unit
) {
View ImageUpload3.kt
fun main() {
println("Start")
initiateUploadingImage(service)
println("End")
}
fun initiateUploadingImage(
imageUpload:(image :String)->Boolean
) {
val result = imageUpload("/Desktop")
View ImageUpload2.kt
fun main() {
println("Start")
initiateUploadingImage(service)
println("End")
}
fun initiateUploadingImage(
imageUpload:(image :String)->Unit
) {
imageUpload("/Desktop")
View ImageUpload1.kt
fun main() {
println("Start")
initiateUploadingImage(service)
println("End")
}
fun initiateUploadingImage(
imageUpload:()->Unit
) {
imageUpload()