Drawable getConstantState - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Drawable getConstantState method.

This code example shows how to use the following methods:getConstantState, setImageDrawable
This code example shows how to use the following methods:getConstantState
        return cached.newDrawable();
    } 
 
    private void storeInIconCache(String resourceUri, Drawable drawable) {
        if (drawable != null) {
            mOutsideDrawablesCache.put(resourceUri, drawable.getConstantState());
        } 
    } 
 
    /** 
     * Gets the left-hand side icon that will be used for the current suggestion 
     * if the suggestion contains an icon column but no icon or a broken icon. 
     * 
     * @param cursor A cursor positioned at the current suggestion. 
     * @return A non-null drawable. 
     */ 
    private Drawable getDefaultIcon1(Cursor cursor) {
        // Fall back to a default icon 
        return mContext.getPackageManager().getDefaultActivityIcon(); 
    } 
6
CodeRank
This code example shows how to use the following methods:getConstantState
        return cached.newDrawable();
    } 
 
    private void storeInIconCache(String resourceUri, Drawable drawable) {
        if (drawable != null) {
            mOutsideDrawablesCache.put(resourceUri, drawable.getConstantState());
        } 
    } 
 
    /** 
     * Gets the left-hand side icon that will be used for the current suggestion 
     * if the suggestion contains an icon column but no icon or a broken icon. 
     * 
     * @param cursor A cursor positioned at the current suggestion. 
     * @return A non-null drawable. 
     */ 
    private Drawable getDefaultIcon1(Cursor cursor) {
        // Fall back to a default icon 
        return mContext.getPackageManager().getDefaultActivityIcon(); 
    } 
6
CodeRank
This code example shows how to use the following methods:getConstantState
This code example shows how to use the following methods:getConstantState
			throws XmlPullParserException, IOException { 
		mCurrDrawable.inflate(r, parser, attrs);
	} 
 
	public ConstantState getConstantState() {
		return mCurrDrawable.getConstantState();
	} 
 
	public String toString() {
		return TAG+mCurrDrawable.toString();
	} 
	 
	// Callback Methods called from the delegate 
	 
	public void invalidateDrawable(Drawable who) {
		if (who == mCurrDrawable) {
			Log.d("ALD", "invalidateDrawable who="+who);
			invalidateSelf();
		} 
	} 
5
CodeRank
This code example shows how to use the following methods:getConstantState, setImageDrawable
This code example shows how to use the following methods:getConstantState
    String agencyName = agency.getName();
    Drawable.ConstantState state = agencyIcons.get(agencyName);
    if ( state == null && ! agencyIcons.containsKey(agencyName)) {
      byte[] icon = agency.getIcon();
      if ( icon != null) {
        Drawable drawable = new BitmapDrawable(context.getResources(), new ByteArrayInputStream(icon));
        state = drawable.getConstantState();
      }     
      agencyIcons.put(agencyName, state);
    } 
    if ( state != null) {
      return state.newDrawable(context.getResources());
    } else { 
      return null; 
    } 
  } 
  public static synchronized Drawable getAgencyIcon(Context context, RouteId routeId) {
    Agency agency = Info.routeManager(context).getAgency(routeId);
    return getAgencyIcon(context, agency);
  } 
4
CodeRank

Related Drawable getConstantState Questions & Answers:

getConstantState Method Overview
Return a Drawable.ConstantState instance that holds the shared state of this Drawable.
See Code Examples for other Android Drawable Methods: