I hereby claim:
- I am androidguydd on github.
- I am hannesvanbraun (https://keybase.io/hannesvanbraun) on keybase.
- I have a public key ASC9UlEVPBmdfHbu287IrFLoFkpe8aNuVHcdiBgzktreDAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| layout?.apply { | |
| if(childCount > 0){ | |
| removeViewAt(0) | |
| } | |
| } |
| val bundle = Bundle().apply { | |
| putString("key", "value") | |
| putInt("key", 42) | |
| } |
| data class User(val address: UserAddress?) | |
| data class UserAddress(var street: String, var city: String, var zipCode: Int) | |
| val user = User(UserAddress("street", "city", 123)) | |
| user.address?.let { | |
| it.city = "New York" | |
| // do some more fancy stuff | |
| }?: Toast.makeText(this, "Address is not set!", Toast.LENGTH_SHORT).show() |
| data class User(val address: UserAddress) | |
| data class UserAddress(var street: String, var city: String, var zipCode: Int) | |
| val user = User(UserAddress("street", "city", 123)) | |
| user.address.let { | |
| it.city = "Mountain View" | |
| val visibleOnlyHere = it.city | |
| .plus(" ") | |
| .plus(it.zipCode) |
| data class User(val address: UserAddress) | |
| data class UserAddress(var street: String, var city: String, var zipCode: Int) | |
| val user = User(UserAddress("street", "city", 123)) | |
| user.address.let { | |
| it.city = "Mountain View" | |
| val visibleOnlyHere = it.city | |
| .plus(" ") | |
| .plus(it.zipCode) |
| class SimpleHorizontalListItemDivider(context: Context) : RecyclerView.ItemDecoration() { | |
| private var divider = ContextCompat.getDrawable(context, R.drawable.shape_material_list_divider) | |
| private val bounds = Rect() | |
| override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) { | |
| canvas.save() | |
| val left: Int = 0 | |
| val right: Int = parent.width |
| class RoundUserImageView @JvmOverloads constructor( | |
| context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : ImageView(context, attrs, defStyleAttr) { | |
| private var path: Path = Path() | |
| private var bounds = Rect() | |
| private var radius = 0f | |
| override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { | |
| super.onSizeChanged(w, h, oldw, oldh) | |
| bounds = Rect(0, 0, w, h) |
| class DatabindingViewHolder(private val binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root) { | |
| fun bind(data: Any) { | |
| binding.setVariable(BR.viewModel, data) | |
| binding.executePendingBindings() | |
| } | |
| } |
| /** | |
| * Returns Observable notifying softkeyboard visible status including screen size if visible. | |
| * Only works if activity has android:windowSoftInputMode="adjustResize" set in manifest. | |
| */ | |
| fun Activity.getSoftkeyboardOnScreenObservable(): Observable<SoftkeyboardEvent> { | |
| return Observable.fromEmitter<SoftkeyboardEvent>({ | |
| // Threshold for minimal keyboard height. | |
| val MIN_KEYBOARD_HEIGHT_PX = 150 | |
| // Top-level window decor view. |