Updated on 2026-08-14
This commit is contained in:
commit
5d47ec3286
3 changed files with 20 additions and 19 deletions
|
|
@ -58,11 +58,17 @@ abstract class BaseFragment : Fragment() {
|
|||
Log.d("LIFECYCLE", "onDestroy: ${this::class.java.simpleName}")
|
||||
}
|
||||
|
||||
protected fun navigateUp(@IdRes destination: Int = DESTINATION_NOT_SET): Boolean {
|
||||
return if (destination == DESTINATION_NOT_SET) {
|
||||
findNavController(this).popBackStack()
|
||||
} else {
|
||||
findNavController(this).popBackStack(destination, false)
|
||||
protected fun navigateUp(@IdRes destination: Int = DESTINATION_NOT_SET) {
|
||||
try {
|
||||
if (destination == DESTINATION_NOT_SET) {
|
||||
findNavController(this).popBackStack()
|
||||
} else {
|
||||
findNavController(this).popBackStack(destination, false)
|
||||
}
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.w(this::class.java.simpleName, e.message)
|
||||
} catch (e: IllegalStateException) {
|
||||
Log.w(this::class.java.simpleName, e.message)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +90,7 @@ abstract class BaseFragment : Fragment() {
|
|||
}
|
||||
|
||||
protected fun navigateBackWithResult(resultCode: Int, data: Bundle? = null,
|
||||
@IdRes destination: Int = DESTINATION_NOT_SET): Boolean {
|
||||
@IdRes destination: Int = DESTINATION_NOT_SET) {
|
||||
(requireActivity() as MainActivity).viewModel.navigationResult =
|
||||
NavigationResult(requestCode, resultCode, data)
|
||||
return navigateUp(destination)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import android.nfc.Tag
|
|||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.tangem.App
|
||||
|
|
@ -89,11 +88,6 @@ class ValidateIdFragment : BaseFragment(), NavigationResultListener,
|
|||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
signTransactionTask?.cancel(true)
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onNavigationResult(requestCode: String, resultCode: Int, data: Bundle?) {
|
||||
if (requestCode == Constant.REQUEST_CODE_SEND_TRANSACTION_) {
|
||||
navigateBackWithResult(resultCode, data)
|
||||
|
|
@ -262,7 +256,10 @@ class ValidateIdFragment : BaseFragment(), NavigationResultListener,
|
|||
NoExtendedLengthSupportDialog().show(requireFragmentManager(), NoExtendedLengthSupportDialog.TAG)
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(context, R.string.general_notification_scan_again, Toast.LENGTH_LONG).show()
|
||||
(activity as MainActivity).toastHelper.showSingleToast(
|
||||
context,
|
||||
getString(R.string.general_notification_scan_again)
|
||||
)
|
||||
}
|
||||
progressBar?.progress = 100
|
||||
progressBar?.progressTintList = ColorStateList.valueOf(Color.RED)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import android.nfc.Tag
|
|||
import android.nfc.tech.IsoDep
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.tangem.App
|
||||
|
|
@ -49,7 +48,6 @@ class WriteIdFragment : BaseFragment(), NavigationResultListener,
|
|||
private lateinit var ctx: TangemContext
|
||||
private lateinit var tx: ByteArray
|
||||
private lateinit var mpFinishSignSound: MediaPlayer
|
||||
private var toast: Toast? = null
|
||||
|
||||
private var idWasWritten = false
|
||||
|
||||
|
|
@ -94,7 +92,6 @@ class WriteIdFragment : BaseFragment(), NavigationResultListener,
|
|||
|
||||
override fun onStop() {
|
||||
writeIDCardTask?.cancel(true)
|
||||
toast?.cancel()
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +171,6 @@ class WriteIdFragment : BaseFragment(), NavigationResultListener,
|
|||
if (success) {
|
||||
navigateUp(R.id.main)
|
||||
} else {
|
||||
toast?.cancel()
|
||||
navigateUp(R.id.issueNewIdFragment)
|
||||
}
|
||||
}
|
||||
|
|
@ -231,8 +227,10 @@ class WriteIdFragment : BaseFragment(), NavigationResultListener,
|
|||
}
|
||||
} else {
|
||||
if (!idWasWritten) {
|
||||
toast = Toast.makeText(context, R.string.general_notification_scan_again, Toast.LENGTH_SHORT)
|
||||
toast?.show()
|
||||
(activity as MainActivity).toastHelper.showSingleToast(
|
||||
context,
|
||||
getString(R.string.general_notification_scan_again)
|
||||
)
|
||||
}
|
||||
}
|
||||
progressBar?.progress = 100
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue