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 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 |
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
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 |
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
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 |
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
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 | |
} |
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 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>>() |
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
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 |
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
package com.sands.android.view.activity | |
import android.annotation.SuppressLint | |
import android.app.Activity | |
import android.content.res.Configuration | |
import android.net.Uri | |
import android.os.AsyncTask | |
import android.os.Bundle | |
import android.os.Handler |
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
package com.sands.android.view.adapter | |
import android.content.Context | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.core.content.ContextCompat | |
import androidx.recyclerview.widget.RecyclerView | |
import com.sands.android.R | |
import com.sands.android.dao.entity.SubtitleColorModel |
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
// private var currentTitle: String = "" | |
// private var currentUrl: String = "" | |
private var periodicJob: Job? = null | |
private var service: DownloadService? = null | |
private var bound: Boolean = false | |
private val TAG = "DownloadActivity" | |
private lateinit var runningAdapter: AdapterRunningDownload | |
private lateinit var historyAdapter: AdapterHistoryDownload | |
private lateinit var downloadCompletedReceiver: BroadcastReceiver | |
private var isCursorOpen = true |
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
package com.sands.android.view.activity | |
import android.Manifest | |
import android.annotation.SuppressLint | |
import android.app.DownloadManager | |
import android.content.BroadcastReceiver | |
import android.content.Context | |
import android.content.pm.PackageManager | |
import android.database.Cursor | |
import android.net.Uri |
NewerOlder