Skip to content

Commit

Permalink
Fix a bug that NullPointerException occurs during preview ogaclejapan#3
Browse files Browse the repository at this point in the history
  • Loading branch information
ogaclejapan committed Apr 29, 2015
1 parent bf66df1 commit 89a1f05
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions library/src/main/java/com/ogaclejapan/arclayout/ArcLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ public ArcLayout(Context context, AttributeSet attrs, int defStyleAttr, int defS
protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
setWillNotDraw(false);

if (isInEditMode()) {
return;
}

final TypedArray a = context.getTheme().obtainStyledAttributes(
attrs, R.styleable.arc_ArcLayout, defStyleAttr, defStyleRes);
int origin = a.getInt(R.styleable.arc_ArcLayout_arc_origin, DEFAULT_ORIGIN);
Expand Down Expand Up @@ -133,9 +129,14 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (isInEditMode()) {
return;
}

if (Utils.DEBUG) {
Utils.d(TAG, "onLayout: l=%d, t=%d, r=%d, b=%d", l, t, r, b);
}

mArcDrawable.setBounds(0, 0, r - l, b - t);

final Point o = mArc.computeOrigin(0, 0, mSize.x, mSize.y);
Expand Down Expand Up @@ -174,6 +175,10 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {

@Override
protected void onDraw(Canvas canvas) {
if (isInEditMode()) {
return;
}

super.onDraw(canvas);
mArcDrawable.draw(canvas);
}
Expand Down

0 comments on commit 89a1f05

Please sign in to comment.