Created
January 24, 2020 04:18
-
-
Save vamjakuldip/404f180ad149168ef7ed73f8759f46e2 to your computer and use it in GitHub Desktop.
View Biding Adapter
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
package com.vk.android.databinding | |
import android.view.View | |
import android.widget.EditText | |
import android.widget.ImageView | |
import androidx.databinding.BindingAdapter | |
import com.bumptech.glide.Glide | |
import com.vk.android.BuildConfig | |
import com.vk.android.R | |
object ViewBidingAdapter { | |
@BindingAdapter("isShow") | |
fun isShow(view: View, visible: Boolean) { | |
view.visibility = if (visible) View.VISIBLE else View.GONE | |
} | |
@BindingAdapter("imageUrl") | |
fun loadImage(view: ImageView, imageUrl: String) { | |
Glide.with(view.context) | |
.load(BuildConfig.BASE_URL + imageUrl).fallback(R.mipmap.ic_launcher).placeholder(R.mipmap.ic_launcher) | |
.into(view) | |
} | |
@BindingAdapter("clearText") | |
fun clearData(view: EditText, isClear: Boolean) { | |
if (isClear) { | |
view.setText("") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment