navigation start
の後またはroute shown
の後にBack Button
を押しました。戻るボタンを押した後にプログレスダイアログを表示
私はFragment
に取り組んでいます。 View
のようになる:Fragment
のA-B-C-D。そして、Back Press
ワークフローは、B:A、C:B:A、D:C:B:Aのようになります。
back press
の画面が表示される前に、back press
の後にprogress bar
を使用します。
IはonBackPress
方法で、次のコードを使用している:私はProgressDialog
を実装している
public boolean onBackPressed() {
if (hasNavigationStarted) {
AlertDialog.Builder alert = new AlertDialog.Builder(HomeFragment.this.getActivity());
alert.setTitle("Really quit?");
alert.setMessage("Do you want to exit navigation?");
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
isDrivingModeOn = false;
navigationManager.stopNavigation();
corLDriveInfoContainer.setVisibility(View.VISIBLE);
mapView.clearAllOverlays();
progressBar = new ProgressDialog(getActivity());
progressBar.setMessage("Loading ...");
progressBar.show();
progressBar.setCancelable(false);
if (isDrivingDirectionsOn) {
showDriveInfoForDrivingDirection();
rlDrivingDirections.setVisibility(View.VISIBLE);
((ToolbarActivity) getActivity()).getSupportActionBar().setTitle(R.string.app_name);
if (drivingDirectionDestPoint != null) {
mapView.deleteAllAnnotationsAndCustomPOIs();
addAnnotation(drivingDirectionDestPoint);
mapView.centerMapOnPosition(new SKCoordinate(drivingDirectionDestPoint.getLongitude(), drivingDirectionDestPoint.getLatitude()));
}
if (drivingDirectionStartPoint != null) {
mapView.deleteAllAnnotationsAndCustomPOIs();
addAnnotation(drivingDirectionStartPoint);
}
} else if (latestDriveInfoPlace != null) {
setSearchViewShown(true);
addAnnotation(latestDriveInfoPlace);
mapView.setZoom(MapUtils.DEFAULT_ZOOM_VALUE);
mapView.centerMapOnPosition(new SKCoordinate(latestDriveInfoPlace.getLongitude(), latestDriveInfoPlace.getLatitude()));
searchItem.expandActionView();
searchView.setQuery(latestDriveInfoPlace.getName(), false);
searchView.clearFocus();
}
}
});
alert.setNegativeButton("Cancel", null);
alert.show();
return true;
} else if (isRouteShown) {
isDrivingModeOn = false;
navigationManager.removeRouteCalculationViews();
mapView.deleteAllAnnotationsAndCustomPOIs();
isRouteShown = false;
corLDriveInfoContainer.setVisibility(View.VISIBLE);
if (isDrivingDirectionsOn) {
rlDrivingDirections.setVisibility(View.VISIBLE);
((ToolbarActivity) getActivity()).getSupportActionBar().setTitle(R.string.app_name);
if (drivingDirectionDestPoint != null) {
mapView.deleteAllAnnotationsAndCustomPOIs();
addAnnotation(drivingDirectionDestPoint);
mapView.centerMapOnPosition(new SKCoordinate(drivingDirectionDestPoint.getLongitude(), drivingDirectionDestPoint.getLatitude()));
}
if (drivingDirectionStartPoint != null) {
mapView.deleteAllAnnotationsAndCustomPOIs();
addAnnotation(drivingDirectionStartPoint);
}
} else if (latestDriveInfoPlace != null) {
setSearchViewShown(true);
addAnnotation(latestDriveInfoPlace);
mapView.setZoom(MapUtils.DEFAULT_ZOOM_VALUE);
mapView.centerMapOnPosition(new SKCoordinate(latestDriveInfoPlace.getLongitude(), latestDriveInfoPlace.getLatitude()));
searchItem.expandActionView();
searchView.setQuery(latestDriveInfoPlace.getName(), false);
searchView.clearFocus();
}
return true;
} else if (isDrivingDirectionsOn) {
isDrivingDirectionsOn = false;
rlDrivingDirections.setVisibility(View.GONE);
corLDriveInfoContainer.setVisibility(View.GONE);
setSearchViewShown(true);
searchItem.collapseActionView();
drivingDirectionDestPoint = null;
drivingDirectionStartPoint = null;
atvDestination.setText("");
atvStart.setText("");
hideKeyboard();
((DrawerViewInterface) getActivity()).showHamburgerIcon();
((DrawerViewInterface) getActivity()).unlockDrawer();
mapView.deleteAllAnnotationsAndCustomPOIs();
return true;
}
return false;
}
更新コード
。私は、画面back press
を返した後、ここでdismiss()
メソッドを使用します
progressBar = new ProgressDialog(getActivity());
progressBar.setMessage("Loading ...");
progressBar.show();
progressBar.setCancelable(false);
しかし、?この問題を解決するために何ができるのですか?
は何のために、進行状況ダイアログを使用しようとしていますか? –
私はマップを使用していますので、バックプレスマップをリフレッシュするまでに時間がかかるので、Progress Dialogを使いたいです。何かのように:この種の操作: 'mapView.deleteAllAnnotationsAndCustomPOIs(); addAnnotation(drivingDirectionDestPoint); mapView.centerMapOnPosition(new SKCoordinate(drivingDirectionDestPoint.getLongitude()、drivingDirectionDestPoint.getLatitude())); 'が発生します。だから、私はそれを克服したい。 –
あなたはそのonBackPressを実装する必要はありません。各フラグメントにAsyncTaskがある場合は、onPreExecute()でダイアログを開始し、PostExecute()でそれを閉じます。 –