-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add ignoreClass to Builder #189
Open
Malinskiy
wants to merge
5
commits into
chrisjenx:master
Choose a base branch
from
Malinskiy:feature/ignore_class
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aa5163a
Add ignoreClass to Builder
Malinskiy c30fa1d
Add sample IconTextView in to CalligraphySample
Malinskiy c32d9f7
Add calligraphyIgnore attribute to ignore views by Calligraphy
Malinskiy 92375fb
Add example for calligraphyIgnore attribute
Malinskiy fbb47b0
Move isIgnoredClass to CalligraphyUtils
Malinskiy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,10 @@ public View onViewCreated(View view, Context context, AttributeSet attrs) { | |
} | ||
|
||
void onViewCreatedInternal(View view, final Context context, AttributeSet attrs) { | ||
if (view instanceof TextView) { | ||
if (!CalligraphyConfig.get().isIgnoredClass(view.getClass()) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isIgnoredClass should take the current view and the Configuration separately as method arguments. |
||
!CalligraphyUtils.pullIgnoredFromView(context, attrs) && | ||
view instanceof TextView) { | ||
|
||
// Fast path the setting of TextView's font, means if we do some delayed setting of font, | ||
// which has already been set by use we skip this TextView (mainly for inflating custom, | ||
// TextView's inside the Toolbar/ActionBar). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,6 +170,27 @@ static String pullFontPathFromView(Context context, AttributeSet attrs, int attr | |
: attrs.getAttributeValue(null, attributeName); | ||
} | ||
|
||
/** | ||
* Tries to pull the Ingored Attribute directly from the View. | ||
* @param context Activity Context | ||
* @param attrs View Attributes | ||
* @return false if attribute is not defined or added to View | ||
*/ | ||
static boolean pullIgnoredFromView(Context context, AttributeSet attrs) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add this as a separate pull-request. |
||
if (attrs == null) | ||
return false; | ||
|
||
final String attributeName; | ||
try { | ||
attributeName = context.getResources().getResourceEntryName(R.attr.calligraphyIgnore); | ||
} catch (Resources.NotFoundException e) { | ||
// invalid attribute ID | ||
return false; | ||
} | ||
|
||
return attrs.getAttributeBooleanValue(null, attributeName, false); | ||
} | ||
|
||
/** | ||
* Tries to pull the Font Path from the View Style as this is the next decendent after being | ||
* defined in the View's xml. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<attr name="fontPath" format="string"/> | ||
<attr name="calligraphyIgnore" format="boolean"/> | ||
</resources> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be on the Utils class as this isn't really a configuration method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrisjenx where should I store collection of ignored classes if it will be in utils?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be in the Config. Just iterating across the list should not be done inside of the Config. Config should be just immutable state storage.