aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt24
1 files changed, 23 insertions, 1 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
index cc79600..bad2f8b 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
@@ -20,6 +20,8 @@ import org.pacien.tincapp.context.CrashRecorder
20 * @author pacien 20 * @author pacien
21 */ 21 */
22abstract class BaseActivity : AppCompatActivity() { 22abstract class BaseActivity : AppCompatActivity() {
23 private var active = false
24
23 override fun onCreate(savedInstanceState: Bundle?) { 25 override fun onCreate(savedInstanceState: Bundle?) {
24 super.onCreate(savedInstanceState) 26 super.onCreate(savedInstanceState)
25 setContentView(R.layout.base) 27 setContentView(R.layout.base)
@@ -31,6 +33,26 @@ abstract class BaseActivity : AppCompatActivity() {
31 return true 33 return true
32 } 34 }
33 35
36 override fun onStart() {
37 super.onStart()
38 active = true
39 }
40
41 override fun onResume() {
42 super.onResume()
43 active = true
44 }
45
46 override fun onPause() {
47 active = false
48 super.onPause()
49 }
50
51 override fun onStop() {
52 active = false
53 super.onStop()
54 }
55
34 fun aboutDialog(@Suppress("UNUSED_PARAMETER") i: MenuItem) { 56 fun aboutDialog(@Suppress("UNUSED_PARAMETER") i: MenuItem) {
35 AlertDialog.Builder(this) 57 AlertDialog.Builder(this)
36 .setTitle(BuildConfig.APPLICATION_ID) 58 .setTitle(BuildConfig.APPLICATION_ID)
@@ -44,7 +66,7 @@ abstract class BaseActivity : AppCompatActivity() {
44 } 66 }
45 67
46 fun runOnUiThread(action: () -> Unit) { 68 fun runOnUiThread(action: () -> Unit) {
47 if (!isFinishing && !isDestroyed) super.runOnUiThread(action) 69 if (active) super.runOnUiThread(action)
48 } 70 }
49 71
50 private fun handleRecentCrash() { 72 private fun handleRecentCrash() {