I have a really easy class (ColorTool.java):
import android.graphics.Color;
public class ColorTool {
public boolean closeMatch (int color1, int color2, int tolerance) {
if (Math.abs (Color.red (color1) - Color.red (color2)) > tolerance ) return false;
if (Math.abs (Color.green (color1) - Color.green (color2)) > tolerance ) return false;
return Math.abs(Color.blue(color1) - Color.blue(color2)) <= tolerance;
}
}
And I'm using it in the Main class:
private final ColorTool ct = new ColorTool ();
And using it:
int tolerance = 25;
switch (action) {
case MotionEvent.ACTION_DOWN :
break;
case MotionEvent.ACTION_UP :
v.performClick();
int touchColor = getHotspotColor (R.id.imgMainAreas, evX, evY);
if(x == 1){
if (ct.closeMatch (Color.BLUE, touchColor, tolerance)){
x = 2;
animStart();
}
}
...
Anyway, the Class is marked as never used, the function within too. (closeMatch) When I analyze the whole code of the App this happens too. Maybe I forgive something? I updated to latest Android Studio version.
在不同的地方可能有两个同名的类,而 Main 使用另一个。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.