|
|
|
@ -4,8 +4,8 @@ import android.Manifest |
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import android.content.Intent |
|
|
|
import android.content.Intent |
|
|
|
import android.content.pm.PackageManager |
|
|
|
import android.content.pm.PackageManager |
|
|
|
|
|
|
|
import android.net.Uri |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.PersistableBundle |
|
|
|
|
|
|
|
import androidx.core.app.ActivityCompat |
|
|
|
import androidx.core.app.ActivityCompat |
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.Realm |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
@ -15,6 +15,8 @@ import timber.log.Timber |
|
|
|
|
|
|
|
|
|
|
|
class ImportActivity : PokerAnalyticsActivity() { |
|
|
|
class ImportActivity : PokerAnalyticsActivity() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lateinit var fileURI: Uri |
|
|
|
|
|
|
|
|
|
|
|
enum class IntentKey(val keyName: String) { |
|
|
|
enum class IntentKey(val keyName: String) { |
|
|
|
FILE_PATH("filepath") |
|
|
|
FILE_PATH("filepath") |
|
|
|
} |
|
|
|
} |
|
|
|
@ -35,14 +37,16 @@ class ImportActivity : PokerAnalyticsActivity() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
|
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { |
|
|
|
Timber.d("Start ImportActivity with URI: ${intent.data}") |
|
|
|
super.onCreate(savedInstanceState, persistentState) |
|
|
|
intent?.data?.let { |
|
|
|
|
|
|
|
this.fileURI = it |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.activity_import) |
|
|
|
setContentView(R.layout.activity_import) |
|
|
|
|
|
|
|
|
|
|
|
initUI() |
|
|
|
initUI() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onStop() { |
|
|
|
override fun onStop() { |
|
|
|
@ -59,11 +63,28 @@ class ImportActivity : PokerAnalyticsActivity() { |
|
|
|
val fragmentTransaction = supportFragmentManager.beginTransaction() |
|
|
|
val fragmentTransaction = supportFragmentManager.beginTransaction() |
|
|
|
val fragment = ImportFragment() |
|
|
|
val fragment = ImportFragment() |
|
|
|
|
|
|
|
|
|
|
|
val filePath = intent.getStringExtra(ImportActivity.IntentKey.FILE_PATH.keyName) |
|
|
|
val fis = contentResolver.openInputStream(fileURI) |
|
|
|
fragment.setData(filePath) |
|
|
|
Timber.d("Load fragment data with: $fis") |
|
|
|
|
|
|
|
fis?.let { |
|
|
|
|
|
|
|
fragment.setData(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// val |
|
|
|
|
|
|
|
// CSVFormat.DEFAULT.parse() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// val path = fileURI.path(contentResolver) |
|
|
|
|
|
|
|
// Timber.d("Load fragment with path: ${path}") |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val file = File(path) |
|
|
|
|
|
|
|
// Timber.d(">>>> length = ${file.length()}") |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// path?.let { filePath -> |
|
|
|
|
|
|
|
// fragment.setData(filePath) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
fragmentTransaction.add(R.id.container, fragment) |
|
|
|
fragmentTransaction.add(R.id.container, fragment) |
|
|
|
fragmentTransaction.commit() |
|
|
|
fragmentTransaction.commit() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun requestPermission() { |
|
|
|
private fun requestPermission() { |
|
|
|
@ -74,15 +95,6 @@ class ImportActivity : PokerAnalyticsActivity() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onNewIntent(intent: Intent?) { |
|
|
|
|
|
|
|
super.onNewIntent(intent) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val f = intent?.data |
|
|
|
|
|
|
|
val uri = f.toString() |
|
|
|
|
|
|
|
Timber.d("!!!Intent!!! uri = $uri") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { |
|
|
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { |
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults) |
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults) |
|
|
|
} |
|
|
|
} |
|
|
|
|