Use .orEmpty()
parent
3e132f102c
commit
284cbab9ea
|
@ -114,9 +114,7 @@ open class FenixApplication : Application() {
|
|||
|
||||
private fun registerRxExceptionHandling() {
|
||||
RxJavaPlugins.setErrorHandler {
|
||||
it.cause?.run {
|
||||
throw this
|
||||
} ?: throw it
|
||||
throw it.cause ?: it
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,12 +116,10 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
|||
private const val LOGTAG = "LeanplumMetricsService"
|
||||
|
||||
private val LeanplumId: String
|
||||
@Suppress("USELESS_ELVIS")
|
||||
// Debug builds have a null (nullable) LEANPLUM_ID
|
||||
get() = BuildConfig.LEANPLUM_ID ?: ""
|
||||
get() = BuildConfig.LEANPLUM_ID.orEmpty()
|
||||
private val LeanplumToken: String
|
||||
@Suppress("USELESS_ELVIS")
|
||||
// Debug builds have a null (nullable) LEANPLUM_TOKEN
|
||||
get() = BuildConfig.LEANPLUM_TOKEN ?: ""
|
||||
get() = BuildConfig.LEANPLUM_TOKEN.orEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,20 +53,17 @@ object MozillaProductDetector {
|
|||
return true
|
||||
}
|
||||
|
||||
// Returns the default browser if and only if it is a Mozilla product
|
||||
/**
|
||||
* Returns the default browser if and only if it is a Mozilla product.
|
||||
*/
|
||||
fun getMozillaBrowserDefault(context: Context): String? {
|
||||
val browserPackageName = Browsers.all(context).defaultBrowser?.packageName
|
||||
return if (isMozillaProduct(browserPackageName ?: "")) { browserPackageName } else { null }
|
||||
return if (isMozillaProduct(browserPackageName)) { browserPackageName } else { null }
|
||||
}
|
||||
|
||||
// Note: we intentionally do not use a-c `firefoxBrandedBrowser` as this only gives us the first from that list
|
||||
private fun isMozillaProduct(packageName: String): Boolean {
|
||||
for (product in MozillaProducts.values()) {
|
||||
if (product.productName == packageName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
private fun isMozillaProduct(packageName: String?): Boolean {
|
||||
packageName ?: return false
|
||||
return MozillaProducts.values().any { product -> product.productName == packageName }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ class BookmarkAdapter(val emptyView: View, val interactor: BookmarkViewInteracto
|
|||
val diffUtil = DiffUtil.calculateDiff(
|
||||
BookmarkDiffUtil(
|
||||
this.tree,
|
||||
tree?.children ?: listOf(),
|
||||
tree?.children.orEmpty(),
|
||||
this.mode,
|
||||
mode
|
||||
)
|
||||
)
|
||||
|
||||
this.tree = tree?.children ?: listOf()
|
||||
this.tree = tree?.children.orEmpty()
|
||||
isFirstRun = if (isFirstRun) false else {
|
||||
emptyView.isVisible = this.tree.isEmpty()
|
||||
false
|
||||
|
|
|
@ -83,7 +83,7 @@ class SearchFragment : Fragment(), BackHandler {
|
|||
?.let { it.showShortcutEnginePicker } ?: false
|
||||
|
||||
val view = inflater.inflate(R.layout.fragment_search, container, false)
|
||||
val url = session?.url ?: ""
|
||||
val url = session?.url.orEmpty()
|
||||
val currentSearchEngine = SearchEngineSource.Default(
|
||||
requireComponents.search.searchEngineManager.getDefaultSearchEngine(requireContext())
|
||||
)
|
||||
|
|
|
@ -116,7 +116,7 @@ class ToolbarView(
|
|||
/* Only set the search terms if pasted text is null so that the search term doesn't
|
||||
overwrite pastedText when view enters `editMode` */
|
||||
if (searchState.pastedText.isNullOrEmpty()) {
|
||||
view.setSearchTerms(searchState.session?.searchTerms ?: "")
|
||||
view.setSearchTerms(searchState.session?.searchTerms.orEmpty())
|
||||
}
|
||||
|
||||
view.editMode()
|
||||
|
|
|
@ -119,7 +119,7 @@ class ShareFragment : AppCompatDialogFragment() {
|
|||
throw IllegalStateException("URL and tabs cannot both be null.")
|
||||
}
|
||||
|
||||
val tabs = args.tabs?.toList() ?: listOf(ShareTab(args.url!!, args.title ?: ""))
|
||||
val tabs = args.tabs?.toList() ?: listOf(ShareTab(args.url!!, args.title.orEmpty()))
|
||||
val accountManager = requireComponents.backgroundServices.accountManager
|
||||
|
||||
shareInteractor = ShareInteractor(
|
||||
|
@ -167,7 +167,7 @@ class ShareFragment : AppCompatDialogFragment() {
|
|||
resolveInfo.activityInfo.packageName,
|
||||
resolveInfo.activityInfo.name
|
||||
)
|
||||
} ?: emptyList()
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
|
|
Loading…
Reference in New Issue