I was wondering if there is a good way for Paint
comparison.
For example, consider the following code:
Paint paint1 = new Paint();
paint1.setColor(Color.BLUE);
Paint paint2 = new Paint(paint1);
Paint paint3 = new Paint(paint1);
paint3.setColor(Color.YELLOW);
In this case, I would like to write some code that says that:
paint1
is the same as paint2
paint1
and paint2
are not the same as paint3
.Of course, you cannot use e.g., paint1 == paint2
as these are two different objects. Also, it seems that paint1.equals(paint2)
is not working.
Is there a way? Or should I individually compare the attributes (such as color, alpha, strokeCap) that I think are important?
Look on the Paint class implementation here. Check what constructor Paint(Paint p) does, what attr it sets. There is a hidden API method hasEqualAttributes(Paint p). Maybe you can use this method code in your app.