@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.LayoutInflater
import android.view.View
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fragment_import.*
import kotlinx.android.synthetic.main.fragment_import.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.GlobalScope
@ -15,6 +16,7 @@ import net.pokeranalytics.android.util.csv.CSVImporter
import net.pokeranalytics.android.util.csv.ImportDelegate
import net.pokeranalytics.android.util.csv.ImportDelegate
import net.pokeranalytics.android.util.csv.ImportException
import net.pokeranalytics.android.util.csv.ImportException
import timber.log.Timber
import timber.log.Timber
import java.io.IOException
import java.io.InputStream
import java.io.InputStream
import java.text.NumberFormat
import java.text.NumberFormat
import java.util.*
import java.util.*
@ -74,6 +76,8 @@ class ImportFragment : RealmFragment(), ImportDelegate {
this . importer = CSVImporter ( inputStream )
this . importer = CSVImporter ( inputStream )
this . importer . delegate = this
this . importer . delegate = this
var error = false
GlobalScope . launch ( coroutineContext ) {
GlobalScope . launch ( coroutineContext ) {
val test = GlobalScope . async {
val test = GlobalScope . async {
@ -84,6 +88,9 @@ class ImportFragment : RealmFragment(), ImportDelegate {
importer . start ( )
importer . start ( )
} catch ( e : ImportException ) {
} catch ( e : ImportException ) {
// shouldDismissActivity = true
// shouldDismissActivity = true
error = true
} catch ( e : IOException ) {
error = true
}
}
val e = Date ( )
val e = Date ( )
val duration = ( e . time - s . time ) / 1000.0
val duration = ( e . time - s . time ) / 1000.0
@ -92,6 +99,12 @@ class ImportFragment : RealmFragment(), ImportDelegate {
}
}
test . await ( )
test . await ( )
if ( error && view != null ) {
Snackbar . make ( view !! , R . string . import _error , Snackbar . LENGTH _INDEFINITE ) . show ( )
}
// if (shouldDismissActivity) {
// if (shouldDismissActivity) {
//
//
// activity?.let {
// activity?.let {