Skip to content

Commit

Permalink
[#3872] Remove set and get navigation results (#3876)
Browse files Browse the repository at this point in the history
* [#3869] Remove SelectCurrencyFragment navigation result logic

* [#3870] Remove CurrenciesFragment navigation result logic

* [#3871] Remove CalculatorFragment navigation result logic

* [#3872] Remove set and get navigation results
  • Loading branch information
mustafaozhan authored Sep 8, 2024
1 parent a88d1be commit 6bde618
Showing 1 changed file with 0 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import androidx.core.content.ContextCompat
import androidx.core.view.children
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import co.touchlab.kermit.Logger
import com.github.submob.scopemob.castTo
import com.oztechan.ccc.android.core.ad.AdManager
import com.oztechan.ccc.android.core.ad.BannerAdView
Expand Down Expand Up @@ -73,32 +70,6 @@ fun View.animateHeight(startHeight: Int, endHeight: Int) {
startAnimation(animation)
}

fun <T> Fragment.getNavigationResult(
key: String,
destinationId: Int
) = try {
findNavController()
.currentBackStackEntry
?.savedStateHandle
?.getLiveData<T>(key)
} catch (e: IllegalArgumentException) {
Logger.e(e) { "$destinationId is not found in the backstack when getting navigation result for key $key" }
null
}

fun <T> Fragment.setNavigationResult(
destinationId: Int,
result: T,
key: String
) = try {
findNavController()
.previousBackStackEntry
?.savedStateHandle
?.set(key, result)
} catch (e: IllegalArgumentException) {
Logger.e(e) { "$destinationId is not found in the backstack when setting navigation result for key $key" }
}

fun View?.visibleIf(visible: Boolean, bringFront: Boolean = false) = this?.apply {
if (visible) {
isVisible = true
Expand Down

0 comments on commit 6bde618

Please sign in to comment.