Differentiate between color Resource Id and int color

Viewed 49

I have a method that should return a Drawable object. It takes Int color or color ResourceId as a parameter, the method should check whether the passed parameter is a ResourceId or Int color

public Drawable getDrawable(int colorIntOrResId){
  if(isItaResColorId(colorIntOrResId)){ //for ex. R.color.white is an int
       return context.getDrawable(isItaResColorId);
  }
 else if(isItIntColor(colorIntOrResId)){ // for ex. Color.parseColor("#ffffff") is also an int
      return new ColorDrawable(isItIntColor)
   }
}

In Short: R.color.white and Color.parseColor("white") Both returns Integer values, How I can programmatically check whether that Integer is a color ResId or a Int color

0 Answers
Related