Open dannysunyu opened 9 years ago
Got the same issue on GT-I8190 stock 4.1.2. Any solution to detect if rendering fail or nothing display ?
@kingstone59 In SvgShader.calculate
, calls shapePath.addPath(path, pathMatrix);
instead of shapePath.transform(path, pathMatrix);
. That'll help!
@dannysuen hapePath instead of shapePath ? Can't find your line in SvgShader.java Do you import library file directly in your project ?
@kingstone59 Yes, I fixed the bug and put it as a library locally instead of remote dependency. Locate the calculate
method of class SvgShader
, and call shapePath.addPath(borderPath, pathMatrix);
instead of shapePath.transform(pathMatrix, borderPath);
. It resolves the issue.
shapePath
in SvgShader.java is type of PathInfo
so to have add addPath
to PathInfo
public void addPath(Path dst, Matrix matrix) { path.addPath(dst, matrix); }
But know nothing render (also with device that work with transform
)
Refer to this post: https://groups.google.com/forum/#!msg/android-developers/eTxV4KPy1G4/tAe2zUPCjMcJ
Add a method addPath
in PathInfo:
public void addPath(Path dst, Matrix matrix) {
dst.addPath(path, matrix);
}
Also I paste the code for calculate here:
@Override
public void calculate(int bitmapWidth, int bitmapHeight, float width, float height, float scale, float translateX, float translateY) {
path.reset();
borderPath.reset();
pathDimensions[0] = shapePath.getWidth();
pathDimensions[1] = shapePath.getHeight();
pathMatrix.reset();
scale = Math.min(width / pathDimensions[0], height / pathDimensions[1]);
translateX = Math.round((width - pathDimensions[0] * scale) * 0.5f);
translateY = Math.round((height - pathDimensions[1] * scale) * 0.5f);
pathMatrix.setScale(scale, scale);
pathMatrix.postTranslate(translateX, translateY);
// shapePath.transform(pathMatrix, path);
shapePath.addPath(path, pathMatrix);
path.offset(borderWidth, borderWidth);
if (borderWidth > 0) {
pathMatrix.reset();
float newWidth;
float newHeight;
float d;
if (borderType == BORDER_TYPE_DEFAULT) {
newWidth = viewWidth - borderWidth;
newHeight = viewHeight - borderWidth;
d = borderWidth / 2f;
} else {
newWidth = viewWidth;
newHeight = viewHeight;
d = 0;
}
scale = Math.min(newWidth / pathDimensions[0], newHeight / pathDimensions[1]);
translateX = Math.round((newWidth - pathDimensions[0] * scale) * 0.5f + d);
translateY = Math.round((newHeight - pathDimensions[1] * scale) * 0.5f + d);
pathMatrix.setScale(scale, scale);
pathMatrix.postTranslate(translateX, translateY);
// shapePath.transform(pathMatrix, borderPath);
shapePath.addPath(borderPath, pathMatrix);
// borderPath.op(path, Path.Op.DIFFERENCE);
}
pathMatrix.reset();
matrix.invert(pathMatrix);
path.transform(pathMatrix);
}
I run the sample code and find out that all svg-based ImageView can't be displayed on Samsung GT-N7100 and GT-I9100G. I don't have many handsets to test but those are the only handsets with the issue.
I am integrating this library into a commercial project and I am trying to figure out the cause. It's important for me to resolve the issue.