當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。