Skip to content

Commit

Permalink
Avoid crash when application is leaving and you try to dissmiss a dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdamiano committed Mar 26, 2018
1 parent 4fa825c commit bbf1dec
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mainActivity/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sierrawireless.avphone"
android:versionCode="47">
android:versionCode="48">

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.text.Html
import android.view.View
import android.widget.TextView
import com.sierrawireless.avphone.R
import com.sierrawireless.avphone.activity.MainActivity

class ProgressDeleteSystemTask internal constructor(systemClient: ISystemClient, userClient: IUserClient, private val alertRuleClient: IAlertRuleClient, context: Context) : DeleteSystemTask(systemClient, userClient, alertRuleClient, context) {

Expand Down Expand Up @@ -66,8 +67,16 @@ class ProgressDeleteSystemTask internal constructor(systemClient: ISystemClient,
}

override fun onPostExecute(result: DeleteSystemResult) {
if (dialog!!.isShowing) {
dialog!!.dismiss()
if (!MainActivity.instance.isFinishing && !MainActivity.instance.isDestroyed) {
try {
if (dialog != null && dialog!!.isShowing) {
dialog!!.dismiss()
}
} catch (e: IllegalArgumentException) {
} catch (e: Exception) {
} finally {
dialog = null
}
}
super.onPostExecute(result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.support.v4.content.ContextCompat
import android.view.View
import android.widget.TextView
import com.sierrawireless.avphone.R
import com.sierrawireless.avphone.activity.MainActivity

class ProgressGetUserTask internal constructor(userClient: IUserClient, context: Context) : GetUserTask(userClient, context) {

Expand Down Expand Up @@ -50,8 +51,16 @@ class ProgressGetUserTask internal constructor(userClient: IUserClient, context:


override fun onPostExecute(result: GetUserResult) {
if (dialog!!.isShowing) {
dialog!!.dismiss()
if (!MainActivity.instance.isFinishing && !MainActivity.instance.isDestroyed) {
try {
if (dialog != null && dialog!!.isShowing) {
dialog!!.dismiss()
}
} catch (e: IllegalArgumentException) {
} catch (e: Exception) {
} finally {
dialog = null
}
}
super.onPostExecute(result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.text.Html
import android.view.View
import android.widget.TextView
import com.sierrawireless.avphone.R
import com.sierrawireless.avphone.activity.MainActivity

class ProgressSyncWithAvTask internal constructor(applicationClient: IApplicationClient, systemClient: ISystemClient,
alertRuleClient: IAlertRuleClient, userClient: IUserClient, context: Context) : SyncWithAvTask(applicationClient, systemClient, alertRuleClient, userClient, context) {
Expand Down Expand Up @@ -64,8 +65,16 @@ class ProgressSyncWithAvTask internal constructor(applicationClient: IApplicatio
}

override fun onPostExecute(result: SyncWithAvResult) {
if (dialog!!.isShowing) {
dialog!!.dismiss()
if (!MainActivity.instance.isFinishing && !MainActivity.instance.isDestroyed) {
try {
if (dialog != null && dialog!!.isShowing) {
dialog!!.dismiss()
}
} catch (e: IllegalArgumentException) {
} catch (e: Exception) {
} finally {
dialog = null
}
}
super.onPostExecute(result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.text.Html
import android.view.View
import android.widget.TextView
import com.sierrawireless.avphone.R
import com.sierrawireless.avphone.activity.MainActivity

class ProgressUpdateTask internal constructor(applicationClient: IApplicationClient, systemClient: ISystemClient,
alertRuleClient: IAlertRuleClient, userClient: IUserClient, context: Context) : UpdateTask(applicationClient, systemClient, alertRuleClient, userClient, context) {
Expand Down Expand Up @@ -62,8 +63,16 @@ class ProgressUpdateTask internal constructor(applicationClient: IApplicationCli
}

override fun onPostExecute(result: UpdateResult) {
if (dialog!!.isShowing) {
dialog!!.dismiss()
if (!MainActivity.instance.isFinishing && !MainActivity.instance.isDestroyed) {
try {
if (dialog != null && dialog!!.isShowing) {
dialog!!.dismiss()
}
} catch (e: IllegalArgumentException) {
} catch (e: Exception) {
} finally {
dialog = null
}
}
super.onPostExecute(result)
}
Expand Down

0 comments on commit bbf1dec

Please sign in to comment.