This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline infix fun <T> Boolean.T(trueOutput: T) = TernaryPart(this, trueOutput) | |
inline infix fun <T> TernaryPart<T>.F(falseOutput: T) = if (condition) trueOutput else falseOutput | |
class TernaryPart<T>(val condition: Boolean, val trueOutput: T) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline infix fun <T> Boolean.T(trueOutput: T) = TernaryPart(this, trueOutput) | |
inline infix fun <T> TernaryPart<T>.F(falseOutput: T) = if (condition) trueOutput else falseOutput | |
class TernaryPart<T>(val condition: Boolean, val trueOutput: T) | |
// T overload for conditional evaluation of functional arguments | |
infix fun <T> Boolean.T(trueBranch: () -> T) = TernaryPart(this, trueBranch) | |
// F overload for conditional evaluation of functional arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Tag { | |
val tag: String | |
val log: Tagger.TaggedLogger | |
} | |
open class Tagger(override val tag: String) : Tag { | |
interface TaggedLogger { | |
fun e(message: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Tag { | |
val tag: String | |
val log: Tagger.TaggedLogger | |
} | |
open class Tagger() : Tag { | |
override val tag = javaClass.enclosingClass?.simpleName ?: javaClass.simpleName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Delegate for use in fragments | |
* | |
* When the fragment's view is destroyed the field will be set to null. | |
* This happens immediately before the fragment's onDestroyView() is called. | |
* | |
* Additionally, this delegate gives the same behavior as lateinit. | |
* | |
* Property should be a non-nullable var. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var _binding: ProfileBinding? = null | |
private val binding get() = _binding!! | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View { | |
_binding = ProfileBinding.inflate(inflater, container, false) | |
return binding.root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var binding: ProfileBinding by nullOnDestroy() | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View { | |
binding = ProfileBinding.inflate(inflater, container, false) | |
return binding.root | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProfileFragment: ViewBindingFragment<ProfileBinding>(ProfileBinding::inflate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class ViewBindingFragment<T: ViewBinding>( | |
private val inflate: (LayoutInflater, ViewGroup?, Boolean) -> T | |
): Fragment() { | |
private var _binding: T? = null | |
protected val binding get() = _binding!! | |
final override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, |