Java 类android.graphics.drawable.Drawable 实例源码

项目:chromium-for-android-56-debug-video    文件:AppMenuAdapter.java   
private void setupStandardMenuItemViewHolder(StandardMenuItemViewHolder holder,
        View convertView, final MenuItem item) {
    // Set up the icon.
    Drawable icon = item.getIcon();
    holder.image.setImageDrawable(icon);
    holder.image.setVisibility(icon == null ? View.GONE : View.VISIBLE);
    holder.image.setChecked(item.isChecked());
    holder.text.setText(item.getTitle());
    holder.text.setContentDescription(item.getTitleCondensed());

    boolean isEnabled = item.isEnabled();
    // Set the text color (using a color state list).
    holder.text.setEnabled(isEnabled);
    // This will ensure that the item is not highlighted when selected.
    convertView.setEnabled(isEnabled);

    convertView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAppMenu.onItemClick(item);
        }
    });
}
项目:google-books-android-viewer    文件:BookListActivity.java   
/**
 * Hide list, show details and instruct the details view to show the selected book.
 */
@Override
public void showDetails(Book book, Drawable thumb) {
  final FragmentManager fragmentManager = getFragmentManager();
  FragmentTransaction ft = fragmentManager.beginTransaction();
  BookDetailsFragment details = (BookDetailsFragment) fragmentManager.findFragmentById(R.id.book_details);

  if (book != null) {
    // If null passed, we only configure fragment transaction here.
    details.showDetails(book, thumb);
  }

  ft.show(details);
  ft.hide(fragmentManager.findFragmentById(R.id.book_list));
  ft.addToBackStack("details"); // Use the back button to return to the search list view.

  ft.commit();
}
项目:GravityBox    文件:PieController.java   
private PieItem constructItem(int width, ButtonType type, Drawable image, int minimumImageSize) {
    ImageView view = new ImageView(mContext);
    view.setImageDrawable(image);
    view.setMinimumWidth(minimumImageSize);
    view.setMinimumHeight(minimumImageSize);
    LayoutParams lp = new LayoutParams(minimumImageSize, minimumImageSize);
    view.setLayoutParams(lp);
    PieItem item = new PieItem(mContext, mGbContext, mPieContainer, 0, width, type, view, mColorInfo);
    item.setOnClickListener(this);
    item.setOnLongPressListener(mLongPressHandler);
    return item;
}
项目:letv    文件:AbsHListView.java   
protected void keyPressed() {
    if (isEnabled() && isClickable()) {
        Drawable selector = this.mSelector;
        Rect selectorRect = this.mSelectorRect;
        if (selector == null) {
            return;
        }
        if ((isFocused() || touchModeDrawsInPressedState()) && !selectorRect.isEmpty()) {
            View v = getChildAt(this.mSelectedPosition - this.mFirstPosition);
            if (v != null) {
                if (!v.hasFocusable()) {
                    v.setPressed(true);
                } else {
                    return;
                }
            }
            setPressed(true);
            boolean longClickable = isLongClickable();
            Drawable d = selector.getCurrent();
            if (d != null && (d instanceof TransitionDrawable)) {
                if (longClickable) {
                    ((TransitionDrawable) d).startTransition(ViewConfiguration.getLongPressTimeout());
                } else {
                    ((TransitionDrawable) d).resetTransition();
                }
            }
            if (longClickable && !this.mDataChanged) {
                if (this.mPendingCheckForKeyLongPress == null) {
                    this.mPendingCheckForKeyLongPress = new CheckForKeyLongPress(this, null);
                }
                this.mPendingCheckForKeyLongPress.rememberWindowAttachCount();
                postDelayed(this.mPendingCheckForKeyLongPress, (long) ViewConfiguration.getLongPressTimeout());
            }
        }
    }
}
项目:PeSanKita-android    文件:EmojiProvider.java   
private @Nullable Drawable getEmojiDrawable(@Nullable EmojiDrawInfo drawInfo) {
  if (drawInfo == null)  {
    return null;
  }

  final EmojiDrawable drawable = new EmojiDrawable(drawInfo, decodeScale);
  drawInfo.getPage().get().addListener(new FutureTaskListener<Bitmap>() {
    @Override public void onSuccess(final Bitmap result) {
      Util.runOnMain(new Runnable() {
        @Override public void run() {
          drawable.setBitmap(result);
        }
      });
    }

    @Override public void onFailure(ExecutionException error) {
      Log.w(TAG, error);
    }
  });
  return drawable;
}
项目:SimpleUILauncher    文件:IconCache.java   
/**
 * 根据ActivityInfo绘制图标
 * @param info
 * @return
 */
public Drawable getFullResIcon(ActivityInfo info) {
    Resources resources;
    try {
        resources = mPackageManager.getResourcesForApplication(
                info.applicationInfo);
    } catch (PackageManager.NameNotFoundException e) {
        resources = null;
    }
    if (resources != null) {
        int iconId = info.getIconResource();
        if (iconId != 0) {
            return getFullResIcon(resources, iconId);
        }
    }

    return getFullResDefaultActivityIcon();
}
项目:Orin    文件:SongAdapter.java   
protected void loadAlbumCover(Song song, final ViewHolder holder) {
    if (holder.image == null) return;

    SongGlideRequest.Builder.from(Glide.with(activity), song)
            .checkIgnoreMediaStore(activity)
            .generatePalette(activity).build()
            .into(new PhonographColoredTarget(holder.image) {
                @Override
                public void onLoadCleared(Drawable placeholder) {
                    super.onLoadCleared(placeholder);
                    setColors(getDefaultFooterColor(), holder);
                }

                @Override
                public void onColorReady(int color) {
                    if (usePalette)
                        setColors(color, holder);
                    else
                        setColors(getDefaultFooterColor(), holder);
                }
            });
}
项目:FireFiles    文件:IconUtils.java   
public static Drawable loadMimeIcon(
        Context context, String mimeType, String authority, String docId, int mode) {

    if (Document.MIME_TYPE_DIR.equals(mimeType)) {
        if (MediaDocumentsProvider.AUTHORITY.equals(authority)) {
            if(docId.startsWith(MediaDocumentsProvider.TYPE_ALBUM)){
                return ContextCompat.getDrawable(context, R.drawable.ic_doc_album);
            }
            else if(docId.startsWith(MediaDocumentsProvider.TYPE_IMAGES_BUCKET)){
                return ContextCompat.getDrawable(context, R.drawable.ic_doc_folder);
            }
            else if(docId.startsWith(MediaDocumentsProvider.TYPE_VIDEOS_BUCKET)){
                return ContextCompat.getDrawable(context, R.drawable.ic_doc_folder);
            }
        }

        if (mode == DocumentsActivity.State.MODE_GRID) {
            return ContextCompat.getDrawable(context, R.drawable.ic_grid_folder);
        } else {
            return ContextCompat.getDrawable(context, R.drawable.ic_doc_folder);
        }
    }

    return loadMimeIcon(context, mimeType);
}
项目:sctalk    文件:DrawableCenterEditText.java   
@Override
protected void onDraw(Canvas canvas) {
    Drawable[] drawables = getCompoundDrawables();
    if (drawables != null) {
        Drawable drawableLeft = drawables[0];
        if (drawableLeft != null) {
            float textWidth = getPaint().measureText(getText().toString());
            int drawablePadding = getCompoundDrawablePadding();
            int drawableWidth = 0;
            drawableWidth = drawableLeft.getIntrinsicWidth();
            float bodyWidth = textWidth + drawableWidth + drawablePadding;
            canvas.translate((getWidth() - bodyWidth) / 2 -20, 0);
        }
    }
    super.onDraw(canvas);
}
项目:CXJPadProject    文件:SurroundTestFragment.java   
@OnClick({R.id.start, R.id.red_line, R.id.gray_line})
public void onViewClicked(View view) {
    switch (view.getId()) {
        case R.id.start:
            Bitmap bp = pint1.createSnapshoot();
            Drawable dw = new BitmapDrawable(getResources(),bp);
            im.setImageDrawable(dw);

            break;
        case R.id.red_line:
            break;
        case R.id.gray_line:

            break;
    }
}
项目:boohee_v5.6    文件:ForegroundLinearLayout.java   
public void draw(@NonNull Canvas canvas) {
    super.draw(canvas);
    if (this.mForeground != null) {
        Drawable foreground = this.mForeground;
        if (this.mForegroundBoundsChanged) {
            this.mForegroundBoundsChanged = false;
            Rect selfBounds = this.mSelfBounds;
            Rect overlayBounds = this.mOverlayBounds;
            int w = getRight() - getLeft();
            int h = getBottom() - getTop();
            if (this.mForegroundInPadding) {
                selfBounds.set(0, 0, w, h);
            } else {
                selfBounds.set(getPaddingLeft(), getPaddingTop(), w - getPaddingRight(), h - getPaddingBottom());
            }
            Gravity.apply(this.mForegroundGravity, foreground.getIntrinsicWidth(), foreground.getIntrinsicHeight(), selfBounds, overlayBounds);
            foreground.setBounds(overlayBounds);
        }
        foreground.draw(canvas);
    }
}
项目:ShangHanLun    文件:ActionSheet.java   
private Drawable getOtherButtonBg(String[] titles, int i) {
    if (titles.length == 1) {
        return mAttrs.otherButtonSingleBackground;
    }
    if (titles.length == 2) {
        switch (i) {
            case 0:
                return mAttrs.otherButtonTopBackground;
            case 1:
                return mAttrs.otherButtonBottomBackground;
        }
    }
    if (titles.length > 2) {
        if (i == 0) {
            return mAttrs.otherButtonTopBackground;
        }
        if (i == (titles.length - 1)) {
            return mAttrs.otherButtonBottomBackground;
        }
        return mAttrs.getOtherButtonMiddleBackground();
    }
    return null;
}
项目:editor-sql    文件:FloatingActionButton.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{-android.R.attr.state_enabled}, createCircleDrawable(mColorDisabled));
    drawable.addState(new int[]{android.R.attr.state_pressed}, createCircleDrawable(mColorPressed));
    drawable.addState(new int[]{}, createCircleDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}
项目:Quran    文件:SeekBarPreference.java   
private void styleSeekBar() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    final Drawable progressDrawable = mSeekBar.getProgressDrawable();
    if (progressDrawable != null) {
      if (progressDrawable instanceof LayerDrawable) {
        LayerDrawable ld = (LayerDrawable) progressDrawable;
        int layers = ld.getNumberOfLayers();
        for (int i = 0; i < layers; i++) {
          ld.getDrawable(i).mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
        }
      } else {
        progressDrawable.mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
      }
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      final Drawable thumb = mSeekBar.getThumb();
      if (thumb != null) {
        thumb.mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
      }
    }
  }
}
项目:Camera-Roll-Android-App    文件:FileOperationDialogActivity.java   
private void setSelected(boolean selected) {
    final View imageView = itemView.findViewById(R.id.image);

    if (selected) {
        final Drawable selectorOverlay = Util
                .getAlbumItemSelectorOverlay(imageView.getContext());
        imageView.post(new Runnable() {
            @Override
            public void run() {
                imageView.getOverlay().clear();
                if (selectorOverlay != null) {
                    selectorOverlay.setBounds(0, 0,
                            imageView.getWidth(),
                            imageView.getHeight());
                    imageView.getOverlay().add(selectorOverlay);
                }
            }
        });
    } else {
        imageView.post(new Runnable() {
            @Override
            public void run() {
                imageView.getOverlay().clear();
            }
        });
    }
}
项目:GitHub    文件:SettableDrawableTest.java   
@Test
public void testSetCurrent() {
  Drawable.Callback callback = mock(Drawable.Callback.class);
  mSettableDrawable.setCallback(callback);
  mSettableDrawable.setDrawable(mUnderlyingDrawable1);
  verify(mUnderlyingDrawable0).setCallback(null);
  verify(mUnderlyingDrawable1).setCallback(isNotNull(Drawable.Callback.class));
  verify(callback).invalidateDrawable(mSettableDrawable);
}
项目:TPlayer    文件:MethodProxies.java   
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    ActivityManager.TaskDescription td = (ActivityManager.TaskDescription) args[1];
    String label = td.getLabel();
    Bitmap icon = td.getIcon();

    // If the activity label/icon isn't specified, the application's label/icon is shown instead
    // Android usually does that for us, but in this case we want info about the contained app, not VIrtualApp itself
    if (label == null || icon == null) {
        Application app = VClientImpl.get().getCurrentApplication();
        if (app != null) {
            try {
                if (label == null) {
                    label = app.getApplicationInfo().loadLabel(app.getPackageManager()).toString();
                }
                if (icon == null) {
                    Drawable drawable = app.getApplicationInfo().loadIcon(app.getPackageManager());
                    if (drawable != null) {
                        icon = DrawableUtils.drawableToBitMap(drawable);
                    }
                }
                td = new ActivityManager.TaskDescription(label, icon, td.getPrimaryColor());
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    }

    TaskDescriptionDelegate descriptionDelegate = VirtualCore.get().getTaskDescriptionDelegate();
    if (descriptionDelegate != null) {
        td = descriptionDelegate.getTaskDescription(td);
    }

    args[1] = td;
    return method.invoke(who, args);
}
项目:google-maps-clustering    文件:DefaultIconGenerator.java   
@NonNull
private Drawable createClusterBackground() {
    GradientDrawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setShape(GradientDrawable.OVAL);
    gradientDrawable.setColor(mIconStyle.getClusterBackgroundColor());
    gradientDrawable.setStroke(mIconStyle.getClusterStrokeWidth(),
            mIconStyle.getClusterStrokeColor());
    return gradientDrawable;
}
项目:topnews    文件:PRTHeader.java   
public PRTHeader(Context context) {
    super(context);
    int[] size = ResHelper.getScreenSize(context);
    float screenWidth = size[0] < size[1] ? size[0] : size[1];
    float ratio = screenWidth / DESIGN_SCREEN_WIDTH;

    setOrientation(VERTICAL);

    LinearLayout llInner = new LinearLayout(context);
    LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER_HORIZONTAL;
    addView(llInner, lp);

    ivArrow = new RotateImageView(context);
    int resId = ResHelper.getBitmapRes(context, "ssdk_oks_ptr_ptr");
    if (resId > 0) {
        ivArrow.setImageResource(resId);
    }
    int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
    lp = new LayoutParams(avatarWidth, avatarWidth);
    lp.gravity = Gravity.CENTER_VERTICAL;
    int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
    lp.topMargin = lp.bottomMargin = avataPadding;
    llInner.addView(ivArrow, lp);

    pbRefreshing = new ProgressBar(context);
    resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_progressbar");
    Drawable pbdrawable = context.getResources().getDrawable(resId);
    pbRefreshing.setIndeterminateDrawable(pbdrawable);
    llInner.addView(pbRefreshing, lp);
    pbRefreshing.setVisibility(View.GONE);

    tvHeader = new TextView(getContext());
    tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
    tvHeader.setTextColor(0xff09bb07);
    lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER_VERTICAL;
    llInner.addView(tvHeader, lp);
}
项目:LJFramework    文件:CacheUtils.java   
/**
 * 缓存中读取Drawable
 *
 * @param key 键
 * @param defaultValue 默认值
 * @return 存在且没过期返回对应值,否则返回默认值{@code defaultValue}
 */
public Drawable getDrawable(@NonNull final String key, final Drawable defaultValue) {
    byte[] bytes = getBytes(key);
    if (bytes == null) {
        return defaultValue;
    }
    return CacheHelper.bytes2Drawable(bytes);
}
项目:qmui    文件:QMUIGroupListView.java   
public QMUICommonListItemView createItemView(Drawable imageDrawable, CharSequence titleText, String detailText, int orientation, int accessoryType) {
    int height;
    if (orientation == QMUICommonListItemView.VERTICAL) {
        height = QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_list_item_height_higher);
        return createItemView(imageDrawable, titleText, detailText, orientation, accessoryType, height);
    } else {
        height = QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_list_item_height);
        return createItemView(imageDrawable, titleText, detailText, orientation, accessoryType, height);
    }
}
项目:disclosure-android-app    文件:AppDetailActivity.java   
@Override public void enableEditPermissions(boolean isEnabled) {
  int id = isEnabled ? R.drawable.ic_edit : R.drawable.ic_edit_disabled;
  int text = isEnabled ? R.color.color_icon : R.color.color_icon_disabled;

  Drawable editIcon = ResourcesCompat.getDrawable(getResources(), id, null);
  btnEditSettings.setCompoundDrawablesWithIntrinsicBounds(null, editIcon, null, null);
  btnEditSettings.setTextColor(ContextCompat.getColor(this, text));
}
项目:CircleImageView    文件:CircleImageView.java   
private Bitmap getBitmapFromDrawable(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    try {
        Bitmap bitmap;

        if (drawable instanceof ColorDrawable) {
            bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
        } else {
            bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
        }

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:superglue    文件:DebugDrawerLayout.java   
private static boolean hasOpaqueBackground(View v) {
  final Drawable bg = v.getBackground();
  if (bg != null) {
    return bg.getOpacity() == PixelFormat.OPAQUE;
  }
  return false;
}
项目:AndroidAnimationTools    文件:ThreeBounce.java   
@NonNull
@Override
public Drawable[] createChildren() {
    Bounce[] bounces = {
            new Bounce(),
            new Bounce(),
            new Bounce()
    };
    bounces[1].setAnimationDelay(160);
    bounces[2].setAnimationDelay(320);
    return bounces;
}
项目:SimpleUILauncher    文件:LauncherAppWidgetProviderInfo.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Drawable getIcon(Context context, IconCache cache) {
    if (isCustomWidget) {
        return cache.getFullResIcon(provider.getPackageName(), icon);
    }
    return super.loadIcon(context,
            LauncherAppState.getInstance().getInvariantDeviceProfile().fillResIconDpi);
}
项目:xmrwallet    文件:Helper.java   
static public Bitmap getBitmap(Context context, int drawableId) {
    Drawable drawable = ContextCompat.getDrawable(context, drawableId);
    if (drawable instanceof BitmapDrawable) {
        return BitmapFactory.decodeResource(context.getResources(), drawableId);
    } else if (drawable instanceof VectorDrawable) {
        return getBitmap((VectorDrawable) drawable);
    } else {
        throw new IllegalArgumentException("unsupported drawable type");
    }
}
项目:GitHub    文件:ArrayDrawable.java   
@Override
public void setFilterBitmap(boolean filterBitmap) {
  mDrawableProperties.setFilterBitmap(filterBitmap);
  for (int i = 0; i < mLayers.length; i++) {
    Drawable drawable = mLayers[i];
    if (drawable != null) {
      drawable.setFilterBitmap(filterBitmap);
    }
  }
}
项目:ImmerseMode    文件:TpSbTlNbImmerseMode.java   
@Override
public boolean setStatusDrawable(@Nullable Drawable drawable) {
    Activity activity = mActivityRef.get();
    if (activity != null) {
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
        mCompatStatusBarView.setBackground(drawable);
    }
    return true;
}
项目:QMUI_Android    文件:QMUIQQFaceView.java   
private void handleQQFaceAfterMiddleEllipsize(Canvas canvas, int res, Drawable specialDrawable, int widthStart,
                                              int widthEnd, int ellipsizeLine, boolean isFirst, boolean isLast) {
    int size = res != 0 ? mQQFaceSize : specialDrawable.getIntrinsicWidth() + (isFirst || isLast ? mSpecialDrawablePadding : mSpecialDrawablePadding * 2);
    if (mMiddleEllipsizeWidthRecord == -1) {
        onRealDrawQQFace(canvas, res, specialDrawable, ellipsizeLine - mLastNeedStopLineRecord, widthStart, widthEnd, isFirst, isLast);
        return;
    }

    int endLines = mNeedDrawLine - ellipsizeLine;
    int borrowWidth = (widthEnd - mMiddleEllipsizeWidthRecord) - mCurrentCalWidth;
    int needStopLine = borrowWidth > 0 ? mLines - endLines - 1 : mLines - endLines;
    int needStopWidth = (borrowWidth > 0 ? widthEnd - borrowWidth :
            mMiddleEllipsizeWidthRecord - (widthEnd - mCurrentCalWidth)) +
            QMUIDisplayHelper.dp2px(getContext(), 5);

    if (mCurrentDrawLine < needStopLine) {
        if (size + mCurrentDrawUsedWidth > widthEnd) {
            toNewDrawLine(widthStart);
            onDrawQQFace(canvas, res, specialDrawable, widthStart, widthEnd, isFirst, isLast);
        } else {
            mCurrentDrawUsedWidth += size;
        }
    } else if (mCurrentDrawLine == needStopLine) {
        if (size + mCurrentDrawUsedWidth < needStopWidth) {
            mCurrentDrawUsedWidth += size;
        } else {
            mCurrentDrawUsedWidth = mMiddleEllipsizeWidthRecord;
            mMiddleEllipsizeWidthRecord = -1;
            mLastNeedStopLineRecord = needStopLine;
        }
    } else {
        onRealDrawQQFace(canvas, res, specialDrawable, ellipsizeLine - needStopLine, widthStart, widthEnd, isFirst, isLast);
    }
}
项目:QSRefreshLayout    文件:PlainRefreshDraw.java   
@Override
public void unscheduleDrawable(Drawable who, Runnable what) {
    final Callback callback = getCallback();
    if (callback != null) {
        callback.unscheduleDrawable(this, what);
    }
}
项目:GitHub    文件:ImageViewTargetTest.java   
@Test
public void testSetsDrawableOnViewInOnResourceReadyWhenAnimationReturnsFalse() {
  @SuppressWarnings("unchecked") Transition<Drawable> animation = mock(Transition.class);
  when(animation.transition(any(Drawable.class), eq(target))).thenReturn(false);
  Drawable resource = new ColorDrawable(Color.GRAY);
  target.onResourceReady(resource, animation);

  assertEquals(resource, target.resource);
}
项目:PlusGram    文件:ThemingChatActivity.java   
private void updateTheme(){
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
    actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
    actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));

    Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
    back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
    actionBar.setBackButtonDrawable(back);
}
项目:GitHub    文件:ExampleColorBackend.java   
@Override
public boolean drawFrame(
    Drawable parent, Canvas canvas, int frameNumber) {
  if (mBounds == null) {
    return false;
  }
  mPaint.setColor(mColors[frameNumber]);
  canvas.drawRect(mBounds, mPaint);
  return true;
}
项目:RNLearn_Project1    文件:ReactToolbar.java   
public ReactToolbar(Context context) {
  super(context);

  mLogoHolder = DraweeHolder.create(createDraweeHierarchy(), context);
  mNavIconHolder = DraweeHolder.create(createDraweeHierarchy(), context);
  mOverflowIconHolder = DraweeHolder.create(createDraweeHierarchy(), context);

  mLogoControllerListener = new IconControllerListener(mLogoHolder) {
    @Override
    protected void setDrawable(Drawable d) {
      setLogo(d);
    }
  };

  mNavIconControllerListener = new IconControllerListener(mNavIconHolder) {
    @Override
    protected void setDrawable(Drawable d) {
      setNavigationIcon(d);
    }
  };

  mOverflowIconControllerListener = new IconControllerListener(mOverflowIconHolder) {
    @Override
    protected void setDrawable(Drawable d) {
      setOverflowIcon(d);
    }
  };

}
项目:MVVMArms    文件:FragmentUtils.java   
/**
 * 设置背景
 *
 * @param fragment   fragment
 * @param background 背景
 */
public static void setBackground(@NonNull Fragment fragment, Drawable background) {
    View view = fragment.getView();
    if (view != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.setBackground(background);
        } else {
            view.setBackgroundDrawable(background);
        }
    }
}
项目:PlusGram    文件:ContextLinkCell.java   
private Drawable getDrawableForCurrentState() {
    if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) {
        if (buttonState == -1) {
            return null;
        }
        radialProgress.setAlphaForPrevious(false);
        return Theme.fileStatesDrawable[buttonState + 5][buttonPressed ? 1 : 0];
    }
    return buttonState == 1 ? Theme.photoStatesDrawables[5][0] : null;
}
项目:duo-navigation-drawer    文件:DuoDrawerToggle.java   
void setActionBarUpIndicator(Drawable upDrawable, int contentDescRes) {
    if (!mWarnedForDisplayHomeAsUp && !mActivityImpl.isNavigationVisible()) {
        Log.w("DuoDrawerToggle", "DrawerToggle may not show up because NavigationIcon"
                + " is not visible. You may need to call "
                + "actionbar.setDisplayHomeAsUpEnabled(true);");
        mWarnedForDisplayHomeAsUp = true;
    }
    mActivityImpl.setActionBarUpIndicator(upDrawable, contentDescRes);
}
项目:ImageLoaderSupportGif    文件:ViewAware.java   
@Override
public boolean setImageDrawable(Drawable drawable) {
    if (Looper.myLooper() == Looper.getMainLooper()) {
        View view = viewRef.get();
        if (view != null) {
            setImageDrawableInto(drawable, view);
            return true;
        }
    } else {
        L.w(WARN_CANT_SET_DRAWABLE);
    }
    return false;
}
项目:DizzyPassword    文件:ThemeUtils.java   
public static Drawable getThemeColor(Context context, int attrRes) {
    TypedArray typedArray = context.obtainStyledAttributes(new int[]{attrRes});
    Drawable color = typedArray.getDrawable(0);
    typedArray.recycle();
    return color;
}