Add route calculation progress to the map route info menu

This commit is contained in:
Alex Sytnyk 2018-05-24 15:48:13 +03:00
parent 9ff87d0f55
commit d7519cc306
5 changed files with 56 additions and 1 deletions

View file

@ -17,6 +17,17 @@
android:clickable="true" android:clickable="true"
android:orientation="vertical"> android:orientation="vertical">
<ProgressBar
android:id="@+id/progress_bar"
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" />
<LinearLayout <LinearLayout
android:id="@+id/ModesLayout" android:id="@+id/ModesLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View file

@ -17,6 +17,17 @@
android:clickable="true" android:clickable="true"
android:orientation="vertical"> android:orientation="vertical">
<ProgressBar
android:id="@+id/progress_bar"
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" />
<LinearLayout <LinearLayout
android:id="@+id/ModesLayout" android:id="@+id/ModesLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View file

@ -93,7 +93,6 @@ import net.osmand.plus.helpers.ExternalApiHelper;
import net.osmand.plus.helpers.ImportHelper; import net.osmand.plus.helpers.ImportHelper;
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment; import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
import net.osmand.plus.helpers.WakeLockHelper; import net.osmand.plus.helpers.WakeLockHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment; import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment; import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment;
@ -436,6 +435,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override @Override
public void updateProgress(int progress) { public void updateProgress(int progress) {
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateRouteCalculationProgress(progress);
if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) { if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) {
if (pbExtView.getVisibility() == View.VISIBLE) { if (pbExtView.getVisibility() == View.VISIBLE) {
pbExtView.setVisibility(View.GONE); pbExtView.setVisibility(View.GONE);
@ -492,6 +492,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override @Override
public void finish() { public void finish() {
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().routeCalculationFinished();
pbExtView.setVisibility(View.GONE); pbExtView.setVisibility(View.GONE);
pb.setVisibility(View.GONE); pb.setVisibility(View.GONE);
} }

View file

@ -188,6 +188,20 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} }
} }
public void updateRouteCalculationProgress(int progress) {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().updateRouteCalculationProgress(progress);
}
}
public void routeCalculationFinished() {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().hideRouteCalculationProgressBar();
}
}
public void updateMenu() { public void updateMenu() {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment(); WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) if (fragmentRef != null)

View file

@ -7,6 +7,7 @@ import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
@ -106,6 +107,23 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
} }
} }
public void updateRouteCalculationProgress(int progress) {
ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar);
if (progressBar != null) {
if (progressBar.getVisibility() != View.VISIBLE) {
progressBar.setVisibility(View.VISIBLE);
}
progressBar.setProgress(progress);
}
}
public void hideRouteCalculationProgressBar() {
View progressBar = mainView.findViewById(R.id.progress_bar);
if (progressBar != null) {
progressBar.setVisibility(View.GONE);
}
}
public void show(MapActivity mapActivity) { public void show(MapActivity mapActivity) {
int slideInAnim = 0; int slideInAnim = 0;
int slideOutAnim = 0; int slideOutAnim = 0;