catch exception of IntentGenerator.getTitle(...)
This commit is contained in:
parent
b642ec2299
commit
58c68edb81
7
mobile/.idea/misc.xml
generated
7
mobile/.idea/misc.xml
generated
@ -3,13 +3,6 @@
|
|||||||
<component name="EntryPointsManager">
|
<component name="EntryPointsManager">
|
||||||
<entry_points version="2.0" />
|
<entry_points version="2.0" />
|
||||||
</component>
|
</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">
|
<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" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
|
@ -36,7 +36,12 @@ class IntentAdapter extends ArrayAdapter<Intent> {
|
|||||||
|
|
||||||
final Intent item = getItem(position);
|
final Intent item = getItem(position);
|
||||||
|
|
||||||
view.setText(IntentGenerator.getTitle(item));
|
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));
|
view.setCompoundDrawablePadding((int) getContext().getResources().getDimension(R.dimen.icon_margin));
|
||||||
|
|
||||||
// get icon and scale it manually to ensure that all have the same size
|
// get icon and scale it manually to ensure that all have the same size
|
||||||
|
@ -78,9 +78,12 @@ public class IntentComparator implements Comparator<Intent> {
|
|||||||
if (lCount < rCount) return 1;
|
if (lCount < rCount) return 1;
|
||||||
|
|
||||||
// still no order. fall back to alphabetical order
|
// still no order. fall back to alphabetical order
|
||||||
order = IntentGenerator.getTitle(lhs).compareTo(IntentGenerator.getTitle(rhs));
|
try {
|
||||||
if (order != 0) return order;
|
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());
|
order = lComponent.getPackageName().compareTo(rComponent.getPackageName());
|
||||||
if (order != 0) return order;
|
if (order != 0) return order;
|
||||||
|
|
||||||
|
@ -34,9 +34,8 @@ public class IntentGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTitle(final Intent intent) {
|
public static String getTitle(final Intent intent) throws IllegalArgumentException {
|
||||||
if (intent.hasExtra(EXTRA_FLAG_TITLE))
|
if (intent.hasExtra(EXTRA_FLAG_TITLE)) return intent.getStringExtra(EXTRA_FLAG_TITLE);
|
||||||
return intent.getStringExtra(EXTRA_FLAG_TITLE);
|
|
||||||
|
|
||||||
throw new IllegalArgumentException("Got an intent not generated by IntentGenerator");
|
throw new IllegalArgumentException("Got an intent not generated by IntentGenerator");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user