[update] New Icon& UI Theme
This commit is contained in:
@@ -69,8 +69,8 @@ class TransmissionScreenViewModel @Inject constructor(
|
||||
val existing = idToState[download.id]
|
||||
if (existing != null) {
|
||||
// update fields in-place -> minimal recomposition
|
||||
existing.filePath = download.file ?: existing.filePath
|
||||
existing.fileName = try { File(existing.filePath).name } catch (_: Exception) { existing.fileName }
|
||||
existing.filePath = download.file
|
||||
existing.fileName = download.request.extras.getString("name", "")
|
||||
existing.url = download.url
|
||||
existing.progress = download.progress
|
||||
existing.status = download.status
|
||||
@@ -97,11 +97,11 @@ class TransmissionScreenViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
private fun downloadToState(download: Download): DownloadItemState {
|
||||
val filePath = download.file ?: ""
|
||||
val fileName = try { File(filePath).name } catch (_: Exception) { filePath }
|
||||
val filePath = download.file
|
||||
|
||||
return DownloadItemState(
|
||||
id = download.id,
|
||||
fileName = fileName,
|
||||
fileName = download.request.extras.getString("name", ""),
|
||||
filePath = filePath,
|
||||
url = download.url,
|
||||
progress = download.progress,
|
||||
|
||||
@@ -11,6 +11,7 @@ import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import coil3.ImageLoader
|
||||
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
||||
@@ -18,14 +19,20 @@ import com.acitelight.aether.dataStore
|
||||
import com.acitelight.aether.helper.insertInNaturalOrder
|
||||
import com.acitelight.aether.model.Video
|
||||
import com.acitelight.aether.service.ApiClient.createOkHttp
|
||||
import com.acitelight.aether.service.FetchManager
|
||||
import com.acitelight.aether.service.MediaManager
|
||||
import com.acitelight.aether.service.MediaManager.queryVideoKlasses
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
class VideoScreenViewModel(application: Application) : AndroidViewModel(application)
|
||||
@HiltViewModel
|
||||
class VideoScreenViewModel @Inject constructor(
|
||||
private val fetchManager: FetchManager
|
||||
) : ViewModel()
|
||||
{
|
||||
private val _tabIndex = mutableIntStateOf(0)
|
||||
val tabIndex: State<Int> = _tabIndex
|
||||
@@ -83,6 +90,11 @@ class VideoScreenViewModel(application: Application) : AndroidViewModel(applicat
|
||||
}
|
||||
}
|
||||
|
||||
fun download(video :Video)
|
||||
{
|
||||
fetchManager.startVideoDownload(video)
|
||||
}
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
init()
|
||||
|
||||
Reference in New Issue
Block a user