Change layout for progress

This commit is contained in:
Victor Shcherb 2018-05-30 14:20:50 +02:00
parent ee207c7598
commit 29fc632a7c
3 changed files with 33 additions and 28 deletions

View file

@ -21,25 +21,25 @@ public class RouteCalculationProgress {
public boolean isCancelled; public boolean isCancelled;
public boolean requestPrivateAccessRouting; public boolean requestPrivateAccessRouting;
private static final float INITIAL_PROGRSS = 0.05f; private static final float INITIAL_PROGRESS = 0.05f;
private static final float FIRST_ITERATION = 0.72f; private static final float FIRST_ITERATION = 0.72f;
public float getLinearProgress() { public float getLinearProgress() {
float p = Math.max(distanceFromBegin, distanceFromEnd); float p = Math.max(distanceFromBegin, distanceFromEnd);
float all = totalEstimatedDistance * 1.25f; float all = totalEstimatedDistance * 1.35f;
float pr = 0; float pr = 0;
if (all > 0) { if (all > 0) {
pr = p * p / (all * all); pr = Math.min(p * p / (all * all), 1);
} }
float progress = INITIAL_PROGRSS; float progress = INITIAL_PROGRESS;
if (totalIterations > 1) { if (totalIterations > 1) {
if (iteration <= 0) { if (iteration < 1) {
progress = pr * FIRST_ITERATION + INITIAL_PROGRSS; progress = pr * FIRST_ITERATION + INITIAL_PROGRESS;
} else { } else {
progress = (INITIAL_PROGRSS + FIRST_ITERATION) + pr * (1 - FIRST_ITERATION - INITIAL_PROGRSS); progress = (INITIAL_PROGRESS + FIRST_ITERATION) + pr * (1 - FIRST_ITERATION - INITIAL_PROGRESS);
} }
} else { } else {
progress = INITIAL_PROGRSS + pr * (1 - INITIAL_PROGRSS); progress = INITIAL_PROGRESS + pr * (1 - INITIAL_PROGRESS);
} }
return Math.min(progress * 100f, 99); return Math.min(progress * 100f, 99);
} }

View file

@ -192,6 +192,19 @@
android:contentDescription="@string/shared_string_hide" android:contentDescription="@string/shared_string_hide"
android:src="@drawable/headliner_close"/> android:src="@drawable/headliner_close"/>
</LinearLayout> </LinearLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content"
android:max="100"
android:minHeight="0dp"
android:visibility="gone"
tools:progress="60"
tools:visibility="visible" />
</FrameLayout> </FrameLayout>
@ -242,16 +255,6 @@
</LinearLayout> </LinearLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:minHeight="0dp"
android:visibility="gone"
tools:progress="60"
tools:visibility="visible" />
<include <include
layout="@layout/move_marker_bottom_sheet" layout="@layout/move_marker_bottom_sheet"

View file

@ -231,18 +231,20 @@
tools:src="@drawable/ic_action_test_light"/> tools:src="@drawable/ic_action_test_light"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:max="100"
android:minHeight="0dp"
android:visibility="gone"
tools:progress="60"
tools:visibility="visible" />
</FrameLayout> </FrameLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:minHeight="0dp"
android:visibility="gone"
tools:progress="60"
tools:visibility="visible" />
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"