|
|
|
|
@ -1,12 +1,14 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.activity.components |
|
|
|
|
|
|
|
|
|
import android.Manifest |
|
|
|
|
import android.Manifest.permission.ACCESS_FINE_LOCATION |
|
|
|
|
import android.content.pm.PackageManager |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.os.PersistableBundle |
|
|
|
|
import android.view.MenuItem |
|
|
|
|
import androidx.appcompat.app.AppCompatActivity |
|
|
|
|
import androidx.core.app.ActivityCompat |
|
|
|
|
import androidx.core.content.ContextCompat |
|
|
|
|
import com.crashlytics.android.Crashlytics |
|
|
|
|
import com.google.android.libraries.places.api.model.PlaceLikelihood |
|
|
|
|
import io.realm.Realm |
|
|
|
|
import net.pokeranalytics.android.model.realm.Location |
|
|
|
|
@ -24,12 +26,36 @@ open class PokerAnalyticsActivity : AppCompatActivity() { |
|
|
|
|
private var realm: Realm? = null |
|
|
|
|
private var permissionCallback: ((granted: Boolean) -> Unit)? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Lifecycle |
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { |
|
|
|
|
super.onCreate(savedInstanceState, persistentState) |
|
|
|
|
Crashlytics.log("$this.localClassName onCreate") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
|
super.onResume() |
|
|
|
|
Crashlytics.log("$this.localClassName onResume") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onPause() { |
|
|
|
|
super.onPause() |
|
|
|
|
Crashlytics.log("$this.localClassName onPause") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
|
super.onDestroy() |
|
|
|
|
Crashlytics.log("$this.localClassName onDestroy") |
|
|
|
|
this.realm?.close() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { |
|
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults) |
|
|
|
|
|
|
|
|
|
when (requestCode) { |
|
|
|
|
PERMISSION_REQUEST_ACCESS_FINE_LOCATION -> { |
|
|
|
|
if (permissions.isNotEmpty() && permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION |
|
|
|
|
if (permissions.isNotEmpty() && permissions[0] == ACCESS_FINE_LOCATION |
|
|
|
|
&& grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED |
|
|
|
|
) { |
|
|
|
|
permissionCallback?.invoke(true) |
|
|
|
|
@ -53,11 +79,6 @@ open class PokerAnalyticsActivity : AppCompatActivity() { |
|
|
|
|
return super.onOptionsItemSelected(item) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
|
super.onDestroy() |
|
|
|
|
this.realm?.close() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the realm instance |
|
|
|
|
*/ |
|
|
|
|
|