Java Code Examples for androidx.core.graphics.drawable.DrawableCompat#unwrap()

The following examples show how to use androidx.core.graphics.drawable.DrawableCompat#unwrap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterialButtonTest.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Test
public void setIcon_iconUpdated_whenCalledTwice() {
  MaterialButton materialButton = new MaterialButton(context);
  materialButton.setText("test");
  Drawable drawable1 = ContextCompat.getDrawable(context, android.R.drawable.btn_plus);
  setIcon(materialButton, makeMeasureSpec(200), drawable1);

  Drawable unwrapDrawable = DrawableCompat.unwrap(materialButton.getIcon());
  assertThat(unwrapDrawable).isEqualTo(drawable1);

  Drawable drawable2 = ContextCompat.getDrawable(context, android.R.drawable.btn_minus);
  setIcon(materialButton, makeMeasureSpec(200), drawable2);

  unwrapDrawable = DrawableCompat.unwrap(materialButton.getIcon());
  assertThat(unwrapDrawable).isEqualTo(drawable2);
}
 
Example 2
Source File: ChipDrawable.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Nullable
public Drawable getChipIcon() {
  return chipIcon != null ? DrawableCompat.unwrap(chipIcon) : null;
}
 
Example 3
Source File: ChipDrawable.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Nullable
public Drawable getCloseIcon() {
  return closeIcon != null ? DrawableCompat.unwrap(closeIcon) : null;
}