use of android.databinding.BindingAdapter in project vlc-android by videolan.
the class AsyncImageLoader method loadPicture.
@BindingAdapter({ "media" })
public static void loadPicture(View v, MediaLibraryItem item) {
if (item == null || TextUtils.isEmpty(item.getArtworkMrl()) || item.getItemType() == MediaLibraryItem.TYPE_GENRE || item.getItemType() == MediaLibraryItem.TYPE_PLAYLIST)
return;
final boolean isMedia = item.getItemType() == MediaLibraryItem.TYPE_MEDIA;
final boolean isGroup = isMedia && ((MediaWrapper) item).getType() == MediaWrapper.TYPE_GROUP;
final String cacheKey = isGroup ? "group:" + item.getTitle() : item.getArtworkMrl();
final Bitmap bitmap = sBitmapCache.getBitmapFromMemCache(cacheKey);
if (bitmap != null) {
updateTargetImage(bitmap, v, DataBindingUtil.findBinding(v));
return;
}
if (isMedia && !isGroup && item.getId() == 0L) {
MediaWrapper mw = (MediaWrapper) item;
final int type = mw.getType();
final boolean isMediaFile = type == MediaWrapper.TYPE_AUDIO || type == MediaWrapper.TYPE_VIDEO;
final Uri uri = mw.getUri();
if (!isMediaFile && !(type == MediaWrapper.TYPE_DIR && "upnp".equals(uri.getScheme())))
return;
if (isMediaFile && "file".equals(uri.getScheme())) {
mw = sMedialibrary.getMedia(uri);
if (mw != null)
item = mw;
}
}
loadImage(MLItemCoverFetcher.obtain().init(v, item), v);
}
use of android.databinding.BindingAdapter in project open-event-orga-app by fossasia.
the class DateBindings method bindTime.
@BindingAdapter("time")
public static void bindTime(Button button, ObservableField<String> time) {
String format = DateUtils.FORMAT_24H;
bindTemporal(button, time, format, zonedDateTime -> new TimePickerDialog(button.getContext(), (picker, hourOfDay, minute) -> setPickedDate(LocalDateTime.of(zonedDateTime.toLocalDate(), LocalTime.of(hourOfDay, minute)), button, format, time), zonedDateTime.getHour(), zonedDateTime.getMinute(), true));
}
use of android.databinding.BindingAdapter in project PainlessMusicPlayer by Doctoror.
the class BindingAdapters method setSrcResTintedFromAttr.
@BindingAdapter({ "srcRes", "tintAttr" })
public static void setSrcResTintedFromAttr(@NonNull final ImageView imageView, @DrawableRes final int res, @AttrRes final int tintAttr) {
Drawable src = ContextCompat.getDrawable(imageView.getContext(), res);
setSrcTintedFromAttr(imageView, src, tintAttr);
}
use of android.databinding.BindingAdapter in project android-mvvm-architecture by MindorksOpenSource.
the class BindingUtils method setImageUrl.
@BindingAdapter("imageUrl")
public static void setImageUrl(ImageView imageView, String url) {
Context context = imageView.getContext();
Glide.with(context).load(url).into(imageView);
}
use of android.databinding.BindingAdapter in project anitrend-app by AniTrend.
the class SingleLineFontTextView method setCustomFontType.
@BindingAdapter({ "fontName" })
public static void setCustomFontType(SingleLineTextView singleLineTextView, String fontName) {
String fontPath = String.format("fonts/%s", fontName);
AssetManager assertManager = singleLineTextView.getContext().getAssets();
singleLineTextView.setTypeface(Typeface.createFromAsset(assertManager, fontPath));
}
Aggregations