fix crash in SwapView on android < 21

In order to support Android < 21, this calls `super` rather than `this`.
RelativeLayout}'s methods just use a 0 for the fourth argument, just like
this used to.
This commit is contained in:
Hans-Christoph Steiner 2019-07-30 22:27:36 +02:00
parent f5a5805610
commit df818b0aed
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA

View File

@ -32,8 +32,19 @@ public class SwapView extends RelativeLayout {
this(context, attrs, 0);
}
/**
* In order to support Android < 21, this calls {@code super} rather than
* {@code this}. {@link RelativeLayout}'s methods just use a 0 for the
* fourth argument, just like this used to.
*/
public SwapView(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.SwapView, 0, 0);
toolbarColor = a.getColor(R.styleable.SwapView_toolbarColor,
getResources().getColor(R.color.swap_blue));
toolbarTitle = a.getString(R.styleable.SwapView_toolbarTitle);
a.recycle();
}
@TargetApi(21)