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
open class TextWatcherListener( | |
private val editText: EditText, | |
private val listener: EditText.(String, String, String, String) -> Unit | |
) : TextWatcher { | |
private var before: String = "" | |
private var old: String = "" | |
private var new: String = "" | |
private var after: 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
fun klog(@IntRange(from = 2, to = 6) level: Int, message: Any?) { | |
if (!BuildConfig.DEBUG) return | |
Throwable().stackTrace[1].run { | |
val tag = "commontag" | |
val fullMessage = "($fileName:$lineNumber): $message" | |
when (level) { | |
Log.VERBOSE -> Log.v(tag, fullMessage) | |
Log.DEBUG -> Log.d(tag, fullMessage) | |
Log.INFO -> Log.i(tag, fullMessage) | |
Log.WARN -> Log.w(tag, fullMessage) |
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
fun Fagment.fragmentListeners(block: FragmentListenerBuilder.() -> Unit) { | |
val builder = FragmentListenerBuilder().apply(block) | |
builder.keys.forEach { | |
val manager = if (it.value) childFragmentManager else parentFragmentManager | |
manager.setFragmentResultListener(it.key, this, builder.listener) | |
} | |
} | |
class FragmentListenerBuilder { | |
var listener: (String, Bundle) -> Unit = { _, _ -> } |