当前位置: 首页>>代码示例>>Java>>正文


Java Context.getDrawable方法代码示例

本文整理汇总了Java中android.content.Context.getDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getDrawable方法的具体用法?Java Context.getDrawable怎么用?Java Context.getDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Context的用法示例。


在下文中一共展示了Context.getDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateStatus

import android.content.Context; //导入方法依赖的package包/类
private void updateStatus(FFMStatus status) {
    if (status.getGroupBlacklist() != null) {
        FFMSettings.putLocalGroupWhitelistValue(status.getGroupBlacklist().isEnabled() ? status.getGroupBlacklist().getCount() : -1);
    }

    if (status.getDiscussWhitelist() != null) {
        FFMSettings.putLocalDiscussWhitelistValue(status.getDiscussWhitelist().isEnabled() ? status.getDiscussWhitelist().getCount() : -1);
    }

    if (status.isRunning()) {
        updateStatus(status.getDevices());
    } else {
        Context context = getContext();

        int color = context.getColor(R.color.serverProblem);
        Drawable icon = context.getDrawable(R.drawable.ic_status_error_24dp);
        updateStatus(context.getString(R.string.status_webqq_dead), color, icon);
    }
}
 
开发者ID:RikkaApps,项目名称:FCM-for-Mojo,代码行数:20,代码来源:ServerStatusPreference.java

示例2: getPreloadProgressPath

import android.content.Context; //导入方法依赖的package包/类
private Path getPreloadProgressPath(Context context) {
    if (AndroidVersion.isAtLeastOreo()) {
        try {
            // Try to load the path from Mask Icon
            Drawable icon = context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper);
            icon.setBounds(0, 0,
                    PreloadIconDrawable.PATH_SIZE, PreloadIconDrawable.PATH_SIZE);
            return (Path) icon.getClass().getMethod("getIconMask").invoke(icon);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // Create a circle static from top center and going clockwise.
    Path p = new Path();
    p.moveTo(PreloadIconDrawable.PATH_SIZE / 2, 0);
    p.addArc(0, 0, PreloadIconDrawable.PATH_SIZE, PreloadIconDrawable.PATH_SIZE, -90, 360);
    return p;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:20,代码来源:DrawableFactory.java

示例3: ResolverDrawerLayout

import android.content.Context; //导入方法依赖的package包/类
public ResolverDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ResolverDrawerLayout,
            defStyleAttr, 0);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ResolverDrawerLayout_android_maxWidth, -1);
    mMaxCollapsedHeight = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeight, 0);
    mMaxCollapsedHeightSmall = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall,
            mMaxCollapsedHeight);
    a.recycle();

    mScrollIndicatorDrawable = context.getDrawable(R.drawable.scroll_indicator_material);

    mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
            android.R.interpolator.decelerate_quint));
    mVelocityTracker = VelocityTracker.obtain();

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();

    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
 
开发者ID:RikkaW,项目名称:Bridge,代码行数:26,代码来源:ResolverDrawerLayout.java

示例4: create

import android.content.Context; //导入方法依赖的package包/类
public static PopupWindow create(@NonNull Context context, @NonNull BubbleLayout bubbleLayout) {

        PopupWindow popupWindow = new PopupWindow(context);

        popupWindow.setContentView(bubbleLayout);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        popupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
        // change background color to transparent
        Drawable drawable;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            drawable = context.getDrawable(R.drawable.popup_window_transparent);
        } else {
            drawable = context.getResources().getDrawable(R.drawable.popup_window_transparent);
        }
        popupWindow.setBackgroundDrawable(drawable);

        return popupWindow;
    }
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:21,代码来源:BubblePopupHelper.java

示例5: IconConfig

import android.content.Context; //导入方法依赖的package包/类
public IconConfig(@NonNull Context context, TypedArray typedArray) {
    DEFAULT_SIZE = IconDotTextView.sDefaultIconSize;
    if (typedArray != null) {
        width = typedArray.getDimensionPixelSize(R.styleable.IconDotTextView_icon_width, DEFAULT_SIZE);
        height = typedArray.getDimensionPixelSize(R.styleable.IconDotTextView_icon_height, DEFAULT_SIZE);
        if (!hasSpecifyWidthAndHeight()) {
            size = typedArray.getDimensionPixelSize(R.styleable.IconDotTextView_icon_size, DEFAULT_SIZE);
        }
        int res = typedArray.getResourceId(R.styleable.IconDotTextView_icon, -1);
        if (res != -1) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                icon = context.getDrawable(res);
            } else {
                icon = context.getResources().getDrawable(res);
            }
        }
    }
}
 
开发者ID:AssIstne,项目名称:IconDotTextView,代码行数:19,代码来源:IconConfig.java

示例6: getDrawableCompat

import android.content.Context; //导入方法依赖的package包/类
private Drawable getDrawableCompat(Context context, int id) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    return context.getDrawable(id);
  } else {
    return context.getResources().getDrawable(id);
  }
}
 
开发者ID:dialogs,项目名称:android-dialer,代码行数:8,代码来源:DialpadView.java

示例7: getDrawable

import android.content.Context; //导入方法依赖的package包/类
public static Drawable getDrawable(Context context, int id){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return context.getDrawable(id);
    } else {
        return context.getResources().getDrawable(id);
    }

}
 
开发者ID:jbmlaird,项目名称:DiscogsBrowser,代码行数:9,代码来源:UtilsJava.java

示例8: getBitmap

import android.content.Context; //导入方法依赖的package包/类
private static Bitmap getBitmap(Context context,int vectorDrawableId) {
    Bitmap bitmap=null;
    if (Build.VERSION.SDK_INT>Build.VERSION_CODES.LOLLIPOP){
        Drawable vectorDrawable = context.getDrawable(vectorDrawableId);
        bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
                vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        vectorDrawable.draw(canvas);
    }else {
        bitmap = BitmapFactory.decodeResource(context.getResources(), vectorDrawableId);
    }
    return bitmap;
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:15,代码来源:ArrowView.java

示例9: getDrawable

import android.content.Context; //导入方法依赖的package包/类
private static Drawable getDrawable(Context context, int id) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return context.getResources().getDrawable(id);
    } else {
        return context.getDrawable(id);
    }
}
 
开发者ID:michaelprimez,项目名称:searchablespinner,代码行数:8,代码来源:EditCursorColor.java

示例10: getDrawable

import android.content.Context; //导入方法依赖的package包/类
static Drawable getDrawable(@NonNull Context context, @DrawableRes int id) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        return context.getDrawable(id);
    } else{
        return context.getResources().getDrawable(id);
    }
}
 
开发者ID:yangchong211,项目名称:YCDialog,代码行数:8,代码来源:ToastUtil.java

示例11: getDrawable

import android.content.Context; //导入方法依赖的package包/类
private Drawable getDrawable(Context context, int id) {
    if (android.os.Build.VERSION.SDK_INT >= 21) {
        return context.getDrawable(id);
    } else {
        return context.getResources().getDrawable(id);
    }
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:8,代码来源:GameActivity.java

示例12: getMaskDrawable

import android.content.Context; //导入方法依赖的package包/类
public static Drawable getMaskDrawable(Context context, int maskId) {
  Drawable drawable;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    drawable = context.getDrawable(maskId);
  } else {
    drawable = context.getResources().getDrawable(maskId);
  }

  if (drawable == null) {
    throw new IllegalArgumentException("maskId is invalid");
  }

  return drawable;
}
 
开发者ID:open-android,项目名称:Glide-transformations,代码行数:15,代码来源:Utils.java

示例13: DividerItemDecoration

import android.content.Context; //导入方法依赖的package包/类
/**
     * Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a
     * {@link LinearLayoutManager}.
     *
     * @param context Current context, it will be used to access resources.
     * @param orientation Divider orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL}.
     */
    public DividerItemDecoration(Context context, int orientation) {
//        final TypedArray a = context.obtainStyledAttributes(ATTRS);
//        mDivider = a.getDrawable(0);
//        a.recycle();
        // @By_syk
        mDivider = context.getDrawable(R.drawable.app_list_divider);
        setOrientation(orientation);
    }
 
开发者ID:homeii,项目名称:GxIconDIY,代码行数:16,代码来源:DividerItemDecoration.java

示例14: getDrawable

import android.content.Context; //导入方法依赖的package包/类
static Drawable getDrawable(Context context, int drawableResId) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        return context.getDrawable(drawableResId);
    } else {
        try {
            return VectorDrawableCompat.create(context.getResources(), drawableResId, null);
        }catch (Resources.NotFoundException e){
            return ContextCompat.getDrawable(context, drawableResId);
        }
    }
}
 
开发者ID:simplezhli,项目名称:ChangeTabLayout,代码行数:12,代码来源:DrawableUtils.java

示例15: getDrawable

import android.content.Context; //导入方法依赖的package包/类
public static Drawable getDrawable(Context context, int id) {
    return context.getDrawable(id);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ContextCompatApi21.java


注:本文中的android.content.Context.getDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。