From df818b0aed705778ce3a7d6c2a1667bfe81b128e Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 30 Jul 2019 22:27:36 +0200 Subject: [PATCH] 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. --- .../java/org/fdroid/fdroid/nearby/SwapView.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/SwapView.java b/app/src/full/java/org/fdroid/fdroid/nearby/SwapView.java index 864bc980c..f400d1ef6 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/SwapView.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/SwapView.java @@ -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)