mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 778081: No NullPointerException in CommandProcessor.getArgsList. r=rnewman
--HG-- extra : rebase_source : 8fd9757ef2b385f6d033e278864d8b2770aceb4a
This commit is contained in:
parent
fc793aafff
commit
a426db70af
@ -92,3 +92,4 @@
|
||||
<!ENTITY sync.title.redirect.to.set.up.sync.label 'Set up &syncBrand.shortName.label; to send tabs'>
|
||||
<!ENTITY sync.text.redirect.to.set.up.sync.label 'Set up &syncBrand.fullName.label; on your device to send tabs to other devices.'>
|
||||
<!ENTITY sync.text.tab.sent.label 'Your tab was sent!'>
|
||||
<!ENTITY sync.text.tab.not.sent.label 'There was a problem sending your tab.'>
|
||||
|
@ -64,12 +64,22 @@ public class CommandProcessor {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of arguments as strings. Individual arguments may be null.
|
||||
*
|
||||
* @return list of strings.
|
||||
*/
|
||||
public synchronized List<String> getArgsList() {
|
||||
if (argsList == null) {
|
||||
ArrayList<String> argsList = new ArrayList<String>(args.size());
|
||||
|
||||
for (int i = 0; i < args.size(); i++) {
|
||||
argsList.add(args.get(i).toString());
|
||||
final Object arg = args.get(i);
|
||||
if (arg == null) {
|
||||
argsList.add(null);
|
||||
continue;
|
||||
}
|
||||
argsList.add(arg.toString());
|
||||
}
|
||||
this.argsList = argsList;
|
||||
}
|
||||
|
@ -117,7 +117,16 @@ public class SendTabActivity extends Activity {
|
||||
Bundle extras = this.getIntent().getExtras();
|
||||
final String uri = extras.getString(Intent.EXTRA_TEXT);
|
||||
final String title = extras.getString(Intent.EXTRA_SUBJECT);
|
||||
final CommandProcessor processor = CommandProcessor.getProcessor();
|
||||
|
||||
if (uri == null) {
|
||||
Logger.warn(LOG_TAG, "uri was null; aborting without sending tab.");
|
||||
notifyAndFinish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (title == null) {
|
||||
Logger.warn(LOG_TAG, "title was null; ignoring and sending tab anyway.");
|
||||
}
|
||||
|
||||
final String clientGUID = getAccountGUID();
|
||||
final List<String> guids = arrayAdapter.getCheckedGUIDs();
|
||||
@ -126,7 +135,7 @@ public class SendTabActivity extends Activity {
|
||||
// Should never happen.
|
||||
Logger.warn(LOG_TAG, "clientGUID? " + (clientGUID == null) + " or guids? " + (guids == null) +
|
||||
" was null; aborting without sending tab.");
|
||||
finish();
|
||||
notifyAndFinish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -134,6 +143,8 @@ public class SendTabActivity extends Activity {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
final CommandProcessor processor = CommandProcessor.getProcessor();
|
||||
|
||||
for (String guid : guids) {
|
||||
processor.sendURIToClientForDisplay(uri, guid, title, clientGUID, getApplicationContext());
|
||||
}
|
||||
@ -143,19 +154,28 @@ public class SendTabActivity extends Activity {
|
||||
}
|
||||
}.start();
|
||||
|
||||
notifyAndFinish();
|
||||
notifyAndFinish(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the user that tabs were sent and then finish the activity.
|
||||
* Notify the user about sent tabs status and then finish the activity.
|
||||
* <p>
|
||||
* This is a bit of a misnomer: we wrote "displayURI" commands to the local
|
||||
* "Success" is a bit of a misnomer: we wrote "displayURI" commands to the local
|
||||
* command database, and they will be sent on next sync. There is no way to
|
||||
* verify that the commands were successfully received by the intended remote
|
||||
* client, so we lie and say they were sent.
|
||||
*
|
||||
* @param success true if tab was sent successfully; false otherwise.
|
||||
*/
|
||||
private void notifyAndFinish() {
|
||||
Toast.makeText(this, R.string.sync_text_tab_sent, Toast.LENGTH_LONG).show();
|
||||
protected void notifyAndFinish(final boolean success) {
|
||||
int textId;
|
||||
if (success) {
|
||||
textId = R.string.sync_text_tab_sent;
|
||||
} else {
|
||||
textId = R.string.sync_text_tab_not_sent;
|
||||
}
|
||||
|
||||
Toast.makeText(this, textId, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
@ -85,3 +85,4 @@
|
||||
<string name="sync_title_redirect_to_set_up_sync">&sync.title.redirect.to.set.up.sync.label;</string>
|
||||
<string name="sync_text_redirect_to_set_up_sync">&sync.text.redirect.to.set.up.sync.label;</string>
|
||||
<string name="sync_text_tab_sent">&sync.text.tab.sent.label;</string>
|
||||
<string name="sync_text_tab_not_sent">&sync.text.tab.not.sent.label;</string>
|
||||
|
Loading…
Reference in New Issue
Block a user