Skip to content

Commit

Permalink
add dynamic package length support
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianTerhorst committed May 14, 2016
1 parent 49f4c4d commit 64f3aa2
Showing 1 changed file with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,24 @@ private LayoutEntity createLayoutFromChild(Node node) {
layout.addLayoutParam(newName, value, false, false, number);
}
}
} else if (attributeName.contains("app:")) {
String newName = attributeName.replace("android:", "");
String[] split = newName.split("_");
newName = "";
for (String refactor : split) {
String start = refactor.substring(0, 1).toUpperCase();
String end = refactor.substring(1, refactor.length());
newName += start + end;
}
Object value = getLayoutAttribute(attributeValue);
boolean number = false;
if (String.valueOf(value).contains("R.")) {
number = true;
} else if (isNumber(value)) {
number = true;
}
layout.addLayoutParam(newName, value, false, false, number);

}
}
return layout;
Expand Down Expand Up @@ -339,7 +357,8 @@ private String stringToConstant(String string) {
* @return object name schema
*/
private String constantToObjectName(String string) {
if(!Character.isUpperCase(string.charAt(0))) {
//StringUtils.capitalize();
if (!Character.isUpperCase(string.charAt(0))) {
string = string.substring(0, 1).toUpperCase() + string.substring(1);
int length = string.length();
for (int i = 0; i < length; i++) {
Expand Down Expand Up @@ -375,8 +394,22 @@ private File findLayouts() throws Exception {

File dummyFile = new File(cleanURI);

File projectRoot = dummyFile.getParentFile().getParentFile().getParentFile().getParentFile().getParentFile().getParentFile();
File projectRoot = dummyFile.getParentFile();

File sourceFile = new File(projectRoot.getAbsolutePath() + "/src/main/res/layout");

while (true) {
if (sourceFile.exists()) {
return sourceFile;
} else {
if (projectRoot.getParentFile() != null) {
projectRoot = projectRoot.getParentFile();
sourceFile = new File(projectRoot.getAbsolutePath() + "/src/main/res/layout");
} else {
break;
}
}
}
return new File(projectRoot.getAbsolutePath() + "/src/main/res/layout");
}

Expand Down

0 comments on commit 64f3aa2

Please sign in to comment.