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
import android.util.Log | |
fun Any?.printToLog(tag: String = "DEBUG_LOG") { | |
Log.d(tag, toString()) | |
} |
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
Dialog(context).apply { | |
setContentView(R.layout.dialog) | |
window?.setBackgroundDrawableResource(R.drawable.bg_dialog) | |
findViewById<ImageView>(R.id.ivClose).setOnClickListener { dismiss() } | |
findViewById<Button>(R.id.btnTry).setOnClickListener { dismiss() } | |
}.show() |
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
import android.text.Editable | |
import android.text.TextWatcher | |
import android.widget.EditText | |
import kotlin.math.max | |
import kotlin.math.min | |
/** | |
* Класс, предназначенный для форматирования тектового ввода в EditText | |
* @param editText поле ввода символов | |
* @param formatter метод форматирования исходной строки |
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
val ViewGroup.children: Iterable<View> | |
get() = (0 until childCount).map { getChildAt(it) } | |
// use: | |
linearLayout.children | |
.forEachIndexed { _, view -> | |
view.setOnClickListener {} | |
} |
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
public class SimpleTextWatcher implements TextWatcher { | |
private BeforeTextChanged beforeTextChanged; | |
private OnTextChanged onTextChanged; | |
private AfterTextChanged afterTextChanged; | |
public SimpleTextWatcher(BeforeTextChanged beforeTextChanged) { | |
this.beforeTextChanged = beforeTextChanged; | |
} |
NewerOlder