mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-26 14:10:23 +00:00
WIP
This commit is contained in:
parent
3ce1d1c719
commit
e676517e13
3 changed files with 12 additions and 4 deletions
|
@ -80,6 +80,8 @@ class OfflineItemManager(downloadRefs: List<Long>?) {
|
|||
val statusText: ObservableField<String> = ObservableField()
|
||||
val currentBytes: ObservableField<Int> = ObservableField()
|
||||
val totalBytes: ObservableField<Int> = ObservableField()
|
||||
val done: Boolean
|
||||
get() { return statusText.get() == "Successful"}
|
||||
|
||||
init {
|
||||
this.statusText.set(status)
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.arch.lifecycle.LiveData
|
|||
import android.arch.lifecycle.MutableLiveData
|
||||
import android.arch.lifecycle.ViewModel
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteConstraintException
|
||||
import android.net.Uri
|
||||
import android.os.Environment
|
||||
import android.util.Log
|
||||
|
@ -79,9 +80,13 @@ class DetailsViewModel(
|
|||
Log.d(TAG, "download started $downloadReference")
|
||||
|
||||
Completable.fromAction {
|
||||
database.offlineEventDao().insert(
|
||||
OfflineEvent(eventId = event.eventId, recordingId = recording.recordingId,
|
||||
localPath = getDownloadDir() + recording.filename, downloadReference = downloadReference))
|
||||
try {
|
||||
database.offlineEventDao().insert(
|
||||
OfflineEvent(eventId = event.eventId, recordingId = recording.recordingId,
|
||||
localPath = getDownloadDir() + recording.filename, downloadReference = downloadReference))
|
||||
} catch (ex: SQLiteConstraintException){
|
||||
Log.d(TAG,ex.message)
|
||||
}
|
||||
result.postValue(true)
|
||||
}.subscribeOn(Schedulers.io()).subscribe()
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<data>
|
||||
|
||||
<import type="de.nicidienase.chaosflix.touch.OfflineItemManager.DownloadStatus"/>
|
||||
|
||||
<import type="de.nicidienase.chaosflix.common.entities.recording.persistence.PersistentEvent"/>
|
||||
<import type="android.view.View"/>
|
||||
|
||||
<variable
|
||||
name="downloadStatus"
|
||||
|
@ -96,6 +96,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@drawable/button_rect_normal"
|
||||
app:srcCompat="@drawable/ic_delete_dark"/>
|
||||
<!--android:visibility="@{downloadStatus.done ? View.VISIBLE : View.INVISIBLE }"-->
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
|
|
Loading…
Reference in a new issue