diff --git a/.gitignore b/.gitignore
index dd02daa6e..61627c924 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,49 @@
+/dist
+
*.iml
-.gradle
-/local.properties
-/.idea/workspace.xml
-/.idea/libraries
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Built application files
+/*/build/
+
+## File-based project format:
+*.ipr
+*.iws
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+## Directory-based project format:
+.idea/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Gradle generated files
+.gradle/
+
+# Signing files
+.signing/
+
+# OS-specific files
.DS_Store
-/build
-/captures
-/node_modules
-/dist
\ No newline at end of file
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 94e0f58fc..000000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-android-widgets
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 96cc43efa..000000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf337..000000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index 97626ba45..000000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 4854b109d..000000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 1d9d62604..000000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 6bc1f218a..000000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460d8..000000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index bc4714fe2..0103dbc30 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
+ classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 05ef575b0..000000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index f23df6e46..000000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Wed Oct 21 11:34:03 PDT 2015
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
diff --git a/widgets/.gitignore b/widgets/.gitignore
index 796b96d1c..58b78e565 100644
--- a/widgets/.gitignore
+++ b/widgets/.gitignore
@@ -1 +1,41 @@
/build
+/dist
+
+*.iml
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Built application files
+/*/build/
+
+## File-based project format:
+*.ipr
+*.iws
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+## Directory-based project format:
+.idea/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Gradle generated files
+.gradle/
+
+# Signing files
+.signing/
\ No newline at end of file
diff --git a/widgets/gradlew b/widgets/gradlew
new file mode 100644
index 000000000..9d82f7891
--- /dev/null
+++ b/widgets/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/widgets/gradlew.bat b/widgets/gradlew.bat
new file mode 100644
index 000000000..8a0b282aa
--- /dev/null
+++ b/widgets/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/widgets/src/main/java/org/nativescript/widgets/AbsoluteLayout.java b/widgets/src/main/java/org/nativescript/widgets/AbsoluteLayout.java
index 21ebd1fd8..fdb4fdf39 100644
--- a/widgets/src/main/java/org/nativescript/widgets/AbsoluteLayout.java
+++ b/widgets/src/main/java/org/nativescript/widgets/AbsoluteLayout.java
@@ -23,9 +23,8 @@ public class AbsoluteLayout extends LayoutBase {
int measureWidth = 0;
int measureHeight = 0;
int childMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- int count = this.getChildCount();
-
- for (int i = 0; i < count; i++) {
+
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
@@ -58,9 +57,8 @@ public class AbsoluteLayout extends LayoutBase {
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
int leftPadding = this.getPaddingLeft();
int topPadding = this.getPaddingTop();
- int count = this.getChildCount();
- for (int i = 0; i < count; i++) {
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
@@ -80,4 +78,4 @@ public class AbsoluteLayout extends LayoutBase {
CommonLayoutParams.restoreOriginalParams(this);
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/CommonLayoutParams.java b/widgets/src/main/java/org/nativescript/widgets/CommonLayoutParams.java
index 2bd555639..2707f2662 100644
--- a/widgets/src/main/java/org/nativescript/widgets/CommonLayoutParams.java
+++ b/widgets/src/main/java/org/nativescript/widgets/CommonLayoutParams.java
@@ -22,6 +22,7 @@ public class CommonLayoutParams extends FrameLayout.LayoutParams {
static final String TAG = "NSLayout";
static int debuggable = -1;
+ private static final int NOT_SET = Integer.MIN_VALUE;
private static final StringBuilder sb = new StringBuilder();
public CommonLayoutParams() {
@@ -36,13 +37,13 @@ public class CommonLayoutParams extends FrameLayout.LayoutParams {
public float bottomMarginPercent = 0;
public float rightMarginPercent = 0;
- public int widthOriginal = -1;
- public int heightOriginal = -1;
+ public int widthOriginal = NOT_SET;
+ public int heightOriginal = NOT_SET;
- public int topMarginOriginal = -1;
- public int leftMarginOriginal = -1;
- public int bottomMarginOriginal = -1;
- public int rightMarginOriginal = -1;
+ public int topMarginOriginal = NOT_SET;
+ public int leftMarginOriginal = NOT_SET;
+ public int bottomMarginOriginal = NOT_SET;
+ public int rightMarginOriginal = NOT_SET;
public int left = 0;
public int top = 0;
@@ -252,53 +253,67 @@ public class CommonLayoutParams extends FrameLayout.LayoutParams {
CommonLayoutParams lp = (CommonLayoutParams) child.getLayoutParams();
if (widthSpec != MeasureSpec.UNSPECIFIED) {
if (lp.widthPercent > 0) {
- lp.widthOriginal = lp.width;
+ // If we get measured twice we will override the original value with the one calculated from percentValue from the first measure.
+ // So we set originalValue only the first time.
+ if (lp.widthOriginal == NOT_SET) {
+ lp.widthOriginal = lp.width;
+ }
lp.width = (int) (availableWidth * lp.widthPercent);
}
else {
- lp.widthOriginal = -1;
+ lp.widthOriginal = NOT_SET;
}
if (lp.leftMarginPercent > 0) {
- lp.leftMarginOriginal = lp.leftMargin;
+ if (lp.leftMarginOriginal == NOT_SET) {
+ lp.leftMarginOriginal = lp.leftMargin;
+ }
lp.leftMargin = (int) (availableWidth * lp.leftMarginPercent);
}
else {
- lp.leftMarginOriginal = -1;
+ lp.leftMarginOriginal = NOT_SET;
}
if (lp.rightMarginPercent > 0) {
- lp.rightMarginOriginal = lp.rightMargin;
+ if (lp.rightMarginOriginal == NOT_SET) {
+ lp.rightMarginOriginal = lp.rightMargin;
+ }
lp.rightMargin = (int) (availableWidth * lp.rightMarginPercent);
}
else {
- lp.rightMarginOriginal = -1;
+ lp.rightMarginOriginal = NOT_SET;
}
}
if (heightSpec != MeasureSpec.UNSPECIFIED) {
if (lp.heightPercent > 0) {
- lp.heightOriginal = lp.height;
+ if (lp.heightOriginal == NOT_SET) {
+ lp.heightOriginal = lp.height;
+ }
lp.height = (int) (availableHeight * lp.heightPercent);
}
else {
- lp.heightOriginal = -1;
+ lp.heightOriginal = NOT_SET;
}
if (lp.topMarginPercent > 0) {
- lp.topMarginOriginal = lp.topMargin;
+ if (lp.topMarginOriginal == NOT_SET) {
+ lp.topMarginOriginal = lp.topMargin;
+ }
lp.topMargin = (int) (availableHeight * lp.topMarginPercent);
}
else {
- lp.topMarginOriginal = -1;
+ lp.topMarginOriginal = NOT_SET;
}
if (lp.bottomMarginPercent > 0) {
- lp.bottomMarginOriginal = lp.bottomMargin;
+ if (lp.bottomMarginOriginal == NOT_SET) {
+ lp.bottomMarginOriginal = lp.bottomMargin;
+ }
lp.bottomMargin = (int) (availableHeight * lp.bottomMarginPercent);
}
else {
- lp.bottomMarginOriginal = -1;
+ lp.bottomMarginOriginal = NOT_SET;
}
}
}
@@ -333,6 +348,13 @@ public class CommonLayoutParams extends FrameLayout.LayoutParams {
if (lp.bottomMarginPercent > 0) {
lp.bottomMargin = lp.bottomMarginOriginal;
}
+
+ lp.widthOriginal = NOT_SET;
+ lp.heightOriginal = NOT_SET;
+ lp.leftMarginOriginal = NOT_SET;
+ lp.topMarginOriginal = NOT_SET;
+ lp.rightMarginOriginal = NOT_SET;
+ lp.bottomMarginOriginal = NOT_SET;
}
}
}
diff --git a/widgets/src/main/java/org/nativescript/widgets/ContentLayout.java b/widgets/src/main/java/org/nativescript/widgets/ContentLayout.java
index 283436dda..30bf965a2 100644
--- a/widgets/src/main/java/org/nativescript/widgets/ContentLayout.java
+++ b/widgets/src/main/java/org/nativescript/widgets/ContentLayout.java
@@ -23,8 +23,7 @@ public class ContentLayout extends LayoutBase {
int measureWidth = 0;
int measureHeight = 0;
- int count = this.getChildCount();
- for (int i = 0; i < count; i++) {
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
@@ -64,9 +63,8 @@ public class ContentLayout extends LayoutBase {
int childRight = right - left - (paddingLeft + paddingRight);
int childBottom = bottom - top - (paddingRight + paddingBottom);
-
- int count = this.getChildCount();
- for (int i = 0; i < count; i++) {
+
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
@@ -77,4 +75,4 @@ public class ContentLayout extends LayoutBase {
CommonLayoutParams.restoreOriginalParams(this);
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/Dock.java b/widgets/src/main/java/org/nativescript/widgets/Dock.java
index e35a4e8ff..e22fdf140 100644
--- a/widgets/src/main/java/org/nativescript/widgets/Dock.java
+++ b/widgets/src/main/java/org/nativescript/widgets/Dock.java
@@ -12,4 +12,4 @@ public enum Dock {
top,
right,
bottom
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/DockLayout.java b/widgets/src/main/java/org/nativescript/widgets/DockLayout.java
index 05baaa99e..6e7724091 100644
--- a/widgets/src/main/java/org/nativescript/widgets/DockLayout.java
+++ b/widgets/src/main/java/org/nativescript/widgets/DockLayout.java
@@ -175,4 +175,4 @@ public class DockLayout extends LayoutBase {
CommonLayoutParams.restoreOriginalParams(this);
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/GridLayout.java b/widgets/src/main/java/org/nativescript/widgets/GridLayout.java
index 860850332..5397304b5 100644
--- a/widgets/src/main/java/org/nativescript/widgets/GridLayout.java
+++ b/widgets/src/main/java/org/nativescript/widgets/GridLayout.java
@@ -266,8 +266,7 @@ public class GridLayout extends LayoutBase {
this.helper.clearMeasureSpecs();
this.helper.init();
- int childrenCount = this.getChildCount();
- for (int i = 0; i < childrenCount; i++) {
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
@@ -1163,4 +1162,4 @@ class MeasureHelper {
this.itemMeasured(measureSpec, false);
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/GridUnitType.java b/widgets/src/main/java/org/nativescript/widgets/GridUnitType.java
index d52a3b047..f5293ad84 100644
--- a/widgets/src/main/java/org/nativescript/widgets/GridUnitType.java
+++ b/widgets/src/main/java/org/nativescript/widgets/GridUnitType.java
@@ -11,4 +11,4 @@ public enum GridUnitType {
auto,
pixel,
star
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/HorizontalScrollView.java b/widgets/src/main/java/org/nativescript/widgets/HorizontalScrollView.java
index d1c38ec9b..fa3af6f08 100644
--- a/widgets/src/main/java/org/nativescript/widgets/HorizontalScrollView.java
+++ b/widgets/src/main/java/org/nativescript/widgets/HorizontalScrollView.java
@@ -248,4 +248,4 @@ public class HorizontalScrollView extends android.widget.HorizontalScrollView {
}
};
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/ImageView.java b/widgets/src/main/java/org/nativescript/widgets/ImageView.java
index 0d8876f96..52a655283 100644
--- a/widgets/src/main/java/org/nativescript/widgets/ImageView.java
+++ b/widgets/src/main/java/org/nativescript/widgets/ImageView.java
@@ -165,4 +165,4 @@ public class ImageView extends android.widget.ImageView {
super.onDraw(canvas);
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/ItemSpec.java b/widgets/src/main/java/org/nativescript/widgets/ItemSpec.java
index 64fc3a884..5c923049b 100644
--- a/widgets/src/main/java/org/nativescript/widgets/ItemSpec.java
+++ b/widgets/src/main/java/org/nativescript/widgets/ItemSpec.java
@@ -57,4 +57,4 @@ public class ItemSpec {
public int getActualLength() {
return this._actualLength;
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/LayoutBase.java b/widgets/src/main/java/org/nativescript/widgets/LayoutBase.java
index 06db0b1ec..39e235209 100644
--- a/widgets/src/main/java/org/nativescript/widgets/LayoutBase.java
+++ b/widgets/src/main/java/org/nativescript/widgets/LayoutBase.java
@@ -64,4 +64,4 @@ public abstract class LayoutBase extends ViewGroup {
return gravity;
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/Orientation.java b/widgets/src/main/java/org/nativescript/widgets/Orientation.java
index bd91e6cfc..273fff8c0 100644
--- a/widgets/src/main/java/org/nativescript/widgets/Orientation.java
+++ b/widgets/src/main/java/org/nativescript/widgets/Orientation.java
@@ -8,6 +8,6 @@ package org.nativescript.widgets;
*
*/
public enum Orientation {
- horzontal,
+ horizontal,
vertical
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/StackLayout.java b/widgets/src/main/java/org/nativescript/widgets/StackLayout.java
index 4186ffac7..fb3360770 100644
--- a/widgets/src/main/java/org/nativescript/widgets/StackLayout.java
+++ b/widgets/src/main/java/org/nativescript/widgets/StackLayout.java
@@ -159,8 +159,7 @@ public class StackLayout extends LayoutBase {
break;
}
- int count = this.getChildCount();
- for (int i = 0; i < count; i++) {
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
@@ -203,8 +202,7 @@ public class StackLayout extends LayoutBase {
break;
}
- int count = this.getChildCount();
- for (int i = 0; i < count; i++) {
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
@@ -215,4 +213,4 @@ public class StackLayout extends LayoutBase {
childLeft += childWidth;
}
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/TabItemSpec.java b/widgets/src/main/java/org/nativescript/widgets/TabItemSpec.java
index 16bc1e021..dc6881f71 100644
--- a/widgets/src/main/java/org/nativescript/widgets/TabItemSpec.java
+++ b/widgets/src/main/java/org/nativescript/widgets/TabItemSpec.java
@@ -6,4 +6,4 @@ public class TabItemSpec {
public String title;
public int iconId;
public Drawable iconDrawable;
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/TabStrip.java b/widgets/src/main/java/org/nativescript/widgets/TabStrip.java
index fa6636e16..68d71a55d 100644
--- a/widgets/src/main/java/org/nativescript/widgets/TabStrip.java
+++ b/widgets/src/main/java/org/nativescript/widgets/TabStrip.java
@@ -166,4 +166,4 @@ class TabStrip extends LinearLayout {
mIndicatorColors = colors;
}
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/VerticalScrollView.java b/widgets/src/main/java/org/nativescript/widgets/VerticalScrollView.java
index 53aa9d817..7e7e9ea20 100644
--- a/widgets/src/main/java/org/nativescript/widgets/VerticalScrollView.java
+++ b/widgets/src/main/java/org/nativescript/widgets/VerticalScrollView.java
@@ -77,7 +77,7 @@ public class VerticalScrollView extends ScrollView {
this.setPadding(0, 0, 0, 0);
}
else {
- CommonLayoutParams.measureChild(child, widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
+ CommonLayoutParams.measureChild(child, widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
this.contentMeasuredWidth = CommonLayoutParams.getDesiredWidth(child);
this.contentMeasuredHeight = CommonLayoutParams.getDesiredHeight(child);
@@ -188,4 +188,4 @@ public class VerticalScrollView extends ScrollView {
this.scrollBy(scrollDelta, 0);
}
}
-}
+}
\ No newline at end of file
diff --git a/widgets/src/main/java/org/nativescript/widgets/WrapLayout.java b/widgets/src/main/java/org/nativescript/widgets/WrapLayout.java
index e246ed923..affa49fb9 100644
--- a/widgets/src/main/java/org/nativescript/widgets/WrapLayout.java
+++ b/widgets/src/main/java/org/nativescript/widgets/WrapLayout.java
@@ -15,7 +15,7 @@ public class WrapLayout extends LayoutBase {
private int _itemWidth = -1;
private int _itemHeight = -1;
- private Orientation _orientation = Orientation.horzontal;
+ private Orientation _orientation = Orientation.horizontal;
private ArrayList _lengths = new ArrayList();
public WrapLayout(Context context) {
@@ -58,6 +58,24 @@ public class WrapLayout extends LayoutBase {
}
}
+ private int getDesiredWidth(View child) {
+ if (this._itemWidth > 0) {
+ return this._itemWidth;
+ }
+
+ // Add margins because layoutChild will subtract them.
+ return CommonLayoutParams.getDesiredWidth(child);
+ }
+
+ private int getDesiredHeight(View child) {
+ if (this._itemHeight > 0) {
+ return this._itemHeight;
+ }
+
+ // Add margins because layoutChild will subtract them.
+ return CommonLayoutParams.getDesiredHeight(child);
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
CommonLayoutParams.adjustChildrenLayoutParams(this, widthMeasureSpec, heightMeasureSpec);
@@ -65,44 +83,42 @@ public class WrapLayout extends LayoutBase {
int measureWidth = 0;
int measureHeight = 0;
- int width = MeasureSpec.getSize(widthMeasureSpec);
- int widthMode = MeasureSpec.getMode(widthMeasureSpec);
-
- int height = MeasureSpec.getSize(heightMeasureSpec);
- int heightMode = MeasureSpec.getMode(heightMeasureSpec);
-
boolean isVertical = this._orientation == Orientation.vertical;
int verticalPadding = this.getPaddingTop() + this.getPaddingBottom();
int horizontalPadding = this.getPaddingLeft() + this.getPaddingRight();
- int childWidthMeasureSpec = getViewMeasureSpec(widthMode, width, this._itemWidth);
- int childHeightMeasureSpec = getViewMeasureSpec(heightMode, height, this._itemHeight);
+ int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ int heightMode = MeasureSpec.getMode(heightMeasureSpec);
- int remainingWidth = widthMode == MeasureSpec.UNSPECIFIED ? Integer.MAX_VALUE : width - horizontalPadding;
- int remainingHeight = heightMode == MeasureSpec.UNSPECIFIED ? Integer.MAX_VALUE : height - verticalPadding;
+ int availableWidth = widthMode == MeasureSpec.UNSPECIFIED ? Integer.MAX_VALUE : MeasureSpec.getSize(widthMeasureSpec) - horizontalPadding;
+ int availableHeight = heightMode == MeasureSpec.UNSPECIFIED ? Integer.MAX_VALUE : MeasureSpec.getSize(heightMeasureSpec) - verticalPadding;
+
+ int childWidthMeasureSpec = getViewMeasureSpec(widthMode, availableWidth, this._itemWidth);
+ int childHeightMeasureSpec = getViewMeasureSpec(heightMode, availableHeight, this._itemHeight);
+
+ int remainingWidth = availableWidth;
+ int remainingHeight = availableHeight;
- int count = this.getChildCount();
-
this._lengths.clear();
int rowOrColumn = 0;
int maxLength = 0;
- for (int i = 0; i < count; i++) {
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
}
CommonLayoutParams.measureChild(child, childWidthMeasureSpec, childHeightMeasureSpec);
- final int childMeasuredWidth = CommonLayoutParams.getDesiredWidth(child);
- final int childMeasuredHeight = CommonLayoutParams.getDesiredHeight(child);
+ final int childMeasuredWidth = this.getDesiredWidth(child);
+ final int childMeasuredHeight = this.getDesiredHeight(child);
if (isVertical) {
if (childMeasuredHeight > remainingHeight) {
rowOrColumn++;
maxLength = Math.max(maxLength, measureHeight);
measureHeight = childMeasuredHeight;
- remainingWidth = height - childMeasuredHeight;
+ remainingWidth = availableHeight - childMeasuredHeight;
this._lengths.add(rowOrColumn, childMeasuredWidth);
}
else {
@@ -115,7 +131,7 @@ public class WrapLayout extends LayoutBase {
rowOrColumn++;
maxLength = Math.max(maxLength, measureWidth);
measureWidth = childMeasuredWidth;
- remainingWidth = width - childMeasuredWidth;
+ remainingWidth = availableWidth - childMeasuredWidth;
this._lengths.add(rowOrColumn, childMeasuredHeight);
}
else {
@@ -132,16 +148,15 @@ public class WrapLayout extends LayoutBase {
}
}
- count = this._lengths.size();
if (isVertical) {
measureHeight = Math.max(maxLength, measureHeight);
- for (int i = 0; i < count; i++) {
+ for (int i = 0, count = this._lengths.size(); i < count; i++) {
measureWidth += this._lengths.get(i);
}
}
else {
measureWidth = Math.max(maxLength, measureWidth);
- for (int i = 0; i < count; i++) {
+ for (int i = 0, count = this._lengths.size(); i < count; i++) {
measureHeight += this._lengths.get(i);
}
}
@@ -173,21 +188,18 @@ public class WrapLayout extends LayoutBase {
int childrenLength = isVertical ? bottom - top - paddingBottom : right - left - paddingRight;
int rowOrColumn = 0;
- int count = this.getChildCount();
- for (int i = 0; i < count; i++) {
+ for (int i = 0, count = this.getChildCount(); i < count; i++) {
View child = this.getChildAt(i);
if (child.getVisibility() == View.GONE) {
continue;
}
- // Add margins because layoutChild will subtract them.
- int childWidth = CommonLayoutParams.getDesiredWidth(child);
- int childHeight = CommonLayoutParams.getDesiredHeight(child);
+ int childWidth = this.getDesiredWidth(child);
+ int childHeight = this.getDesiredHeight(child);
int length = this._lengths.get(rowOrColumn);
if (isVertical) {
childWidth = length;
- childHeight = this._itemHeight > 0 ? this._itemHeight : childHeight;
if (childTop + childHeight > childrenLength) {
// Move to top.
childTop = paddingTop;
@@ -203,7 +215,6 @@ public class WrapLayout extends LayoutBase {
}
}
else {
- childWidth = this._itemWidth > 0 ? this._itemWidth : childWidth;
childHeight = length;
if (childLeft + childWidth > childrenLength) {
// Move to left.