forked from organicmaps/organicmaps
[android] Added parent assertion
This commit is contained in:
parent
f226a57872
commit
681f22c88e
1 changed files with 15 additions and 1 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue