diff --git a/CalligraphySample/src/main/res/layout/fragment_main.xml b/CalligraphySample/src/main/res/layout/fragment_main.xml index 4c7bc46..3b7b223 100644 --- a/CalligraphySample/src/main/res/layout/fragment_main.xml +++ b/CalligraphySample/src/main/res/layout/fragment_main.xml @@ -17,12 +17,14 @@ tools:ignore="MissingPrefix"> diff --git a/calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyFactory.java b/calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyFactory.java index ca45b62..1f38704 100644 --- a/calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyFactory.java +++ b/calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyFactory.java @@ -3,6 +3,7 @@ import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; +import android.content.res.Resources; import android.os.Build; import android.text.TextUtils; import android.util.AttributeSet; @@ -86,8 +87,13 @@ protected static boolean parentIsToolbarV7(View view) { */ protected static boolean matchesResourceIdName(View view, String matches) { if (view.getId() == View.NO_ID) return false; - final String resourceEntryName = view.getResources().getResourceEntryName(view.getId()); - return resourceEntryName.equalsIgnoreCase(matches); + try { + final String resourceEntryName = view.getResources().getResourceEntryName(view.getId()); + return resourceEntryName.equalsIgnoreCase(matches); + } catch (Resources.NotFoundException ex) { + // If the view is not found, return false, same as if we were not given an id + return false; + } } private final int mAttributeId;