From 647ca10343d04f5f6de3b43f320c5a219e5d59f9 Mon Sep 17 00:00:00 2001 From: "Rakshak R.Hegde" Date: Wed, 15 Feb 2017 17:44:50 +0530 Subject: [PATCH 1/3] fix getMeasuredWidth() for some layouts produced 0. So now computed width is being sent to computeMaxLabelHeight() --- build.gradle | 2 +- library/build.gradle | 2 +- .../stepperindicator/StepperIndicator.java | 16 +++--- sample/build.gradle | 3 +- sample/src/main/res/layout/activity_main.xml | 56 ++++++++++++------- 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index 012a0ad..9487104 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0-beta3' + classpath 'com.android.tools.build:gradle:2.3.0-beta4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/library/build.gradle b/library/build.gradle index 34fd23b..36b80bd 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -24,7 +24,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:appcompat-v7:25.1.1' } apply from: 'gradle-mvn-push.gradle' diff --git a/library/src/main/java/com/badoualy/stepperindicator/StepperIndicator.java b/library/src/main/java/com/badoualy/stepperindicator/StepperIndicator.java index dd54c91..663eeeb 100644 --- a/library/src/main/java/com/badoualy/stepperindicator/StepperIndicator.java +++ b/library/src/main/java/com/badoualy/stepperindicator/StepperIndicator.java @@ -763,12 +763,12 @@ private float getMaxLabelHeight() { return showLabels ? maxLabelHeight + labelMarginTop : 0; } - private void calculateMaxLabelHeight() { + private void calculateMaxLabelHeight(final int measuredWidth) { if (!showLabels) return; // gridWidth is the width of the grid assigned for the step indicator int twoDp = getContext().getResources().getDimensionPixelSize(R.dimen.stpi_two_dp); - int gridWidth = getMeasuredWidth() / stepCount - twoDp; + int gridWidth = measuredWidth / stepCount - twoDp; if (gridWidth <= 0) return; @@ -998,7 +998,13 @@ private boolean isStepValid(final int stepPos) { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - calculateMaxLabelHeight(); + + int widthMode = MeasureSpec.getMode(widthMeasureSpec); + int widthSize = MeasureSpec.getSize(widthMeasureSpec); + + int width = widthMode == MeasureSpec.EXACTLY ? widthSize : getSuggestedMinimumWidth(); + + calculateMaxLabelHeight(width); // Compute the necessary height for the widget int desiredHeight = (int) Math.ceil( @@ -1008,12 +1014,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { getMaxLabelHeight() ); - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); - - int width = widthMode == MeasureSpec.EXACTLY ? widthSize : getSuggestedMinimumWidth(); int height = heightMode == MeasureSpec.EXACTLY ? heightSize : desiredHeight; setMeasuredDimension(width, height); diff --git a/sample/build.gradle b/sample/build.gradle index bb23fb1..94934d7 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -24,10 +24,11 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:appcompat-v7:25.1.1' if (compileLocal) compile project(':library') else compile 'com.github.badoualy:stepper-indicator:1.0.4' + compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5' } diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 59ff866..4878d6a 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -1,23 +1,41 @@ - + - + - + - \ No newline at end of file + \ No newline at end of file From a39e5ad31df1fa075732b37f157c638d59da2ed9 Mon Sep 17 00:00:00 2001 From: "Rakshak R.Hegde" Date: Sat, 18 Feb 2017 23:22:27 +0530 Subject: [PATCH 2/3] fix Incorrect computation of Label Height in some ConstraintLayout --- build.gradle | 2 +- sample/build.gradle | 1 - sample/src/main/res/layout/activity_main.xml | 40 ++++++-------------- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/build.gradle b/build.gradle index 9487104..fcda6da 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0-beta4' + classpath 'com.android.tools.build:gradle:2.3.0-rc1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/sample/build.gradle b/sample/build.gradle index 94934d7..552c652 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -30,5 +30,4 @@ dependencies { compile project(':library') else compile 'com.github.badoualy:stepper-indicator:1.0.4' - compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5' } diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 4878d6a..1740849 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -1,41 +1,23 @@ - + + - - + app:stpi_labels="@array/stepLabels"/> - \ No newline at end of file + \ No newline at end of file From 601db0230c69d7f0e8b5bf4758fd838219082b08 Mon Sep 17 00:00:00 2001 From: "Rakshak R.Hegde" Date: Sat, 18 Feb 2017 23:28:16 +0530 Subject: [PATCH 3/3] fixes --- sample/src/main/res/layout/activity_main.xml | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 1740849..4bc2ed2 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -1,23 +1,23 @@ + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> - + - + - \ No newline at end of file +