android.graphics.drawable.Drawable.setCallback()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(279)

本文整理了Java中android.graphics.drawable.Drawable.setCallback()方法的一些代码示例,展示了Drawable.setCallback()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Drawable.setCallback()方法的具体详情如下:
包路径:android.graphics.drawable.Drawable
类名称:Drawable
方法名:setCallback

Drawable.setCallback介绍

暂无

代码示例

代码示例来源:origin: seven332/EhViewer

public void setWrappedDrawable(Drawable drawable) {
  if (this.mDrawable != null) {
   this.mDrawable.setCallback(null);
  }

  this.mDrawable = drawable;
  if (drawable != null) {
   drawable.setCallback(this);
  }
 }
}

代码示例来源:origin: stackoverflow.com

ad.stop();
for (int i = 0; i < ad.getNumberOfFrames(); ++i){
  Drawable frame = ad.getFrame(i);
  if (frame instanceof BitmapDrawable) {
    ((BitmapDrawable)frame).getBitmap().recycle();
  }
  frame.setCallback(null);
}
ad.setCallback(null);

代码示例来源:origin: facebook/litho

public void setWrappedDrawable(Drawable drawable) {
  if (drawable instanceof ComparableDrawable) {
   throw new IllegalArgumentException("drawable is already a ComparableDrawable");
  }

  if (mDrawable != null) {
   mDrawable.setCallback(null);
  }

  mDrawable = drawable;

  if (drawable != null) {
   drawable.setCallback(this);
  }
 }
}

代码示例来源:origin: aa112901/remusic

/**
   * 销毁ImageView回收资源
   */
  private void destoryBitmaps() {
    for (int i = 0; i < IMAGE_COUNT; i++) {
      ImageView imageView = imageViewList.get(i);
      Drawable drawable = imageView.getDrawable();
      if (drawable != null)
        //解除drawable对view的引用
        drawable.setCallback(null);
    }
  }
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Unbind all drawables to avoid memory leaks.
 * Link: http://stackoverflow.com/a/6779164/1590502
 *
 * @param view
 */
private void unbindDrawables(View view) {
  if (view.getBackground() != null) {
    view.getBackground().setCallback(null);
  }
  if (view instanceof ViewGroup) {
    for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
      unbindDrawables(((ViewGroup) view).getChildAt(i));
    }
    ((ViewGroup) view).removeAllViews();
  }
}

代码示例来源:origin: facebook/litho

public void unmount() {
 if (mDrawable != null) {
  setDrawableVisibilitySafe(false, false);
  mDrawable.setCallback(null);
 }
 mDrawable = null;
 mMatrix = null;
 mShouldClipRect = false;
 mWidth = mHeight = 0;
}

代码示例来源:origin: facebook/litho

public void release() {
 setCallback(null);
 mIgnoreInvalidations = false;
 mInvalidated = false;
 mDoNotAttemptDLDrawing = false;
 mDrawable.setCallback(null);
 mDrawable = null;
 mTouchable = false;
 mName = null;
 mDisplayList = null;
}

代码示例来源:origin: DreaminginCodeZH/MaterialProgressBar

private Drawable prepareDrawable(Drawable child) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    child.setLayoutDirection(mLayoutDirection);
  }
  child = child.mutate();
  child.setCallback(mOwner);
  return child;
}

代码示例来源:origin: facebook/litho

/** Sets the current wrapped {@link Drawable} */
void setWrappedDrawable(Drawable drawable) {
 if (drawable == null) {
  throw new IllegalArgumentException("The wrapped drawable must not be null");
 }
 if (mDrawable != null) {
  mDrawable.setCallback(null);
 }
 mDrawable = drawable;
 mDrawable.setCallback(this);
 mTouchable = mDrawable instanceof Touchable;
 // DL needs to be re-created
 invalidateDL();
 // Notify callback about invalidation
 invalidateSelf();
}

代码示例来源:origin: Rajawali/Rajawali

private void unbindDrawables(View view) {
    if (view.getBackground() != null) {
      view.getBackground().setCallback(null);
    }
    if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
      for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
        unbindDrawables(((ViewGroup) view).getChildAt(i));
      }
      ((ViewGroup) view).removeAllViews();
    }
  }
}

代码示例来源:origin: rey5137/material

public void setWrappedDrawable(Drawable drawable) {
    if (mDrawable != null) {
      mDrawable.setCallback(null);
    }

    mDrawable = drawable;

    if (drawable != null) {
      drawable.setCallback(this);
    }

    onBoundsChange(getBounds());
    invalidateSelf();
  }
}

代码示例来源:origin: chentao0707/SimplifyReader

public void setSelector(Drawable sel) {
  if (mSelector != null) {
    mSelector.setCallback(null);
    unscheduleDrawable(mSelector);
  }
  mSelector = sel;
  Rect padding = new Rect();
  sel.getPadding(padding);
  mSelectionLeftPadding = padding.left;
  mSelectionTopPadding = padding.top;
  mSelectionRightPadding = padding.right;
  mSelectionBottomPadding = padding.bottom;
  sel.setCallback(this);
  sel.setState(getDrawableState());
}

代码示例来源:origin: rey5137/material

public void stopAnimation() {
  mRunning = false;
  mPrevIcon.setCallback(null);
  unscheduleDrawable(mPrevIcon);
  mPrevIcon = null;
  mIcon.setAlpha(255);
  if(getHandler() != null)
    getHandler().removeCallbacks(this);
  invalidate();
}

代码示例来源:origin: scwang90/SmartRefreshLayout

public WaterDropHeader(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);
  final ViewGroup thisGroup = this;
  final DensityUtil density = new DensityUtil();
  mSpinnerStyle = SpinnerStyle.Scale;
  mWaterDropView = new WaterDropView(context);
  mWaterDropView.updateCompleteState(0);
  thisGroup.addView(mWaterDropView, MATCH_PARENT, MATCH_PARENT);
  mProgressDrawable = new ProgressDrawable();
  final Drawable progressDrawable = mProgressDrawable;
  progressDrawable.setCallback(this);
  progressDrawable.setBounds(0, 0, density.dip2px(20), density.dip2px(20));
  mImageView = new ImageView(context);
  mProgress = new MaterialProgressDrawable(mImageView);
  mProgress.setBackgroundColor(0xffffffff);
  mProgress.setAlpha(255);
  mProgress.setColorSchemeColors(0xffffffff,0xff0099cc,0xffff4444,0xff669900,0xffaa66cc,0xffff8800);
  mImageView.setImageDrawable(mProgress);
  thisGroup.addView(mImageView, density.dip2px(30), density.dip2px(30));
}

代码示例来源:origin: facebook/litho

private void unmountDrawable(MountItem mountItem) {
 assertMainThread();
 final Drawable drawable = (Drawable) mountItem.getMountableContent();
 drawable.setCallback(null);
 invalidate(drawable.getBounds());
 releaseScrapDataStructuresIfNeeded();
}

代码示例来源:origin: koral--/android-gif-drawable

@Test
  public void testViewInvalidate() {
    final MultiCallback viewInvalidateMultiCallback = new MultiCallback(true);
    viewInvalidateMultiCallback.addView(view);
    drawable.setCallback(viewInvalidateMultiCallback);
    drawable.invalidateSelf();
    verify(view).invalidate();
  }
}

代码示例来源:origin: koral--/android-gif-drawable

@Test
public void testUnscheduleDrawable() {
  simpleMultiCallback.addView(view);
  drawable.setCallback(simpleMultiCallback);
  drawable.unscheduleSelf(action);
  verify(view).unscheduleDrawable(drawable, action);
}

代码示例来源:origin: koral--/android-gif-drawable

@Test
public void testInvalidateDrawable() {
  simpleMultiCallback.addView(view);
  drawable.setCallback(simpleMultiCallback);
  drawable.invalidateSelf();
  verify(view).invalidateDrawable(drawable);
}

代码示例来源:origin: koral--/android-gif-drawable

@Test
public void testScheduleDrawable() {
  simpleMultiCallback.addView(view);
  drawable.setCallback(simpleMultiCallback);
  drawable.scheduleSelf(action, 0);
  verify(view).scheduleDrawable(drawable, action, 0);
}

代码示例来源:origin: koral--/android-gif-drawable

@Test
public void testViewRemoval() {
  simpleMultiCallback.addView(view);
  drawable.setCallback(simpleMultiCallback);
  drawable.invalidateSelf();
  simpleMultiCallback.removeView(view);
  drawable.invalidateSelf();
  verify(view).invalidateDrawable(drawable);
}

相关文章