code: public static int getThemeColorFromAttrOrRes(Context ctx, int attr, int res) {
  		int color = getThemeColor(ctx, attr);
  		// If this color is not styled, use the default from the resource
  		if (color == 0) {
  			color = ContextCompat.getColor(ctx, res);
  		}
  		return color;
  	}
docs: helper method to get the color by attr (if defined in the style) or by resource.
  
  @param ctx
  @param attr attribute that defines the color
  @param res  color resource id
  @return