Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #160 - Crash when using labelFor attribute #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CalligraphySample/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
tools:ignore="MissingPrefix">

<TextView
android:id="@+id/basic_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/default_theme"/>

<TextView
fontPath="fonts/Roboto-Bold.ttf"
android:labelFor="@id/basic_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/defined_fontpath_view"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down