Obtains the margin of the preference's dialog from a specific typed array.

@param typedArray
The typed array, the margin should be obtained from, as an instance of the class
{@link TypedArray}. The typed array may not be null
769251
private void obtainDialogMargin(@NonNull final TypedArray typedArray) {
        int defaultHorizontalMargin =
                getContext().getResources().getDimensionPixelSize(R.dimen.dialog_horizontal_margin);
        int defaultVerticalMargin =
                getContext().getResources().getDimensionPixelSize(R.dimen.dialog_vertical_margin);
        int left = typedArray.getDimensionPixelSize(R.styleable.DialogPreference_dialogMarginLeft,
                defaultHorizontalMargin);
        int top = typedArray.getDimensionPixelSize(R.styleable.DialogPreference_dialogMarginTop,
                defaultVerticalMargin);
        int right = typedArray.getDimensionPixelSize(R.styleable.DialogPreference_dialogMarginRight,
                defaultHorizontalMargin);
        int bottom = typedArray
                .getDimensionPixelSize(R.styleable.DialogPreference_dialogMarginBottom,
                        defaultVerticalMargin);
        setDialogMargin(left, top, right, bottom);
    }
900923
private void obtainInsetForeground(@NonNull final TypedArray typedArray) {
        int color = typedArray.getColor(R.styleable.ScrimInsetsLayout_insetDrawable, -1);

        if (color == -1) {
            Drawable drawable = typedArray.getDrawable(R.styleable.ScrimInsetsLayout_insetDrawable);

            if (drawable != null) {
                setInsetDrawable(drawable);
            } else {
                setInsetColor(ContextCompat.getColor(getContext(),
                        R.color.scrim_insets_layout_insets_drawable_default_value));
            }
        } else {
            setInsetColor(color);
        }
    }
505227
@SuppressLint("Recycle")
    public static TypedArray getDialogStyledAttributes(Context activity, int[] attrs, int defStyleAttr, int defStyleRef) {
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        AlertDialog dialog = builder.create();
        TypedArray ta = dialog.getContext().obtainStyledAttributes(null, attrs, defStyleAttr, defStyleRef);
        dialog.dismiss();
        return ta;
    }
1374039
private void obtainDialogTheme(@NonNull final TypedArray typedArray) {
        int themeId = typedArray.getResourceId(R.styleable.DialogPreference_dialogThemeResource, 0);

        if (themeId == 0) {
            TypedValue typedValue = new TypedValue();
            getContext().getTheme()
                    .resolveAttribute(R.attr.preferenceDialogTheme, typedValue, true);
            themeId = typedValue.resourceId;
        }

        dialogTheme = themeId != 0 ? themeId : R.style.MaterialDialog_Light;
    }
926501
private static int sortAbstractLongArray(Block array, long[] buffer, AbstractType type)
    {
        int arraySize = array.getPositionCount();
        int nonNullSize = 0;
        for (int i = 0; i < arraySize; i++) {
            if (!array.isNull(i)) {
                buffer[nonNullSize++] = type.getLong(array, i);
            }
        }
        for (int i = 1; i < nonNullSize; i++) {
            if (buffer[i - 1] > buffer[i]) {
                Arrays.sort(buffer, 0, nonNullSize);
                break;
            }
        }
        return nonNullSize;
    }
549782
public static <T extends Comparable<? super T>> void ascDeep(final T[] comparableArray) {

        if (ArrayUtils.isEmpty(comparableArray)) {
            return;
        }
        ascByReflex(comparableArray);
    }
329727
private void obtainShadowOrientation(@NonNull final TypedArray typedArray) {
        int defaultValue = getResources()
                .getInteger(R.integer.elevation_shadow_view_shadow_orientation_default_value);
        orientation = Orientation.fromValue(typedArray
                .getInteger(R.styleable.ElevationShadowView_shadowOrientation, defaultValue));
    }
1220284
private void obtainDisableDependantsState(@NonNull final TypedArray typedArray) {
        boolean defaultValue = getContext().getResources()
                .getBoolean(R.bool.two_state_preference_default_disable_dependents_state);
        setDisableDependentsState(typedArray
                .getBoolean(R.styleable.AbstractTwoStatePreference_android_disableDependentsState,
                        defaultValue));
    }
224191
public static <T extends Comparable<? super T>> T[] desc(final T[] comparableArray) {

        if (comparableArray == null) {
            return null;
        }
        T[] clone = comparableArray.clone();
        descByReflex(clone);
        return clone;
    }
860184
public void newarray(TypeMirror type, int count) throws IOException
    {
        if (type.getKind() != TypeKind.ARRAY)
        {
            throw new IllegalArgumentException(type+" is not array");
        }
        ArrayType at = (ArrayType) type;
        iconst(count);
        TypeMirror ct = at.getComponentType();
        switch (ct.getKind())
        {
            case BOOLEAN:
                newarray(T_BOOLEAN);
                break;
            case CHAR:
                newarray(T_CHAR);
                break;
            case FLOAT:
                newarray(T_FLOAT);
                break;
            case DOUBLE:
                newarray(T_DOUBLE);
                break;
            case BYTE:
                newarray(T_BYTE);
                break;
            case SHORT:
                newarray(T_SHORT);
                break;
            case INT:
                newarray(T_INT);
                break;
            case LONG:
                newarray(T_LONG);
                break;
            case DECLARED:
            {
                DeclaredType dt = (DeclaredType) ct;
                int index = subClass.resolveClassIndex((TypeElement)dt.asElement());
                anewarray(index);
            }
                break;
            default:
                throw new IllegalArgumentException(type+" not supported");
        }
    }
529124
private void obtainDialogMessage(@NonNull final TypedArray typedArray) {
        setDialogMessage(typedArray.getText(R.styleable.DialogPreference_android_dialogMessage));
    }
57304
@SafeVarargs
    public static <V extends Comparable<V>> V[] sort(V... array) {
        Arrays.sort(array);
        return array;
    }
728444
public static Type getArrayComponentType(Type type) {
		if (type instanceof Class) {
			Class<?> clazz = (Class<?>)type;
			return clazz.getComponentType();
		} else if (type instanceof GenericArrayType) {
			GenericArrayType aType = (GenericArrayType) type;
			return aType.getGenericComponentType();
		} else {
			return null;
		}
	}
6336
private void setTopMargin(final int margin) {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams();
        layoutParams.topMargin = margin;
        setLayoutParams(layoutParams);
    }
1046897
private void obtainTextColor(@NonNull final TypedArray typedArray) {
        ColorStateList colorStateList =
                typedArray.getColorStateList(R.styleable.ActionPreference_android_textColor);

        if (colorStateList == null) {
            colorStateList = ContextCompat
                    .getColorStateList(getContext(), R.color.action_preference_text_color);
        }

        setTextColor(colorStateList);
    }
695915
private void obtainScaledEdge(@NonNull final TypedArray typedArray) {
        int defaultValue = Edge.VERTICAL.getValue();
        Edge scaledEdge = Edge.fromValue(
                typedArray.getInt(R.styleable.SquareImageView_scaledEdge, defaultValue));
        setScaledEdge(scaledEdge);
    }
492472
private void obtainDialogIcon(@NonNull final TypedArray typedArray) {
        int resourceId =
                typedArray.getResourceId(R.styleable.DialogPreference_android_dialogIcon, -1);

        if (resourceId != -1) {
            setDialogIcon(resourceId);
        }
    }