Start action mode immediately after selecting a train

This commit is contained in:
Doug Keen 2013-07-28 18:07:54 -07:00
parent 6f18d4877a
commit a2d79b5a41

View File

@ -295,8 +295,8 @@ public class ViewDeparturesActivity extends Activity implements
* Otherwise select the clicked departure as the one the user * Otherwise select the clicked departure as the one the user
* wants to board * wants to board
*/ */
setBoardedDeparture((Departure) getListAdapter().getItem( setBoardedDeparture(
position)); (Departure) getListAdapter().getItem(position), true);
} }
} }
}; };
@ -454,6 +454,11 @@ public class ViewDeparturesActivity extends Activity implements
} }
private void setBoardedDeparture(Departure selectedDeparture) { private void setBoardedDeparture(Departure selectedDeparture) {
setBoardedDeparture(selectedDeparture, false);
}
private void setBoardedDeparture(Departure selectedDeparture,
boolean startActionMode) {
final BartRunnerApplication application = (BartRunnerApplication) getApplication(); final BartRunnerApplication application = (BartRunnerApplication) getApplication();
selectedDeparture selectedDeparture
.setPassengerDestination(mStationPair.getDestination()); .setPassengerDestination(mStationPair.getDestination());
@ -465,6 +470,11 @@ public class ViewDeparturesActivity extends Activity implements
BoardedDepartureService.class); BoardedDepartureService.class);
intent.putExtra("departure", selectedDeparture); intent.putExtra("departure", selectedDeparture);
startService(intent); startService(intent);
if (startActionMode) {
((Checkable) mYourTrainSection).setChecked(true);
startYourTrainActionMode();
}
} }
private void startDepartureActionMode() { private void startDepartureActionMode() {
@ -491,7 +501,7 @@ public class ViewDeparturesActivity extends Activity implements
@Override @Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
if (item.getItemId() == R.id.boardTrain) { if (item.getItemId() == R.id.boardTrain) {
setBoardedDeparture(mSelectedDeparture); setBoardedDeparture(mSelectedDeparture, false);
mode.finish(); mode.finish();
return true; return true;