Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a675e3a4 authored by Yorke Lee's avatar Yorke Lee
Browse files

Don't crash if R.styleable int array is null

Workaround for a very very strange test/AAPT/ART bug that causes
R.styleable int arrays to be null during test instrumentation even
though the values are there in the generated R files and via
reflection.

These changes have no effect on production since those fields should
never be null then but help to prevent tests from failing.

Change-Id: Ic986f6411886ef5d5858ec15f2e9f68826a5dd39
parent e8862171
Loading
Loading
Loading
Loading
+58 −49
Original line number Diff line number Diff line
@@ -239,8 +239,11 @@ public class ContactListItemView extends ViewGroup
    public ContactListItemView(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray a;

        if (R.styleable.ContactListItemView != null) {
            // Read all style values
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ContactListItemView);
            a = getContext().obtainStyledAttributes(attrs, R.styleable.ContactListItemView);
            mPreferredHeight = a.getDimensionPixelSize(
                    R.styleable.ContactListItemView_list_item_height, mPreferredHeight);
            mActivatedBackgroundDrawable = a.getDrawable(
@@ -256,7 +259,8 @@ public class ContactListItemView extends ViewGroup
                    R.styleable.ContactListItemView_list_item_presence_icon_margin,
                    mPresenceIconMargin);
            mPresenceIconSize = a.getDimensionPixelOffset(
                R.styleable.ContactListItemView_list_item_presence_icon_size, mPresenceIconSize);
                    R.styleable.ContactListItemView_list_item_presence_icon_size,
                    mPresenceIconSize);
            mDefaultPhotoViewSize = a.getDimensionPixelOffset(
                    R.styleable.ContactListItemView_list_item_photo_size, mDefaultPhotoViewSize);
            mTextIndent = a.getDimensionPixelOffset(
@@ -264,12 +268,14 @@ public class ContactListItemView extends ViewGroup
            mTextOffsetTop = a.getDimensionPixelOffset(
                    R.styleable.ContactListItemView_list_item_text_offset_top, mTextOffsetTop);
            mDataViewWidthWeight = a.getInteger(
                R.styleable.ContactListItemView_list_item_data_width_weight, mDataViewWidthWeight);
                    R.styleable.ContactListItemView_list_item_data_width_weight,
                    mDataViewWidthWeight);
            mLabelViewWidthWeight = a.getInteger(
                    R.styleable.ContactListItemView_list_item_label_width_weight,
                    mLabelViewWidthWeight);
            mNameTextViewTextColor = a.getColor(
                R.styleable.ContactListItemView_list_item_name_text_color, mNameTextViewTextColor);
                    R.styleable.ContactListItemView_list_item_name_text_color,
                    mNameTextViewTextColor);
            mNameTextViewTextSize = (int) a.getDimension(
                    R.styleable.ContactListItemView_list_item_name_text_size,
                    (int) getResources().getDimension(R.dimen.contact_browser_list_item_text_size));
@@ -284,13 +290,16 @@ public class ContactListItemView extends ViewGroup
                    a.getDimensionPixelOffset(
                            R.styleable.ContactListItemView_list_item_padding_bottom, 0));

        mTextHighlighter = new TextHighlighter(Typeface.BOLD);

            a.recycle();
        }

        mTextHighlighter = new TextHighlighter(Typeface.BOLD);

        if (R.styleable.Theme != null) {
            a = getContext().obtainStyledAttributes(R.styleable.Theme);
            mSecondaryTextColor = a.getColorStateList(R.styleable.Theme_android_textColorSecondary);
            a.recycle();
        }

        mHeaderWidth =
                getResources().getDimensionPixelSize(R.dimen.contact_list_section_header_width);
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ public class ContactListPinnedHeaderView extends TextView {
    public ContactListPinnedHeaderView(Context context, AttributeSet attrs, View parent) {
        super(context, attrs);

        if (R.styleable.ContactListItemView == null) {
            return;
        }
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ContactListItemView);
        int backgroundColor = a.getColor(
                R.styleable.ContactListItemView_list_item_background_color, Color.WHITE);