|
|
|
@ -3,6 +3,9 @@ package net.pokeranalytics.android.util |
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.RealmResults |
|
|
|
import io.realm.RealmResults |
|
|
|
|
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import net.pokeranalytics.android.api.BackupApi |
|
|
|
import net.pokeranalytics.android.api.BackupApi |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.model.realm.Transaction |
|
|
|
import net.pokeranalytics.android.model.realm.Transaction |
|
|
|
@ -54,8 +57,10 @@ class BackupOperator(var context: Context) { |
|
|
|
val csv = ProductCSVDescriptors.pokerAnalyticsAndroid6Sessions.toCSV(sessions) |
|
|
|
val csv = ProductCSVDescriptors.pokerAnalyticsAndroid6Sessions.toCSV(sessions) |
|
|
|
val fileName = "sessions_${Date().dateTimeFileFormatted}.csv" |
|
|
|
val fileName = "sessions_${Date().dateTimeFileFormatted}.csv" |
|
|
|
|
|
|
|
|
|
|
|
if (BackupApi.backupFile(context, email, fileName, csv)) { |
|
|
|
CoroutineScope(context = Dispatchers.IO).launch { |
|
|
|
this.sessionsChanged = false |
|
|
|
if (BackupApi.backupFile(context, email, fileName, csv)) { |
|
|
|
|
|
|
|
sessionsChanged = false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -68,8 +73,11 @@ class BackupOperator(var context: Context) { |
|
|
|
val transactions = this.realm.where(Transaction::class.java).findAll().sort("date") |
|
|
|
val transactions = this.realm.where(Transaction::class.java).findAll().sort("date") |
|
|
|
val csv = ProductCSVDescriptors.pokerAnalyticsAndroidTransactions.toCSV(transactions) |
|
|
|
val csv = ProductCSVDescriptors.pokerAnalyticsAndroidTransactions.toCSV(transactions) |
|
|
|
val fileName = "transactions_${Date().dateTimeFileFormatted}.csv" |
|
|
|
val fileName = "transactions_${Date().dateTimeFileFormatted}.csv" |
|
|
|
if (BackupApi.backupFile(context, email, fileName, csv)) { |
|
|
|
|
|
|
|
this.transactionsChanged = false |
|
|
|
CoroutineScope(context = Dispatchers.IO).launch { |
|
|
|
|
|
|
|
if (BackupApi.backupFile(context, email, fileName, csv)) { |
|
|
|
|
|
|
|
transactionsChanged = false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|