Search in sources :

Example 11 with BindingAdapter

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);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Bitmap(android.graphics.Bitmap) Uri(android.net.Uri) BindingAdapter(android.databinding.BindingAdapter)

Example 12 with BindingAdapter

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));
}
Also used : BindingAdapter(android.databinding.BindingAdapter) TimePickerDialog(android.app.TimePickerDialog) LocalTime(org.threeten.bp.LocalTime) LocalDate(org.threeten.bp.LocalDate) ZonedDateTime(org.threeten.bp.ZonedDateTime) Timber(timber.log.Timber) AlertDialog(android.app.AlertDialog) DatePickerDialog(android.app.DatePickerDialog) DateUtils(org.fossasia.openevent.app.utils.DateUtils) Function(org.fossasia.openevent.app.common.Function) LocalDateTime(org.threeten.bp.LocalDateTime) Button(android.widget.Button) DateTimeParseException(org.threeten.bp.format.DateTimeParseException) ObservableField(android.databinding.ObservableField) TimePickerDialog(android.app.TimePickerDialog) BindingAdapter(android.databinding.BindingAdapter)

Example 13 with BindingAdapter

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);
}
Also used : Drawable(android.graphics.drawable.Drawable) BindingAdapter(android.databinding.BindingAdapter)

Example 14 with BindingAdapter

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);
}
Also used : Context(android.content.Context) BindingAdapter(android.databinding.BindingAdapter)

Example 15 with BindingAdapter

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));
}
Also used : AssetManager(android.content.res.AssetManager) BindingAdapter(android.databinding.BindingAdapter)

Aggregations

BindingAdapter (android.databinding.BindingAdapter)15 Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 ObjectAnimator (android.animation.ObjectAnimator)2 AlertDialog (android.app.AlertDialog)2 DatePickerDialog (android.app.DatePickerDialog)2 TimePickerDialog (android.app.TimePickerDialog)2 Context (android.content.Context)2 ObservableField (android.databinding.ObservableField)2 Bitmap (android.graphics.Bitmap)2 Uri (android.net.Uri)2 Button (android.widget.Button)2 Function (org.fossasia.openevent.app.common.Function)2 DateUtils (org.fossasia.openevent.app.utils.DateUtils)2 LocalDate (org.threeten.bp.LocalDate)2 LocalDateTime (org.threeten.bp.LocalDateTime)2 LocalTime (org.threeten.bp.LocalTime)2 ZonedDateTime (org.threeten.bp.ZonedDateTime)2 DateTimeParseException (org.threeten.bp.format.DateTimeParseException)2 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)2