Skip to content

Commit

Permalink
Suppress deprecation warning when calling overridePendingTransition
Browse files Browse the repository at this point in the history
Also docs say that it should be called after finish/startActivity, not before
  • Loading branch information
equeim committed Aug 21, 2024
1 parent 4d52e29 commit b61b5c2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/quantumbadger/redreader/common/General.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.quantumbadger.redreader.common

import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.content.DialogInterface
Expand Down Expand Up @@ -704,13 +705,18 @@ object General {

// http://stackoverflow.com/a/3419987/1526861
val intent = activity.intent
activity.overridePendingTransition(0, 0)
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
activity.finish()
activity.overridePendingTransition(0, 0)
activity.overridePendingTransitionWithNoAnimation()
activity.startActivity(intent)
activity.overridePendingTransitionWithNoAnimation()
}

@Suppress("DEPRECATION")
private fun Activity.overridePendingTransitionWithNoAnimation() {
overridePendingTransition(0, 0)
}

@JvmStatic
fun safeDismissDialog(dialog: Dialog) {
runOnUiThread {
Expand Down

0 comments on commit b61b5c2

Please sign in to comment.