Skip to content

Commit

Permalink
Merge pull request #1 from Obsidian96/master
Browse files Browse the repository at this point in the history
Fixed issue InflationX#30
  • Loading branch information
dbsima authored Oct 24, 2019
2 parents 881f11f + 330e86e commit 0a9520d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 3.1.2 (23/10/2019)
- Fixed crash in webview

## 3.1.1 (16/04/2019)
- Use custom reflection utils rather than depend on ViewPump internals
- Added support for loading a font from an absolute path
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Include the dependency [Download (.aar)](http://search.maven.org/remotecontent?f

```groovy
dependencies {
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:calligraphy3:3.1.2'
implementation 'io.github.inflationx:viewpump:2.0.3'
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.TextView;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;

class Calligraphy {

private static final String ACTION_BAR_TITLE = "action_bar_title";
private static final String ACTION_BAR_SUBTITLE = "action_bar_subtitle";
private static final String TAG = Calligraphy.class.getSimpleName();

/**
* Some styles are in sub styles, such as actionBarTextStyle etc..
Expand Down Expand Up @@ -91,7 +95,7 @@ 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());
final String resourceEntryName = getResourceEntryName(view);
return resourceEntryName.equalsIgnoreCase(matches);
}

Expand All @@ -103,6 +107,16 @@ public Calligraphy(CalligraphyConfig calligraphyConfig) {
this.mAttributeId = new int[]{calligraphyConfig.getAttrId()};
}

@NonNull
private static String getResourceEntryName(@NonNull View view) {
try {
return view.getResources().getResourceEntryName(view.getId());
} catch (Resources.NotFoundException exception) {
Log.w(TAG, "An error occurred when trying to get resource entry name.", exception);
return "";
}
}

/**
* Handle the created view
*
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# org.gradle.parallel=true

GROUP=io.github.inflationx
VERSION_NAME=3.1.2-SNAPSHOT
VERSION_NAME=3.1.2
VERSION_CODE=32

POM_PACKAGING=aar
Expand Down

0 comments on commit 0a9520d

Please sign in to comment.