From 681f22c88e401f68eafa06f7c7bedf898de7a111 Mon Sep 17 00:00:00 2001 From: Dmitry Donskoy Date: Thu, 26 Jul 2018 13:08:27 +0300 Subject: [PATCH] [android] Added parent assertion --- .../mapswithme/maps/widget/PlaceholderView.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/android/src/com/mapswithme/maps/widget/PlaceholderView.java b/android/src/com/mapswithme/maps/widget/PlaceholderView.java index bed568ae91..4697f7696a 100644 --- a/android/src/com/mapswithme/maps/widget/PlaceholderView.java +++ b/android/src/com/mapswithme/maps/widget/PlaceholderView.java @@ -9,12 +9,14 @@ import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; +import android.support.v4.widget.NestedScrollView; import android.util.AttributeSet; -import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewParent; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.ScrollView; import android.widget.TextView; import com.mapswithme.maps.R; @@ -107,6 +109,7 @@ public class PlaceholderView extends LinearLayout { super.onFinishInflate(); + checkParent(); mImage = findViewById(R.id.image); mTitle = findViewById(R.id.title); mSubtitle = findViewById(R.id.subtitle); @@ -114,6 +117,17 @@ public class PlaceholderView extends LinearLayout setupDefaultContent(); } + private void checkParent() + { + ViewParent current = getParent(); + while (current != null) + { + if (current instanceof NestedScrollView || current instanceof ScrollView) + throw new IllegalStateException("PlaceholderView can not be attached to NestedScrollView or ScrollView"); + current = current.getParent(); + } + } + private void setupDefaultContent() { if (isDefaultValueValid(mImage, mImgSrcDefault))