This commit is contained in:
Felix 2017-12-15 09:51:35 +01:00
parent 3ce1d1c719
commit e676517e13
3 changed files with 12 additions and 4 deletions

View file

@ -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)

View file

@ -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()
}

View file

@ -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