Skip to content

Commit

Permalink
Merge pull request #22 from bdbergeron/master
Browse files Browse the repository at this point in the history
Default to Roboto Regular instead of Thin when no typeface is specified.
  • Loading branch information
johnkil committed Apr 28, 2014
2 parents a3a6326 + d21aa94 commit 8d1c046
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class RobotoTypefaceManager {
* @return specify {@link Typeface}
* @throws IllegalArgumentException if unknown `typeface` attribute value.
*/
public static Typeface obtaintTypeface(Context context, int typefaceValue) throws IllegalArgumentException {
public static Typeface obtainTypeface (Context context, int typefaceValue) throws IllegalArgumentException {
Typeface typeface = mTypefaces.get(typefaceValue);
if (typeface == null) {
typeface = createTypeface(context, typefaceValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ private void onInitTypeface(Context context, AttributeSet attrs) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void onInitTypeface(Context context, AttributeSet attrs, int defStyle) {
return;
}

int typefaceValue = 0;
int typefaceValue = RobotoTypefaceManager.ROBOTO_REGULAR;
if (attrs != null) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView, defStyle, 0);
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, 0);
values.recycle();
if (values != null) {
typefaceValue = values.getInt(R.styleable.RobotoTextView_typeface, typefaceValue);
values.recycle();
}
}

Typeface robotoTypeface = RobotoTypefaceManager.obtaintTypeface(context, typefaceValue);
Typeface robotoTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue);
setTypeface(robotoTypeface);
}

Expand Down

0 comments on commit 8d1c046

Please sign in to comment.