Addressing TODO: Making SendActivity a state machine.

This commit is contained in:
Rodrigo Damazio
2011-06-30 02:26:01 -03:00
parent d0b5faf266
commit 1d5e2dc4d5
@@ -66,6 +66,28 @@ import java.util.List;
public class SendActivity extends Activity implements ProgressIndicator { public class SendActivity extends Activity implements ProgressIndicator {
public static final String EXTRA_SHARE_LINK = "share_link"; public static final String EXTRA_SHARE_LINK = "share_link";
/** States for the state machine that defines the upload process. */
private enum SendState {
SEND_OPTIONS,
START,
AUTHENTICATE_MAPS,
PICK_MAP,
SEND_TO_MAPS,
SEND_TO_MAPS_DONE,
AUTHENTICATE_FUSION_TABLES,
SEND_TO_FUSION_TABLES,
SEND_TO_FUSION_TABLES_DONE,
AUTHENTICATE_DOCS,
AUTHENTICATE_TRIX,
SEND_TO_DOCS,
SEND_TO_DOCS_DONE,
SHOW_RESULTS,
SHARE_LINK,
FINISH,
DONE,
NOT_READY
}
private static final int SEND_DIALOG = 1; private static final int SEND_DIALOG = 1;
private static final int PROGRESS_DIALOG = 2; private static final int PROGRESS_DIALOG = 2;
/* @VisibleForTesting */ /* @VisibleForTesting */
@@ -103,6 +125,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
private String sendToDocsMessage; private String sendToDocsMessage;
// State used while sending. // State used while sending.
private SendState currentState;
private SendDialog sendDialog; private SendDialog sendDialog;
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
@@ -115,16 +138,12 @@ public class SendActivity extends Activity implements ProgressIndicator {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "SendActivity.onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
providerUtils = MyTracksProviderUtils.Factory.get(this); providerUtils = MyTracksProviderUtils.Factory.get(this);
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, 0); sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, 0);
}
@Override
protected void onStart() {
Log.d(TAG, "SendActivity.onStart");
super.onStart();
resetState(); resetState();
tracker = GoogleAnalyticsTracker.getInstance(); tracker = GoogleAnalyticsTracker.getInstance();
@@ -146,7 +165,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
sendTrackId = ContentUris.parseId(data); sendTrackId = ContentUris.parseId(data);
showDialog(SEND_DIALOG); executeState(SendState.SEND_OPTIONS);
} }
@Override @Override
@@ -174,7 +193,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
} }
dialog.dismiss(); dialog.dismiss();
doSend();
executeStateMachine(SendState.START);
} }
}); });
sendDialog.setOnCancelListener(finishOnCancelListener); sendDialog.setOnCancelListener(finishOnCancelListener);
@@ -183,30 +203,97 @@ public class SendActivity extends Activity implements ProgressIndicator {
@Override @Override
protected void onStop() { protected void onStop() {
Log.d(TAG, "SendActivity.onStop"); Log.d(TAG, "SendActivity.onStop" + currentState);
tracker.dispatch(); tracker.dispatch();
tracker.stop(); tracker.stop();
super.onStop(); super.onStop();
} }
@Override
protected void onDestroy() {
Log.d(TAG, "SendActivity.onDestroy, state=" + currentState);
super.onDestroy();
}
private void executeStateMachine(SendState startState) {
if (startState != null) {
currentState = startState;
}
// If a state handler returns NOT_READY, it means it's waiting for some
// event, and will call this method again when it happens.
while (currentState != SendState.DONE &&
currentState != SendState.NOT_READY) {
Log.d(TAG, "Executing state " + currentState);
currentState = executeState(currentState);
Log.d(TAG, "New state is " + currentState);
}
}
private SendState executeState(SendState state) {
switch (state) {
case SEND_OPTIONS:
return showSendOptions();
case START:
return startSend();
case AUTHENTICATE_MAPS:
return authenticateToGoogleMaps();
case PICK_MAP:
return pickMap();
case SEND_TO_MAPS:
return sendToGoogleMaps();
case SEND_TO_MAPS_DONE:
return onSendToGoogleMapsDone();
case AUTHENTICATE_FUSION_TABLES:
return authenticateToFusionTables();
case SEND_TO_FUSION_TABLES:
return sendToFusionTables();
case SEND_TO_FUSION_TABLES_DONE:
return onSendToFusionTablesDone();
case AUTHENTICATE_DOCS:
return authenticateToGoogleDocs();
case AUTHENTICATE_TRIX:
return authenticateToGoogleTrix();
case SEND_TO_DOCS:
return sendToGoogleDocs();
case SEND_TO_DOCS_DONE:
return onSendToGoogleDocsDone();
case SHOW_RESULTS:
return onSendToGoogleDone();
case SHARE_LINK:
return shareLink();
case FINISH:
return onAllDone();
default:
Log.e(TAG, "Reached a non-executable state");
return null;
}
}
private SendState showSendOptions() {
showDialog(SEND_DIALOG);
return SendState.NOT_READY;
}
/** /**
* Initiates the process to send tracks to google. * Initiates the process to send tracks to google.
* This is called once the user has selected sending options via the * This is called once the user has selected sending options via the
* SendToGoogleDialog. * SendToGoogleDialog.
*/ */
private void doSend() { private SendState startSend() {
showDialog(PROGRESS_DIALOG); showDialog(PROGRESS_DIALOG);
if (sendDialog.getSendToMyMaps()) { if (sendDialog.getSendToMyMaps()) {
sendToGoogleMapsOrPickMap(); return SendState.AUTHENTICATE_MAPS;
} else if (sendDialog.getSendToFusionTables()) { } else if (sendDialog.getSendToFusionTables()) {
authenticateToFusionTables(null); return SendState.AUTHENTICATE_FUSION_TABLES;
} else if (sendDialog.getSendToDocs()) { } else if (sendDialog.getSendToDocs()) {
authenticateToGoogleDocs(); return SendState.AUTHENTICATE_DOCS;
} else { } else {
Log.w(TAG, "Nowhere to upload to"); Log.w(TAG, "Nowhere to upload to");
onSendToGoogleDone(); return SendState.FINISH;
} }
} }
@@ -222,29 +309,29 @@ public class SendActivity extends Activity implements ProgressIndicator {
return progressDialog; return progressDialog;
} }
private void sendToGoogleMapsOrPickMap() { private SendState authenticateToGoogleMaps() {
Log.d(TAG, "SendActivity.authenticateToGoogleMaps");
progressDialog.setProgress(0);
progressDialog.setMessage(getString(
R.string.progress_message_authenticating_mymaps));
authenticate(Constants.AUTHENTICATE_TO_MY_MAPS, MyMapsConstants.SERVICE_NAME);
// AUTHENTICATE_TO_MY_MAPS callback calls sendToGoogleMaps
return SendState.NOT_READY;
}
private SendState pickMap() {
if (!sendDialog.getCreateNewMap()) { if (!sendDialog.getCreateNewMap()) {
// Ask the user to choose a map to upload into // Ask the user to choose a map to upload into
Intent listIntent = new Intent(this, MyMapsList.class); Intent listIntent = new Intent(this, MyMapsList.class);
startActivityForResult(listIntent, Constants.GET_MAP); startActivityForResult(listIntent, Constants.GET_MAP);
// The callback for GET_MAP calls authenticateToGoogleMaps // The callback for GET_MAP calls authenticateToGoogleMaps
return SendState.NOT_READY;
} else { } else {
authenticateToGoogleMaps(null); return SendState.SEND_TO_MAPS;
} }
} }
private void authenticateToGoogleMaps(Intent results) { private SendState sendToGoogleMaps() {
if (results == null) { results = new Intent(); }
progressDialog.setProgress(0);
progressDialog.setMessage(getString(
R.string.progress_message_authenticating_mymaps));
authenticate(results, Constants.AUTHENTICATE_TO_MY_MAPS,
MyMapsConstants.SERVICE_NAME);
// AUTHENTICATE_TO_MY_MAPS callback calls sendToGoogleMaps
}
private void sendToGoogleMaps(String mapId) {
tracker.trackPageView("/send/maps"); tracker.trackPageView("/send/maps");
SendToMyMaps.OnSendCompletedListener onCompletion = new SendToMyMaps.OnSendCompletedListener() { SendToMyMaps.OnSendCompletedListener onCompletion = new SendToMyMaps.OnSendCompletedListener() {
@@ -271,40 +358,46 @@ public class SendActivity extends Activity implements ProgressIndicator {
} }
} }
onSendToGoogleMapsDone(); executeStateMachine(SendState.SEND_TO_MAPS_DONE);
} }
}; };
final SendToMyMaps sender = new SendToMyMaps(this, mapId, lastAuth,
if (sendToMyMapsMapId == null) {
sendToMyMapsMapId = SendToMyMaps.NEW_MAP_ID;
}
final SendToMyMaps sender = new SendToMyMaps(this, sendToMyMapsMapId, lastAuth,
sendTrackId, this /*progressIndicator*/, onCompletion); sendTrackId, this /*progressIndicator*/, onCompletion);
// TODO: We're leaking this thread!
HandlerThread handlerThread = new HandlerThread("SendToMyMaps"); HandlerThread handlerThread = new HandlerThread("SendToMyMaps");
handlerThread.start(); handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper()); Handler handler = new Handler(handlerThread.getLooper());
handler.post(sender); handler.post(sender);
return SendState.NOT_READY;
} }
private void onSendToGoogleMapsDone() { private SendState onSendToGoogleMapsDone() {
if (sendDialog.getSendToFusionTables()) { if (sendDialog.getSendToFusionTables()) {
authenticateToFusionTables(null); return SendState.AUTHENTICATE_FUSION_TABLES;
} else if (sendDialog.getSendToDocs()) { } else if (sendDialog.getSendToDocs()) {
authenticateToGoogleDocs(); return SendState.AUTHENTICATE_DOCS;
} else { } else {
onSendToGoogleDone(); return SendState.SHOW_RESULTS;
} }
} }
private void authenticateToFusionTables(Intent results) { private SendState authenticateToFusionTables() {
if (results == null) { results = new Intent(); }
progressDialog.setProgress(0); progressDialog.setProgress(0);
progressDialog.setMessage(getString( progressDialog.setMessage(getString(
R.string.progress_message_authenticating_fusiontables)); R.string.progress_message_authenticating_fusiontables));
authenticate(results, Constants.AUTHENTICATE_TO_FUSION_TABLES, authenticate(Constants.AUTHENTICATE_TO_FUSION_TABLES, SendToFusionTables.SERVICE_ID);
SendToFusionTables.SERVICE_ID);
// AUTHENTICATE_TO_FUSION_TABLES callback calls sendToFusionTables // AUTHENTICATE_TO_FUSION_TABLES callback calls sendToFusionTables
return SendState.NOT_READY;
} }
private void sendToFusionTables() { private SendState sendToFusionTables() {
tracker.trackPageView("/send/fusion_tables"); tracker.trackPageView("/send/fusion_tables");
OnSendCompletedListener onCompletion = new OnSendCompletedListener() { OnSendCompletedListener onCompletion = new OnSendCompletedListener() {
@@ -332,47 +425,48 @@ public class SendActivity extends Activity implements ProgressIndicator {
} }
} }
onSendToFusionTablesDone(); executeStateMachine(SendState.SEND_TO_FUSION_TABLES_DONE);
} }
}; };
final SendToFusionTables sender = new SendToFusionTables(this, lastAuth, final SendToFusionTables sender = new SendToFusionTables(this, lastAuth,
sendTrackId, this /*progressIndicator*/, onCompletion); sendTrackId, this /*progressIndicator*/, onCompletion);
// TODO: We're leaking this thread!
HandlerThread handlerThread = new HandlerThread("SendToFusionTables"); HandlerThread handlerThread = new HandlerThread("SendToFusionTables");
handlerThread.start(); handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper()); Handler handler = new Handler(handlerThread.getLooper());
handler.post(sender); handler.post(sender);
return SendState.NOT_READY;
} }
private void onSendToFusionTablesDone() { private SendState onSendToFusionTablesDone() {
if (sendDialog.getSendToDocs()) { if (sendDialog.getSendToDocs()) {
authenticateToGoogleDocs(); return SendState.AUTHENTICATE_DOCS;
} else { } else {
onSendToGoogleDone(); return SendState.SHOW_RESULTS;
} }
} }
private void authenticateToGoogleDocs() { private SendState authenticateToGoogleDocs() {
setProgressValue(0); setProgressValue(0);
setProgressMessage( setProgressMessage(
R.string.progress_message_authenticating_docs); R.string.progress_message_authenticating_docs);
authenticate(new Intent(), authenticate(Constants.AUTHENTICATE_TO_DOCLIST, SendToDocs.GDATA_SERVICE_NAME_DOCLIST);
Constants.AUTHENTICATE_TO_DOCLIST,
SendToDocs.GDATA_SERVICE_NAME_DOCLIST);
// AUTHENTICATE_TO_DOCLIST callback calls authenticateToGoogleTrix // AUTHENTICATE_TO_DOCLIST callback calls authenticateToGoogleTrix
return SendState.NOT_READY;
} }
private void authenticateToGoogleTrix() { private SendState authenticateToGoogleTrix() {
setProgressValue(30); setProgressValue(30);
setProgressMessage( setProgressMessage(
R.string.progress_message_authenticating_docs); R.string.progress_message_authenticating_docs);
authenticate(new Intent(), authenticate(Constants.AUTHENTICATE_TO_TRIX, SendToDocs.GDATA_SERVICE_NAME_TRIX);
Constants.AUTHENTICATE_TO_TRIX,
SendToDocs.GDATA_SERVICE_NAME_TRIX);
// AUTHENTICATE_TO_TRIX callback calls sendToGoogleDocs // AUTHENTICATE_TO_TRIX callback calls sendToGoogleDocs
return SendState.NOT_READY;
} }
private void sendToGoogleDocs() { private SendState sendToGoogleDocs() {
Log.d(TAG, "Sending to Docs...."); Log.d(TAG, "Sending to Docs....");
tracker.trackPageView("/send/docs"); tracker.trackPageView("/send/docs");
@@ -390,18 +484,20 @@ public class SendActivity extends Activity implements ProgressIndicator {
sendToDocsMessage = sender.getStatusMessage(); sendToDocsMessage = sender.getStatusMessage();
sendToDocsSuccess = sender.wasSuccess(); sendToDocsSuccess = sender.wasSuccess();
onSendToGoogleDocsDone(); executeStateMachine(SendState.SEND_TO_DOCS_DONE);
} }
}; };
sender.setOnCompletion(onCompletion); sender.setOnCompletion(onCompletion);
sender.sendToDocs(sendTrackId); sender.sendToDocs(sendTrackId);
return SendState.NOT_READY;
} }
private void onSendToGoogleDocsDone() { private SendState onSendToGoogleDocsDone() {
onSendToGoogleDone(); return SendState.SHOW_RESULTS;
} }
private void onSendToGoogleDone() { private SendState onSendToGoogleDone() {
tracker.dispatch(); tracker.dispatch();
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@@ -418,6 +514,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
showDialog(DONE_DIALOG); showDialog(DONE_DIALOG);
} }
}); });
return SendState.NOT_READY;
} }
private Dialog createDoneDialog() { private Dialog createDoneDialog() {
@@ -440,8 +538,6 @@ public class SendActivity extends Activity implements ProgressIndicator {
// which we succeeded in uploading the track are incompatible with // which we succeeded in uploading the track are incompatible with
// sharing. We won't display a share button. // sharing. We won't display a share button.
final boolean sentToMyMaps = sendDialog.getSendToMyMaps();
final boolean sentToFusionTables = sendDialog.getSendToFusionTables();
List<SendResult> results = makeSendToGoogleResults(); List<SendResult> results = makeSendToGoogleResults();
final boolean canShare = sendToFusionTablesTableId != null || sendToMyMapsMapId != null; final boolean canShare = sendToFusionTablesTableId != null || sendToMyMapsMapId != null;
@@ -449,7 +545,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); dialog.dismiss();
onAllDone(); executeStateMachine(SendState.FINISH);
} }
}; };
@@ -460,11 +556,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); dialog.dismiss();
if (!shareLinkToMap(sentToMyMaps, sentToFusionTables)) { executeStateMachine(SendState.SHARE_LINK);
Log.w(TAG, "Failed to share link");
}
onAllDone();
} }
}; };
} }
@@ -477,7 +569,16 @@ public class SendActivity extends Activity implements ProgressIndicator {
return ResultDialogFactory.makeDialog(this, results, onOkListener, onShareListener, finishOnCancelListener); return ResultDialogFactory.makeDialog(this, results, onOkListener, onShareListener, finishOnCancelListener);
} }
private void onAllDone() { private SendState shareLink() {
boolean sentToMyMaps = sendDialog.getSendToMyMaps();
boolean sentToFusionTables = sendDialog.getSendToFusionTables();
if (!shareLinkToMap(sentToMyMaps, sentToFusionTables)) {
Log.w(TAG, "Failed to share link");
}
return SendState.FINISH;
}
private SendState onAllDone() {
Log.d(TAG, "All sending done."); Log.d(TAG, "All sending done.");
removeDialog(PROGRESS_DIALOG); removeDialog(PROGRESS_DIALOG);
removeDialog(SEND_DIALOG); removeDialog(SEND_DIALOG);
@@ -485,6 +586,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
progressDialog = null; progressDialog = null;
sendDialog = null; sendDialog = null;
finish(); finish();
return SendState.DONE;
} }
boolean shareLinkToMap(boolean sentToMyMaps, boolean sentToFusionTables) { boolean shareLinkToMap(boolean sentToMyMaps, boolean sentToFusionTables) {
@@ -553,8 +655,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
* Initializes the authentication manager which obtains an authentication * Initializes the authentication manager which obtains an authentication
* token, prompting the user for a login and password if needed. * token, prompting the user for a login and password if needed.
*/ */
private void authenticate(final Intent results, final int requestCode, private void authenticate(final int requestCode, final String service) {
final String service) {
lastAuth = authMap.get(service); lastAuth = authMap.get(service);
if (lastAuth == null) { if (lastAuth == null) {
Log.i(TAG, "Creating a new authentication for service: " + service); Log.i(TAG, "Creating a new authentication for service: " + service);
@@ -571,16 +672,15 @@ public class SendActivity extends Activity implements ProgressIndicator {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
chooseAccount(results, requestCode, service); chooseAccount(requestCode, service);
} }
}); });
} else { } else {
doLogin(results, requestCode, service, null); doLogin(requestCode, service, null);
} }
} }
private void chooseAccount(final Intent results, final int requestCode, private void chooseAccount(final int requestCode, final String service) {
final String service) {
accountChooser.chooseAccount(SendActivity.this, accountChooser.chooseAccount(SendActivity.this,
new AccountChooser.AccountHandler() { new AccountChooser.AccountHandler() {
@Override @Override
@@ -591,18 +691,17 @@ public class SendActivity extends Activity implements ProgressIndicator {
return; return;
} }
doLogin(results, requestCode, service, account); doLogin(requestCode, service, account);
} }
}); });
} }
private void doLogin(final Intent results, final int requestCode, private void doLogin(final int requestCode, final String service, final Account account) {
final String service, final Account account) {
// There's a chance that we go to a different activity, so close the dialog. // There's a chance that we go to a different activity, so close the dialog.
lastAuth.doLogin(new Runnable() { lastAuth.doLogin(new Runnable() {
public void run() { public void run() {
Log.i(TAG, "Login success for " + service + "!"); Log.i(TAG, "Login success for " + service + "!");
onActivityResult(requestCode, RESULT_OK, results); onActivityResult(requestCode, RESULT_OK, new Intent());
} }
}, account); }, account);
} }
@@ -610,84 +709,83 @@ public class SendActivity extends Activity implements ProgressIndicator {
@Override @Override
public void onActivityResult(int requestCode, int resultCode, public void onActivityResult(int requestCode, int resultCode,
final Intent results) { final Intent results) {
Log.w(TAG, "Result: req=" + requestCode + "; res=" + resultCode + "; result=" + results);
SendState nextState = null;
switch (requestCode) { switch (requestCode) {
case Constants.GET_LOGIN: { case Constants.GET_LOGIN: {
// TODO: This is a result from inside the auth manager, // TODO: This is a result from inside the auth manager,
// make this return path explicit. // make this return path explicit.
if (resultCode != RESULT_OK || lastAuth == null || if (resultCode != RESULT_OK || lastAuth == null ||
!lastAuth.authResult(resultCode, results)) { !lastAuth.authResult(resultCode, results)) {
dismissDialog(PROGRESS_DIALOG); nextState = SendState.FINISH;
finish();
} }
break;
} }
case Constants.GET_MAP: { case Constants.GET_MAP: {
// User picked a map to upload to // User picked a map to upload to
Log.d(TAG, "Get map result: " + resultCode);
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
results.putExtra("trackid", sendTrackId);
if (results.hasExtra("mapid")) { if (results.hasExtra("mapid")) {
sendToMyMapsMapId = results.getStringExtra("mapid"); sendToMyMapsMapId = results.getStringExtra("mapid");
} }
authenticateToGoogleMaps(results); nextState = SendState.SEND_TO_MAPS;
} else { } else {
onSendToGoogleDone(); nextState = SendState.FINISH;
} }
break; break;
} }
case Constants.AUTHENTICATE_TO_MY_MAPS: { case Constants.AUTHENTICATE_TO_MY_MAPS: {
// Authenticated with Google My Maps // Authenticated with Google My Maps
if (results != null && resultCode == RESULT_OK) { if (results != null && resultCode == RESULT_OK) {
final String mapId; nextState = SendState.PICK_MAP;
if (results.hasExtra("mapid")) {
mapId = results.getStringExtra("mapid");
} else {
mapId = "new";
}
sendToGoogleMaps(mapId);
} else { } else {
onSendToGoogleDone(); nextState = SendState.SHOW_RESULTS;
} }
break; break;
} }
case Constants.AUTHENTICATE_TO_FUSION_TABLES: { case Constants.AUTHENTICATE_TO_FUSION_TABLES: {
// Authenticated with Google Fusion Tables // Authenticated with Google Fusion Tables
if (results != null && resultCode == RESULT_OK) { if (results != null && resultCode == RESULT_OK) {
sendToFusionTables(); nextState = SendState.SEND_TO_FUSION_TABLES;
} else { } else {
onSendToGoogleDone(); nextState = SendState.SHOW_RESULTS;
} }
break; break;
} }
case Constants.AUTHENTICATE_TO_DOCLIST: { case Constants.AUTHENTICATE_TO_DOCLIST: {
// Authenticated with Google Docs // Authenticated with Google Docs
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
authenticateToGoogleTrix(); nextState = SendState.AUTHENTICATE_TRIX;
} else { } else {
onSendToGoogleDone(); nextState = SendState.SHOW_RESULTS;
} }
break; break;
} }
case Constants.AUTHENTICATE_TO_TRIX: { case Constants.AUTHENTICATE_TO_TRIX: {
// Authenticated with Trix // Authenticated with Trix
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
sendToGoogleDocs(); nextState = SendState.SEND_TO_DOCS;
} else { } else {
onSendToGoogleDone(); nextState = SendState.SHOW_RESULTS;
} }
break; break;
} }
default: { default: {
Log.w(TAG, "Warning unhandled request code: " + requestCode); Log.w(TAG, "Warning unhandled request code: " + requestCode);
return;
} }
} }
if (nextState != null) {
executeStateMachine(nextState);
}
} }
/** /**
* Resets status information for sending to MyMaps/Docs. * Resets status information for sending to MyMaps/Docs.
*/ */
private void resetState() { private void resetState() {
currentState = SendState.SEND_OPTIONS;
sendToMyMapsMapId = null; sendToMyMapsMapId = null;
sendToMyMapsMessage = ""; sendToMyMapsMessage = "";
sendToMyMapsSuccess = true; sendToMyMapsSuccess = true;