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

Commit 8b480c4c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "LayoutInflater: Special case well-known View constructors"

parents 31717ff7 cb694714
Loading
Loading
Loading
Loading
+66 −0
Original line number Diff line number Diff line
@@ -53,6 +53,11 @@ public class PhoneLayoutInflater extends LayoutInflater {
        call through to our super class.
    */
    @Override protected View onCreateView(String name, AttributeSet attrs) throws ClassNotFoundException {
        View fastView = fastCreateView(name, getContext(), attrs);
        if (fastView != null) {
            return fastView;
        }

        for (String prefix : sClassPrefixList) {
            try {
                View view = createView(name, prefix, attrs);
@@ -68,6 +73,67 @@ public class PhoneLayoutInflater extends LayoutInflater {
        return super.onCreateView(name, attrs);
    }

    private static final View fastCreateView(String name, Context context, AttributeSet attrs) {
        switch (name) {
            case "ActionMenuView":
                return new android.widget.ActionMenuView(context, attrs);
            case "AutoCompleteTextView":
                return new android.widget.AutoCompleteTextView(context, attrs);
            case "Button":
                return new android.widget.Button(context, attrs);
            case "CheckBox":
                return new android.widget.CheckBox(context, attrs);
            case "CheckedTextView":
                return new android.widget.CheckedTextView(context, attrs);
            case "EditText":
                return new android.widget.EditText(context, attrs);
            case "FrameLayout":
                return new android.widget.FrameLayout(context, attrs);
            case "ImageButton":
                return new android.widget.ImageButton(context, attrs);
            case "ImageView":
                return new android.widget.ImageView(context, attrs);
            case "LinearLayout":
                return new android.widget.LinearLayout(context, attrs);
            case "ListView":
                return new android.widget.ListView(context, attrs);
            case "MultiAutoCompleteTextView":
                return new android.widget.AutoCompleteTextView(context, attrs);
            case "ProgressBar":
                return new android.widget.ProgressBar(context, attrs);
            case "RadioButton":
                return new android.widget.RadioButton(context, attrs);
            case "RatingBar":
                return new android.widget.RatingBar(context, attrs);
            case "RelativeLayout":
                return new android.widget.RelativeLayout(context, attrs);
            case "ScrollView":
                return new android.widget.ScrollView(context, attrs);
            case "SeekBar":
                return new android.widget.SeekBar(context, attrs);
            case "Space":
                return new android.widget.Space(context, attrs);
            case "Spinner":
                return new android.widget.Spinner(context, attrs);
            case "TextureView":
                return new android.view.TextureView(context, attrs);
            case "TextView":
                return new android.widget.TextView(context, attrs);
            case "ToggleButton":
                return new android.widget.ToggleButton(context, attrs);
            case "Toolbar":
                return new android.widget.Toolbar(context, attrs);
            case "View":
                return new android.view.View(context, attrs);
            case "ViewFlipper":
                return new android.widget.ViewFlipper(context, attrs);
            case "ViewStub":
                return new android.view.ViewStub(context, attrs);
            default:
                return null;
        }
    }

    public LayoutInflater cloneInContext(Context newContext) {
        return new PhoneLayoutInflater(this, newContext);
    }