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
@SuppressLint("Range")
private suspend fun downloadFromScratch() {
try {
val downloadManager = getSystemService(DownloadManager::class.java)
val request = DownloadManager.Request(currentUrl.toUri()).setMimeType("video/*")
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI and DownloadManager.Request.NETWORK_MOBILE)
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
.setTitle("در حال دانلود فیلم " + currentTitle).setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS, DOWNLOADS_SUB_DIRECTORY + currentTitle
@SuppressLint("Range")
private suspend fun downloadFromScratch() {
try {
val downloadManager = getSystemService(DownloadManager::class.java)
val request = DownloadManager.Request(currentUrl.toUri()).setMimeType("video/*")
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI and DownloadManager.Request.NETWORK_MOBILE)
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
.setTitle("در حال دانلود فیلم " + currentTitle).setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS, DOWNLOADS_SUB_DIRECTORY + currentTitle
val request = DownloadManager.Request(Uri.parse(url))
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "filename.ext")
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
val manager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
val downloadId = manager.enqueue(request)
val query = DownloadManager.Query().setFilterById(downloadId)
@Database(
entities = [MdlMovie::class, MdlLastPlay::class],
version = 16, exportSchema = false
)
@TypeConverters(Converters::class)
abstract class RoomDB : RoomDatabase() {
abstract fun appDao(): AppDao
companion object {
private var INSTANCE: RoomDB? = null
fun EditText.addThousandSeparator() {
this.addTextChangedListener(object : TextWatcher {
private var current = ""
override fun beforeTextChanged(
s: CharSequence?,
start: Int,
count: Int,
after: Int
) {
}
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import java.text.DecimalFormatSymbols
fun EditText.addThousandSeparator() {
this.addTextChangedListener(object : TextWatcher {
private var current = ""
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import java.text.DecimalFormatSymbols
fun EditText.addThousandSeparator() {
this.addTextChangedListener(object : TextWatcher {
private var current = ""
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2018 Mukesh Solanki
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.videolan.libvlc.util.VLCVideoLayout
android:id="@+id/VideoView"
android:layout_width="match_parent"
class MainViewModel : BaseViewModel<MainContract.Event, MainContract.State, MainContract.Effect>() {
/**
* Create initial State of Views
*/
override fun createInitialState(): MainContract.State {
val currentTime = Calendar.getInstance().getTime()
return MainContract.State("sajjad-agha-gole-bagha + $currentTime")
}