Skip to content

Instantly share code, notes, and snippets.

View sajjadyousefnia's full-sized avatar
🤒
Out sick

Sajjad Yousefnia sajjadyousefnia

🤒
Out sick
View GitHub Profile
package com.sajjady.recorder.Socket
import android.annotation.SuppressLint
import android.content.Context
import android.media.AudioFormat
import android.media.AudioRecord
import android.media.MediaCodec
import android.media.MediaFormat
import android.media.MediaRecorder
import io.socket.client.Socket
package com.owl.Owl
import android.annotation.SuppressLint
import android.content.Context
import android.media.*
import io.socket.client.IO
import io.socket.client.Socket
import java.net.URI
import kotlin.concurrent.thread
import kotlin.experimental.or
@Composable
public fun DualSwitch(selection: Int) {
CardContainer {
Box {
val scope = rememberCoroutineScope()
val selection = remember {
mutableIntStateOf(selection)
}
fun Modifier.animatePlacement(): Modifier = composed {
val scope = rememberCoroutineScope()
var targetOffset by remember { mutableStateOf(IntOffset.Zero) }
var animatable by remember {
mutableStateOf<Animatable<IntOffset, AnimationVector2D>?>(null)
}
this
// 🔥 onPlaced should be before offset Modifier
.onPlaced {
// Calculate the position in the parent layout
class AlarmService : Service() {
val TAG = "AlarmService"
private val INTERVAL_TIME = 60L * 1000L
private val messenger = Messenger(IncomingHandler())
private val binder = LocalBinder()
override fun onBind(intent: Intent?): IBinder? {
return binder
package com.sajjady.sleepbehavior
import android.app.AlarmManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.PowerManager
import android.content.Context
import android.content.Intent
import android.os.PowerManager
import android.provider.Settings
import android.net.Uri
fun requestIgnoreBatteryOptimizations(context: Context) {
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
val packageName = context.packageName
fun calculateDownloadSpeed(
oldBytes: Long, newBytes: Long, oldTimeMillis: Long, newTimeMillis: Long
): Double {
val downloadedBytes = newBytes - oldBytes
val timeSeconds = (newTimeMillis - oldTimeMillis) / 1000.0
val speedBytesPerSecond = downloadedBytes / timeSeconds
return speedBytesPerSecond / 1_048_576 // Convert to megabytes per second
}
class DownloadService : Service() {
private val runningDownloadList = mutableListOf<DownloadModel>()
private var onServiceChangeListener: OnServiceChangeListener? = null
private val TAG = "DownloadService"
private val messenger = Messenger(IncomingHandler())
private val binder = LocalBinder()
// private val notificationList = mutableListOf<Pair<Long, NotificationCompat.Builder>>()
package com.sands.android.Service
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.Service
import android.content.Context
import android.os.Handler
import android.os.Message