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);
}
});
}
java类android.graphics.drawable.Drawable的实例源码
AppMenuAdapter.java 文件源码
项目:chromium-for-android-56-debug-video
阅读 28
收藏 0
点赞 0
评论 0
BookListActivity.java 文件源码
项目:google-books-android-viewer
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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();
}
PieController.java 文件源码
项目:GravityBox
阅读 31
收藏 0
点赞 0
评论 0
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;
}
AbsHListView.java 文件源码
项目:letv
阅读 39
收藏 0
点赞 0
评论 0
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());
}
}
}
}
EmojiProvider.java 文件源码
项目:PeSanKita-android
阅读 44
收藏 0
点赞 0
评论 0
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;
}
IconCache.java 文件源码
项目:SimpleUILauncher
阅读 38
收藏 0
点赞 0
评论 0
/**
* 根据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();
}
SongAdapter.java 文件源码
项目:Orin
阅读 28
收藏 0
点赞 0
评论 0
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);
}
});
}
IconUtils.java 文件源码
项目:FireFiles
阅读 41
收藏 0
点赞 0
评论 0
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);
}
DrawableCenterEditText.java 文件源码
项目:sctalk
阅读 30
收藏 0
点赞 0
评论 0
@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);
}
SurroundTestFragment.java 文件源码
项目:CXJPadProject
阅读 34
收藏 0
点赞 0
评论 0
@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;
}
}
ForegroundLinearLayout.java 文件源码
项目:boohee_v5.6
阅读 33
收藏 0
点赞 0
评论 0
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);
}
}
ActionSheet.java 文件源码
项目:ShangHanLun
阅读 37
收藏 0
点赞 0
评论 0
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;
}
FloatingActionButton.java 文件源码
项目:editor-sql
阅读 41
收藏 0
点赞 0
评论 0
@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;
}
SeekBarPreference.java 文件源码
项目:Quran
阅读 33
收藏 0
点赞 0
评论 0
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);
}
}
}
}
FileOperationDialogActivity.java 文件源码
项目:Camera-Roll-Android-App
阅读 24
收藏 0
点赞 0
评论 0
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();
}
});
}
}
SettableDrawableTest.java 文件源码
项目:GitHub
阅读 26
收藏 0
点赞 0
评论 0
@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);
}
MethodProxies.java 文件源码
项目:TPlayer
阅读 37
收藏 0
点赞 0
评论 0
@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);
}
DefaultIconGenerator.java 文件源码
项目:google-maps-clustering
阅读 32
收藏 0
点赞 0
评论 0
@NonNull
private Drawable createClusterBackground() {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setShape(GradientDrawable.OVAL);
gradientDrawable.setColor(mIconStyle.getClusterBackgroundColor());
gradientDrawable.setStroke(mIconStyle.getClusterStrokeWidth(),
mIconStyle.getClusterStrokeColor());
return gradientDrawable;
}
PRTHeader.java 文件源码
项目:topnews
阅读 25
收藏 0
点赞 0
评论 0
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);
}
CacheUtils.java 文件源码
项目:LJFramework
阅读 31
收藏 0
点赞 0
评论 0
/**
* 缓存中读取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);
}
QMUIGroupListView.java 文件源码
项目:qmui
阅读 33
收藏 0
点赞 0
评论 0
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);
}
}
AppDetailActivity.java 文件源码
项目:disclosure-android-app
阅读 22
收藏 0
点赞 0
评论 0
@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.java 文件源码
项目:CircleImageView
阅读 38
收藏 0
点赞 0
评论 0
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;
}
}
DebugDrawerLayout.java 文件源码
项目:superglue
阅读 29
收藏 0
点赞 0
评论 0
private static boolean hasOpaqueBackground(View v) {
final Drawable bg = v.getBackground();
if (bg != null) {
return bg.getOpacity() == PixelFormat.OPAQUE;
}
return false;
}
ThreeBounce.java 文件源码
项目:AndroidAnimationTools
阅读 29
收藏 0
点赞 0
评论 0
@NonNull
@Override
public Drawable[] createChildren() {
Bounce[] bounces = {
new Bounce(),
new Bounce(),
new Bounce()
};
bounces[1].setAnimationDelay(160);
bounces[2].setAnimationDelay(320);
return bounces;
}
LauncherAppWidgetProviderInfo.java 文件源码
项目:SimpleUILauncher
阅读 35
收藏 0
点赞 0
评论 0
@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);
}
Helper.java 文件源码
项目:xmrwallet
阅读 35
收藏 0
点赞 0
评论 0
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");
}
}
ArrayDrawable.java 文件源码
项目:GitHub
阅读 38
收藏 0
点赞 0
评论 0
@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);
}
}
}
TpSbTlNbImmerseMode.java 文件源码
项目:ImmerseMode
阅读 34
收藏 0
点赞 0
评论 0
@Override
public boolean setStatusDrawable(@Nullable Drawable drawable) {
Activity activity = mActivityRef.get();
if (activity != null) {
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
mCompatStatusBarView.setBackground(drawable);
}
return true;
}
QMUIQQFaceView.java 文件源码
项目:QMUI_Android
阅读 34
收藏 0
点赞 0
评论 0
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);
}
}