catch exception of IntentGenerator.getTitle(...)

This commit is contained in:
Philipp Schaefer 2014-02-23 12:47:16 +01:00
parent b642ec2299
commit 58c68edb81
4 changed files with 14 additions and 14 deletions

7
mobile/.idea/misc.xml generated
View File

@ -3,13 +3,6 @@
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="GradleLocalSettings">
<option name="modificationStamps">
<map>
<entry key="$PROJECT_DIR$/../../ShowcaseView/library" value="1379967589662" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android 4.4 Platform" project-jdk-type="Android SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>

View File

@ -36,7 +36,12 @@ class IntentAdapter extends ArrayAdapter<Intent> {
final Intent item = getItem(position);
try {
view.setText(IntentGenerator.getTitle(item));
} catch (IllegalArgumentException e) {
view.setText("unknown");
Log.w(e);
}
view.setCompoundDrawablePadding((int) getContext().getResources().getDimension(R.dimen.icon_margin));
// get icon and scale it manually to ensure that all have the same size

View File

@ -78,9 +78,12 @@ public class IntentComparator implements Comparator<Intent> {
if (lCount < rCount) return 1;
// still no order. fall back to alphabetical order
try {
order = IntentGenerator.getTitle(lhs).compareTo(IntentGenerator.getTitle(rhs));
if (order != 0) return order;
} catch(IllegalArgumentException e) {
Log.w(e);
}
order = lComponent.getPackageName().compareTo(rComponent.getPackageName());
if (order != 0) return order;

View File

@ -34,9 +34,8 @@ public class IntentGenerator {
}
}
public static String getTitle(final Intent intent) {
if (intent.hasExtra(EXTRA_FLAG_TITLE))
return intent.getStringExtra(EXTRA_FLAG_TITLE);
public static String getTitle(final Intent intent) throws IllegalArgumentException {
if (intent.hasExtra(EXTRA_FLAG_TITLE)) return intent.getStringExtra(EXTRA_FLAG_TITLE);
throw new IllegalArgumentException("Got an intent not generated by IntentGenerator");
}