Skip to content

Commit

Permalink
fix: Various crashes reported through Google Play.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellsundt committed Nov 18, 2014
1 parent 773dd50 commit 76ff484
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/org/odk/collect/android/activities/FormDownloadList.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,13 @@ protected void onListItemClick(ListView l, View v, int position, long id) {
Object o = getListAdapter().getItem(position);
@SuppressWarnings("unchecked")
HashMap<String, String> item = (HashMap<String, String>) o;
FormDetails detail = mFormNamesAndURLs.get(item.get(FORMDETAIL_KEY));
FormDetails detail = mFormNamesAndURLs.get(item.get(FORMDETAIL_KEY));

if ( detail != null ) {
Collect.getInstance().getActivityLogger().logAction(this, "onListItemClick", detail.downloadUrl);
} else {
Collect.getInstance().getActivityLogger().logAction(this, "onListItemClick", "<missing form detail>");
}
}


Expand Down
14 changes: 10 additions & 4 deletions src/org/odk/collect/android/activities/FormEntryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1764,8 +1764,15 @@ private boolean saveDataToDisk(boolean exit, boolean complete, String updatedSav
* saving
*/
private void createQuitDialog() {
FormController formController = Collect.getInstance()
.getFormController();
String title;
{
FormController formController = Collect.getInstance().getFormController();
title = (formController == null) ? null : formController.getFormTitle();
if ( title == null ) {
title = "<no form loaded>";
}
}

String[] items;
if (mAdminPreferences.getBoolean(AdminPreferencesActivity.KEY_SAVE_MID,
true)) {
Expand All @@ -1782,8 +1789,7 @@ private void createQuitDialog() {
mAlertDialog = new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle(
getString(R.string.quit_application,
formController.getFormTitle()))
getString(R.string.quit_application, title))
.setNeutralButton(getString(R.string.do_not_exit),
new DialogInterface.OnClickListener() {
@Override
Expand Down
14 changes: 10 additions & 4 deletions src/org/odk/collect/android/tasks/DownloadFormsTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,19 @@ protected HashMap<FormDetails, String> doInBackground(ArrayList<FormDetails>...
// do not download additional forms.
break;
} catch (Exception e) {
Log.e(t, e.getMessage());
String msg = e.getMessage();
if ( msg == null ) {
msg = e.toString();
}
Log.e(t, msg);

if (e.getCause() != null) {
message += e.getCause().getMessage();
} else {
message += e.getMessage();
msg = e.getCause().getMessage();
if ( msg == null ) {
msg = e.getCause().toString();
}
}
message += msg;
}

if (!isCancelled() && message.length() == 0 && fileResult != null) {
Expand Down
9 changes: 8 additions & 1 deletion src/org/odk/collect/android/widgets/SelectOneWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,15 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
}

SelectChoice choice = mItems.get((Integer)buttonView.getTag());

if ( choice != null ) {
Collect.getInstance().getActivityLogger().logInstanceAction(this, "onCheckedChanged",
mItems.get((Integer)buttonView.getTag()).getValue(), mPrompt.getIndex());
choice.getValue(), mPrompt.getIndex());
} else {
Collect.getInstance().getActivityLogger().logInstanceAction(this, "onCheckedChanged",
"<no matching choice>", mPrompt.getIndex());
}
}

@Override
Expand Down

0 comments on commit 76ff484

Please sign in to comment.