Java Examples for android.databinding.BindingAdapter

The following java examples will help you to understand the usage of android.databinding.BindingAdapter. These source code samples are taken from different open source projects.

Example 1
Project: S1-Next-master  File: TextViewBindingAdapter.java View source code
@BindingAdapter("increaseClickingArea")
public static void increaseClickingArea(TextView textView, float size) {
    // fork from http://stackoverflow.com/a/1343796
    View parent = (View) textView.getParent();
    // post in the parent's message queue to make sure the parent
    // lays out its children before we call View#getHitRect()
    parent.post(() -> {
        final int halfSize = (int) (size / 2 + 0.5);
        Rect rect = new Rect();
        textView.getHitRect(rect);
        rect.top -= halfSize;
        rect.right += halfSize;
        rect.bottom += halfSize;
        rect.left -= halfSize;
        // use TouchDelegate to increase count's clicking area
        parent.setTouchDelegate(new TouchDelegate(rect, textView));
    });
}
Example 2
Project: data-binding-validator-master  File: LengthBindings.java View source code
@BindingAdapter(value = { "validateMinLength", "validateMinLengthMessage", "validateMinLengthAutoDismiss" }, requireAll = false)
public static void bindingMinLength(TextView view, int minLength, String errorMessage, boolean autoDismiss) {
    if (autoDismiss) {
        EditTextHandler.disableErrorOnChanged(view);
    }
    String handledErrorMessage = ErrorMessageHelper.getStringOrDefault(view, errorMessage, R.string.error_message_min_length, minLength);
    ViewTagHelper.appendValue(R.id.validator_rule, view, new MinLengthRule(view, minLength, handledErrorMessage));
}
Example 3
Project: demos-master  File: FlowViewGroupAdapter.java View source code
@BindingAdapter({ "flowDatas" })
public static void setDatas(final FlowViewGroup flowViewGroup, List<FlowBean> flowBeanList) {
    flowViewGroup.removeAllViews();
    TextView tv;
    if (flowBeanList != null) {
        Context context = flowViewGroup.getContext();
        LayoutInflater inflater = LayoutInflater.from(context);
        for (final FlowBean bean : flowBeanList) {
            ItemFlowBinding itemFlowBinding = DataBindingUtil.inflate(inflater, R.layout.item_flow, flowViewGroup, false);
            itemFlowBinding.setData(bean);
            flowViewGroup.addView(itemFlowBinding.getRoot());
        }
    }
}
Example 4
Project: playground-master  File: TextBinding.java View source code
@BindingAdapter({ "android:text" })
public static void setMediaTypeText(TextView textView, MediaType mediaType) {
    if (mediaType == null) {
        textView.setText(null);
        return;
    }
    Context context = textView.getContext();
    switch(mediaType) {
        case EBOOK:
            textView.setText(context.getString(R.string.text_book_media_ebook));
            break;
        case PAPER:
            textView.setText(context.getString(R.string.text_book_media_paper));
            break;
        default:
            textView.setText(null);
    }
}
Example 5
Project: marvel-master  File: CustomBindingAdapter.java View source code
@BindingAdapter("bind:imageUrl")
public static void loadImage(ImageView imageView, String url) {
    if (null == url) {
        imageView.setImageResource(R.drawable.default_image);
    } else {
        Picasso.with(imageView.getContext()).load(url).error(R.drawable.default_image).into(imageView, new PaletteCallback(imageView) {

            @Override
            public void onPalette(Palette palette) {
                if (null != palette) {
                    ViewGroup parent = (ViewGroup) imageView.getParent().getParent();
                    parent.setBackgroundColor(palette.getDarkVibrantColor(Color.GRAY));
                }
            }
        });
    }
}
Example 6
Project: android-signaturepad-master  File: SignaturePadBindingAdapter.java View source code
@BindingAdapter(value = { "onStartSigning", "onSigned", "onClear" }, requireAll = false)
public static void setOnSignedListener(SignaturePad view, final OnStartSigningListener onStartSigningListener, final OnSignedListener onSignedListener, final OnClearListener onClearListener) {
    view.setOnSignedListener(new SignaturePad.OnSignedListener() {

        @Override
        public void onStartSigning() {
            if (onStartSigningListener != null) {
                onStartSigningListener.onStartSigning();
            }
        }

        @Override
        public void onSigned() {
            if (onSignedListener != null) {
                onSignedListener.onSigned();
            }
        }

        @Override
        public void onClear() {
            if (onClearListener != null) {
                onClearListener.onClear();
            }
        }
    });
}
Example 7
Project: droidkaigi2016-master  File: DataBindingAttributeUtil.java View source code
@BindingAdapter("sessionTimeRange")
public static void setSessionTimeRange(TextView textView, @NonNull Session session) {
    Date displaySTime = session.getDisplaySTime(textView.getContext());
    Date displayETime = session.getDisplayETime(textView.getContext());
    String timeRange = textView.getContext().getString(R.string.session_time_range, DateUtil.getHourMinute(displaySTime), DateUtil.getHourMinute(displayETime), Integer.toString(DateUtil.getMinutes(displaySTime, displayETime)));
    textView.setText(timeRange);
}
Example 8
Project: binding-collection-adapter-master  File: BindingCollectionAdapters.java View source code
// AdapterView
@SuppressWarnings("unchecked")
@BindingAdapter(value = { "itemBinding", "itemTypeCount", "items", "adapter", "itemDropDownLayout", "itemIds", "itemIsEnabled" }, requireAll = false)
public static <T> void setAdapter(AdapterView adapterView, ItemBinding<T> itemBinding, Integer itemTypeCount, List items, BindingListViewAdapter<T> adapter, @LayoutRes int itemDropDownLayout, BindingListViewAdapter.ItemIds<? super T> itemIds, BindingListViewAdapter.ItemIsEnabled<? super T> itemIsEnabled) {
    if (itemBinding == null) {
        throw new IllegalArgumentException("onItemBind must not be null");
    }
    BindingListViewAdapter<T> oldAdapter = (BindingListViewAdapter<T>) unwrapAdapter(adapterView.getAdapter());
    if (adapter == null) {
        if (oldAdapter == null) {
            int count = itemTypeCount != null ? itemTypeCount : 1;
            adapter = new BindingListViewAdapter<>(count);
        } else {
            adapter = oldAdapter;
        }
    }
    adapter.setItemBinding(itemBinding);
    adapter.setDropDownItemLayout(itemDropDownLayout);
    adapter.setItems(items);
    adapter.setItemIds(itemIds);
    adapter.setItemIsEnabled(itemIsEnabled);
    if (oldAdapter != adapter) {
        adapterView.setAdapter(adapter);
    }
}
Example 9
Project: android-sdk-sources-for-api-level-23-master  File: ProcessMethodAdapters.java View source code
@Override
public boolean onHandleStep(RoundEnvironment roundEnv, ProcessingEnvironment processingEnvironment, BindingBuildInfo buildInfo) {
    L.d("processing adapters");
    final ModelAnalyzer modelAnalyzer = ModelAnalyzer.getInstance();
    Preconditions.checkNotNull(modelAnalyzer, "Model analyzer should be" + " initialized first");
    SetterStore store = SetterStore.get(modelAnalyzer);
    clearIncrementalClasses(roundEnv, store);
    addBindingAdapters(roundEnv, processingEnvironment, store);
    addRenamed(roundEnv, processingEnvironment, store);
    addConversions(roundEnv, processingEnvironment, store);
    addUntaggable(roundEnv, processingEnvironment, store);
    try {
        store.write(buildInfo.modulePackage(), processingEnvironment);
    } catch (IOException e) {
        L.e(e, "Could not write BindingAdapter intermediate file.");
    }
    return true;
}
Example 10
Project: android-data-binding-recyclerview-master  File: RecyclerViewBindings.java View source code
@SuppressWarnings("unchecked")
@BindingAdapter("itemViewBinder")
public static <T> void setItemViewBinder(RecyclerView recyclerView, ItemBinder<T> itemViewMapper) {
    Collection<T> items = (Collection<T>) recyclerView.getTag(KEY_ITEMS);
    ClickHandler<T> clickHandler = (ClickHandler<T>) recyclerView.getTag(KEY_CLICK_HANDLER);
    BindingRecyclerViewAdapter<T> adapter = new BindingRecyclerViewAdapter<>(itemViewMapper, items);
    if (clickHandler != null) {
        adapter.setClickHandler(clickHandler);
    }
    recyclerView.setAdapter(adapter);
}
Example 11
Project: MVVM_Hacker_News-master  File: CommentViewModel.java View source code
@BindingAdapter("containerMargin")
public static void setContainerMargin(View view, boolean isTopLevelComment) {
    if (view.getTag() == null) {
        view.setTag(true);
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        float horizontalMargin = view.getContext().getResources().getDimension(R.dimen.activity_horizontal_margin);
        float topMargin = isTopLevelComment ? view.getContext().getResources().getDimension(R.dimen.activity_vertical_margin) : 0;
        layoutParams.setMargins((int) horizontalMargin, (int) topMargin, (int) horizontalMargin, 0);
        view.setLayoutParams(layoutParams);
    }
}
Example 12
Project: cusnews-master  File: DetailPagerAdapterBinder.java View source code
@SuppressWarnings("unchecked")
@BindingAdapter("entryContent")
public static void setEntryContent(TextView tv, Entry entry) {
    final WeakReference<TextView> textViewWeakReference = new WeakReference<>(tv);
    if (!TextUtils.isEmpty(entry.getContent())) {
        tv.setVisibility(View.VISIBLE);
        AsyncTaskCompat.executeParallel(new AsyncTask<Entry, Void, String>() {

            @Override
            protected String doInBackground(Entry... params) {
                Entry entry = params[0];
                //try {
                return Jsoup.parse(entry.getContent()).text();
            //} catch (Exception e) {
            //	return Jsoup.parse(new URL(entry.getUrl()), 1000 * 30).body().children().text();
            //}
            }

            @Override
            protected void onPostExecute(String s) {
                super.onPostExecute(s);
                if (textViewWeakReference.get() != null) {
                    textViewWeakReference.get().setText(s);
                    ((View) textViewWeakReference.get().getParent()).findViewById(R.id.load_pb).setVisibility(View.GONE);
                }
            }
        }, entry);
    } else {
        ((View) tv.getParent()).setVisibility(View.GONE);
    }
}
Example 13
Project: cw-omnibus-master  File: RequestFocusActivity.java View source code
@BindingAdapter("app:requestFocus")
public static void bindRequestFocus(View v, String focusMode) {
    Configuration cfg = v.getResources().getConfiguration();
    boolean hasNoKeyboard = cfg.keyboard == Configuration.KEYBOARD_NOKEYS;
    boolean keyboardHidden = cfg.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES;
    boolean result = false;
    if (TRUE.equals(focusMode)) {
        result = true;
    } else if (IF_HARD_KEYBOARD.equals(focusMode)) {
        if (!hasNoKeyboard && !keyboardHidden) {
            result = true;
        }
    } else if (IF_NO_HARD_KEYBOARD.equals(focusMode)) {
        if (hasNoKeyboard || keyboardHidden) {
            result = true;
            if (hasNoKeyboard)
                v.setFocusableInTouchMode(true);
        }
    } else {
        throw new IllegalArgumentException("Unexpected focusMode value: " + focusMode);
    }
    if (result) {
        v.setFocusable(true);
        v.requestFocus();
    }
}
Example 14
Project: open-keychain-master  File: ImportKeysExtraBindings.java View source code
@BindingAdapter({ "keyRevoked", "keyExpired", "keySecure" })
public static void setStatus(ImageView imageView, boolean revoked, boolean expired, boolean secure) {
    Context context = imageView.getContext();
    if (revoked) {
        KeyFormattingUtils.setStatusImage(context, imageView, null, KeyFormattingUtils.State.REVOKED, R.color.key_flag_gray);
    } else if (expired) {
        KeyFormattingUtils.setStatusImage(context, imageView, null, KeyFormattingUtils.State.EXPIRED, R.color.key_flag_gray);
    } else if (!secure) {
        KeyFormattingUtils.setStatusImage(context, imageView, null, KeyFormattingUtils.State.INSECURE, R.color.key_flag_gray);
    }
}
Example 15
Project: AndroidAgeraTutorial-master  File: PicassoBinding.java View source code
@BindingAdapter({ "imageUrl" })
public static void imageLoader(ImageView imageView, String url) {
    //        Picasso.Builder builder = new Picasso.Builder(imageView.getContext());
    //        builder.listener(new Picasso.Listener() {
    //            @Override
    //            public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
    //                exception.printStackTrace();
    //                Log.e("Picasso Error", uri.toString());
    //            }
    //        });
    //        builder.build().load(url).into(imageView);
    Picasso.with(imageView.getContext()).load(url).into(imageView);
}
Example 16
Project: SyncthingAndroid-master  File: EditFolderPresenter.java View source code
@BindingAdapter("addShareDevices")
public static void addShareDevices(LinearLayout shareDevicesContainer, EditFolderPresenter presenter) {
    if (presenter == null)
        return;
    shareDevicesContainer.removeAllViews();
    for (Map.Entry<String, Boolean> e : presenter.sharedDevices.entrySet()) {
        final String id = e.getKey();
        CheckBox checkBox = new CheckBox(shareDevicesContainer.getContext());
        DeviceConfig device = presenter.controller.getDevice(id);
        if (device == null) {
            device = new DeviceConfig();
            device.deviceID = id;
        }
        checkBox.setText(SyncthingUtils.getDisplayName(device));
        checkBox.setChecked(e.getValue());
        shareDevicesContainer.addView(checkBox);
        presenter.bindingSubscriptions().add(RxCompoundButton.checkedChanges(checkBox).subscribe( b -> {
            presenter.setDeviceShared(id, b);
        }));
    }
}
Example 17
Project: android-ui-toolkit-demos-master  File: ListBindingAdapters.java View source code
/**
     * Assign a list of items to a ViewGroup. This is used with the {@code entries} and
     * {@code layout} attributes in the application namespace. Example Usage:
     * <pre><code><LinearLayout
     *     android:layout_width="match_parent"
     *     android:layout_height="wrap_content"
     *     android:orientation="vertical"
     *     app:entries="@{items}"
     *     app:layout="@{@layout/item}"/>
     * </code></pre>
     * <p>
     * In the above, {@code items} is a List or ObservableList. {@code layout} does not
     * need to be hard-coded, but most commonly will be. This BindingAdapter will work
     * with any ViewGroup that only needs addView() and removeView() to manage its Views.
     * <p>
     * The layout, @layout/item for example, must have a single variable named
     * {@code data}.
     */
@BindingAdapter({ "entries", "layout" })
public static <T> void setEntries(ViewGroup viewGroup, List<T> oldEntries, int oldLayoutId, List<T> newEntries, int newLayoutId) {
    if (oldEntries == newEntries && oldLayoutId == newLayoutId) {
        // nothing has changed
        return;
    }
    EntryChangeListener listener = ListenerUtil.getListener(viewGroup, R.id.entryListener);
    if (oldEntries != newEntries && listener != null && oldEntries instanceof ObservableList) {
        ((ObservableList) oldEntries).removeOnListChangedCallback(listener);
    }
    if (newEntries == null) {
        viewGroup.removeAllViews();
    } else {
        if (newEntries instanceof ObservableList) {
            if (listener == null) {
                listener = new EntryChangeListener(viewGroup, newLayoutId);
                ListenerUtil.trackListener(viewGroup, listener, R.id.entryListener);
            } else {
                listener.setLayoutId(newLayoutId);
            }
            if (newEntries != oldEntries) {
                ((ObservableList) newEntries).addOnListChangedCallback(listener);
            }
        }
        resetViews(viewGroup, newLayoutId, newEntries);
    }
}
Example 18
Project: Avengers-master  File: CharacterDetailActivity.java View source code
@BindingAdapter({ "source", "presenter", "callback" })
public static void setImageSource(ImageView v, String url, CharacterDetailPresenter detailPresenter, OnCharacterImageCallback imageCallback) {
    Glide.with(v.getContext()).load(url).asBitmap().into(new BitmapImageViewTarget(v) {

        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
            super.onResourceReady(resource, glideAnimation);
            v.setImageBitmap(resource);
            imageCallback.onReceive(resource);
            detailPresenter.onImageReceived();
        }
    });
}
Example 19
Project: From-design-to-Android-part1-master  File: OrderDialogFragment.java View source code
@BindingAdapter("app:spanOffset")
public static void setItemSpan(View v, int spanOffset) {
    final String itemText = ((TextView) v).getText().toString();
    final SpannableString sString = new SpannableString(itemText);
    sString.setSpan(new RelativeSizeSpan(1.65f), itemText.length() - spanOffset, itemText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    ((TextView) v).setText(sString);
}
Example 20
Project: countries-master  File: BindingAdapters.java View source code
@BindingAdapter("android:visibility")
public static void setVisibility(View view, boolean visible) {
    view.setVisibility(visible ? View.VISIBLE : View.GONE);
}
Example 21
Project: EverExample-master  File: Bindings.java View source code
@BindingAdapter({ "bind:imageUrl" })
public static void loadImage(ImageView imageView, String url) {
    Glide.with(imageView.getContext()).load(url).into(imageView);
}
Example 22
Project: GuildWars2_APIViewer-master  File: BindingUtils.java View source code
@BindingAdapter({ "app:imageUrl" })
public static void loadImage(ImageView view, String imageUrl) {
    Picasso.with(view.getContext()).load(imageUrl).error(R.drawable.icon_unavailable).into(view);
}
Example 23
Project: MultiItem-master  File: DataBindUtil.java View source code
/**
     * 通过android:imageUrl可以在xml布局中直接为ImageView设置url地址,这样方便业务中使用第三方库加载网络图片
     *
     * @param imageView xml中ImageView实例
     * @param imgUrl    网络图片地址
     */
@BindingAdapter({ "android:imageUrl" })
public static void setImageViewResource(ImageView imageView, String imgUrl) {
    Context context = imageView.getContext();
    //此处通过imgUrl字符串获取资源ID,具体使用根据业务需要
    int resId = context.getResources().getIdentifier(imgUrl, "drawable", context.getPackageName());
    imageView.setImageResource(resId);
}
Example 24
Project: InifiniteRecyclerView-master  File: ImageViewBindingAdapter.java View source code
@BindingAdapter("imageSrc")
public static void setImageSource(ImageView imageView, String imageSrc) {
    Glide.with(imageView.getContext()).load(imageSrc).placeholder(R.drawable.mtg_card_back).crossFade().into(imageView);
}
Example 25
Project: BGAPhotoPicker-Android-master  File: BGANinePhotoLayoutAdapter.java View source code
@BindingAdapter({ "bga_npl_delegate" })
public static void setDelegate(BGANinePhotoLayout ninePhotoLayout, BGANinePhotoLayout.Delegate delegate) {
    ninePhotoLayout.setDelegate(delegate);
}
Example 26
Project: MVVMLight-master  File: ViewBindingAdapter.java View source code
@BindingAdapter({ "onRefreshCommand" })
public static void onRefreshCommand(SwipeRefreshLayout swipeRefreshLayout, final ReplyCommand onRefreshCommand) {
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (onRefreshCommand != null) {
                onRefreshCommand.execute();
            }
        }
    });
}
Example 27
Project: avatar-view-master  File: AvatarViewBindings.java View source code
@BindingAdapter({ "bind:avatarUrl", "bind:name" })
public void loadImage(AvatarView avatarView, String avatarUrl, String name) {
    if (avatarView != null) {
        imageLoader.loadImage(avatarView, avatarUrl, name, avatarView.textSizePercentage());
    }
}
Example 28
Project: multi-type-adapter-master  File: BindingUtil.java View source code
@BindingAdapter({ "imageUrl", "error", "placeholder" })
public static void loadImage(ImageView imgView, String url, Drawable error, Drawable placeholder) {
    Glide.with(imgView.getContext()).load(url).error(error).placeholder(placeholder).into(imgView);
}
Example 29
Project: RxDownload-master  File: DataBindingAdapter.java View source code
@BindingAdapter("image")
public static void setImage(ImageView view, String url) {
    Picasso.with(view.getContext()).load(url).into(view);
}
Example 30
Project: android-ago-master  File: RelativeTimeTextViewBindingAdapter.java View source code
@BindingAdapter("rttv:reference_time")
public static void setReferenceTime(RelativeTimeTextView view, long time) {
    view.setReferenceTime(time);
}
Example 31
Project: Material-Animations-master  File: Sample.java View source code
@BindingAdapter("bind:colorTint")
public static void setColorTint(ImageView view, @ColorRes int color) {
    DrawableCompat.setTint(view.getDrawable(), color);
//view.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
Example 32
Project: all-base-adapter-master  File: LoadImgAdapter.java View source code
//后面的netUrl是xml里的名字, 必须是static方法
@BindingAdapter({ "netUrl", "shenqi" })
public static void loadNetImage(ImageView imageView, String url, String shenqi) {
    //图片加载
    Glide.with(imageView.getContext()).load(url).into(imageView);
    Toast.makeText(imageView.getContext(), "shenqi" + shenqi, Toast.LENGTH_SHORT).show();
}
Example 33
Project: Android-MVVM-Architecture-master  File: ImageDataBinding.java View source code
@BindingAdapter({ "bind:imageUrl", "bind:placeHolder" })
public static void loadImage(ImageView view, String url, Drawable placeHolder) {
    if (url != null && !url.equals(""))
        Picasso.with(view.getContext()).load(url).placeholder(placeHolder).resize(500, 500).centerCrop().into(view);
}
Example 34
Project: Idaily-master  File: DBRecyclerView.java View source code
@BindingAdapter({ "adapter" })
public static void bindAdapter(SuperRecyclerView recyclerView, AbsRVAdapter adapter) {
    recyclerView.setAdapter(adapter);
    recyclerView.setPageFooter(R.layout.layout_loading_footer);
}
Example 35
Project: LoopSeries-Mobile-master  File: AnimeViewModel.java View source code
@BindingAdapter("binder:imageURL")
public static void loadImage(ImageView imageView, String imageURL) {
    Glide.with(imageView.getContext()).load(ImageUtils.getImageURL(imageURL)).placeholder(R.color.background).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().into(imageView);
}
Example 36
Project: MVVMRxJavaRetrofitSample-master  File: MovieViewModel.java View source code
@BindingAdapter({ "app:imageUrl" })
public static void loadImage(ImageView imageView, String url) {
    Glide.with(imageView.getContext()).load(url).placeholder(R.drawable.cover).error(R.drawable.cover).into(imageView);
}
Example 37
Project: BGARefreshLayout-Android-master  File: BGARefreshLayoutAdapter.java View source code
@BindingAdapter({ "bga_refresh_delegate" })
public static void setDelegate(BGARefreshLayout refreshLayout, BGARefreshLayout.BGARefreshLayoutDelegate delegate) {
    refreshLayout.setDelegate(delegate);
}
Example 38
Project: android-architecture-components-master  File: FragmentBindingAdapters.java View source code
@BindingAdapter("imageUrl")
public void bindImage(ImageView imageView, String url) {
    Glide.with(fragment).load(url).into(imageView);
}
Example 39
Project: MasteringAndroidDataBinding-master  File: AttributeSettersActivity.java View source code
@BindingAdapter({ "imageUrl", "error" })
public static void loadImage(ImageView view, String url, Drawable error) {
    Log.d(App.TAG, "load image");
    Picasso.with(view.getContext()).load(url).error(error).into(view);
}
Example 40
Project: mr-mantou-android-master  File: RatioImageViewBindingUtil.java View source code
@BindingAdapter({ "originalWidth", "originalHeight" })
public static void setOriginalSize(RatioImageView view, int originalWidth, int originalHeight) {
    view.setOriginalSize(originalWidth, originalHeight);
}
Example 41
Project: mv2m-master  File: DataBindingConverters.java View source code
@BindingAdapter({ "app:error" })
public static void bindValidationError(TextInputLayout textInputLayout, int errorRes) {
    if (errorRes != 0) {
        textInputLayout.setError(textInputLayout.getResources().getString(errorRes));
    } else {
        textInputLayout.setError(null);
    }
}
Example 42
Project: AndroidStartupDemo-master  File: PicassoBindingAdapter.java View source code
@BindingAdapter({ "imageUrl" })
public static void imageLoader(ImageView imageView, String url) {
    Picasso.with(imageView.getContext()).load(url).into(imageView);
}
Example 43
Project: android-app-makers-2017-master  File: Speaker.java View source code
@BindingAdapter("imageUrl")
public static void setSpeakerImageUrl(ImageView imageView, String url) {
    final Context context = imageView.getContext();
    Glide.with(context).load("http://androidmakers.fr/img/people/" + url).centerCrop().bitmapTransform(new CropCircleTransformation(context)).placeholder(R.drawable.ic_person_black_24dp).into(imageView);
}
Example 44
Project: AACustomFont-master  File: AAHelper.java View source code
/**
     * Binding Adapter for setting the typeface for the given font name.
     * The font file should be placed in assets folder in the directory of fonts.
     * Any view that has parent class of TextView can easily use this method.
     *
     * @param view Any TextView expected for set the typeface
     * @param fontName Font file name
     */
@BindingAdapter({ "bind:font" })
public static void setFont(View view, String fontName) {
    if (view instanceof TextView) {
        Context context = view.getContext();
        Typeface font = AACustomFont.getInstance(context).get(fontName);
        TextView textView = (TextView) view;
        textView.setTypeface(font);
    }
}
Example 45
Project: movie-booking-master  File: ViewBinding.java View source code
@BindingAdapter("longClick")
public static void setLongClick(@NonNull final View view, @NonNull final View.OnClickListener listener) {
    view.setOnLongClickListener(( v -> {
        listener.onClick(v);
        return true;
    }));
}
Example 46
Project: wheelmap-android-master  File: TextDrawable.java View source code
@BindingAdapter({ "app:drawableText", "app:drawableTextColor", "app:drawableTextSize" })
public static void textDrawable(ImageView imageView, String text, int color, int size) {
    int fontSize = (int) UtilsMisc.dbToPx(imageView.getResources(), size);
    imageView.setImageDrawable(new TextDrawable(text, color, fontSize));
}
Example 47
Project: books-master  File: PageFragment.java View source code
@BindingAdapter({ "bind:imageUrl" })
public static void loadImage(ImageView view, String url) {
    Glide.with(view.getContext()).load(bookLocation + File.separator + url).into(view);
}
Example 48
Project: lib_game-master  File: FontCache.java View source code
@BindingAdapter({ "font" })
public static void setFont(TextView view, String fontName) {
    view.setTypeface(getInstance(view.getContext()).get(fontName));
}
Example 49
Project: archi-master  File: RepositoryViewModel.java View source code
@BindingAdapter({ "imageUrl" })
public static void loadImage(ImageView view, String imageUrl) {
    Picasso.with(view.getContext()).load(imageUrl).placeholder(R.drawable.placeholder).into(view);
}
Example 50
Project: html-textview-master  File: DataBindingExampleActivity.java View source code
/**
     * This method will be used by data binding when we use app:html in XML.
     * BindingAdapters only need to be declared once and usable in the whole app.
     * Its better to put all BindingAdapters in a single Java file.
     *
     * @param view The {@link HtmlTextView}
     * @param html The value from {@link NewsItem#getHtml()}
     */
@BindingAdapter({ "html" })
public static void displayHtml(HtmlTextView view, @Nullable String html) {
    view.setHtml(html, new HtmlResImageGetter(view));
}
Example 51
Project: CloudReader-master  File: ImgLoadUtil.java View source code
/**
     * 妹子,电影列表图
     *
     * @param defaultPicType 电影:0;妹子:1; 书籍:2
     */
@BindingAdapter({ "android:displayFadeImage", "android:defaultPicType" })
public static void displayFadeImage(ImageView imageView, String url, int defaultPicType) {
    displayEspImage(url, imageView, defaultPicType);
}
Example 52
Project: Jockey-master  File: NowPlayingControllerViewModel.java View source code
@BindingAdapter("onSeekListener")
public static void bindOnSeekListener(SeekBar seekBar, OnSeekBarChangeListener listener) {
    seekBar.setOnSeekBarChangeListener(listener);
}
Example 53
Project: SlidePager-master  File: SlidePager.java View source code
@BindingAdapter("sp_slide_show_circular_bars")
public static void showCircularBars(SlidePager slidePager, Boolean visible) {
    if (visible == null) {
        visible = true;
    }
    ProgressView.setShowCircularBar(visible);
}