Don't crash on faulty search results translations (issue #184)

This commit is contained in:
Ciaran Gultnieks 2013-03-23 10:18:06 +00:00
parent 54fb62e186
commit 04e2966067

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2011-12 Ciaran Gultnieks, ciaran@ciarang.com * Copyright (C) 2011-13 Ciaran Gultnieks, ciaran@ciarang.com
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -95,16 +95,21 @@ public class SearchResults extends ListActivity {
} }
TextView tv = (TextView) findViewById(R.id.description); TextView tv = (TextView) findViewById(R.id.description);
String headertext; String headertexit;
if (apps.size() == 0) try
headertext = String.format(getString(R.string.searchres_noapps), {
mQuery); if (apps.size() == 0)
else if (apps.size() == 1) headertext = String.format(getString(R.string.searchres_noapps),
headertext = String.format(getString(R.string.searchres_oneapp), mQuery);
mQuery); else if (apps.size() == 1)
else headertext = String.format(getString(R.string.searchres_oneapp),
headertext = String.format(getString(R.string.searchres_napps), mQuery);
apps.size(), mQuery); else
headertext = String.format(getString(R.string.searchres_napps),
apps.size(), mQuery);
} catch(Exception ex) {
headertext = "TRANSLATION ERROR!";
}
tv.setText(headertext); tv.setText(headertext);
Log.d("FDroid", "Search for '" + mQuery + "' returned " + apps.size() Log.d("FDroid", "Search for '" + mQuery + "' returned " + apps.size()
+ " results"); + " results");