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

Commit 0c807f4a authored by Ian Lake's avatar Ian Lake
Browse files

Annotate LayoutInflater.Factory2 with nullability annotations

Also add the annotations to the most common implementation
of Factory2 - Activity.

BUG: 78245676
Test: make
Change-Id: I49f1cf57be240525916a624f215fdff4701f32a5
parent 5185bc79
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -6350,7 +6350,8 @@ public class Activity extends ContextThemeWrapper
     * @see android.view.Window#getLayoutInflater
     * @see android.view.Window#getLayoutInflater
     */
     */
    @Nullable
    @Nullable
    public View onCreateView(String name, Context context, AttributeSet attrs) {
    public View onCreateView(@NonNull String name, @NonNull Context context,
            @NonNull AttributeSet attrs) {
        return null;
        return null;
    }
    }


@@ -6364,7 +6365,9 @@ public class Activity extends ContextThemeWrapper
     * @see android.view.LayoutInflater#createView
     * @see android.view.LayoutInflater#createView
     * @see android.view.Window#getLayoutInflater
     * @see android.view.Window#getLayoutInflater
     */
     */
    public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
    @Nullable
    public View onCreateView(@Nullable View parent, @NonNull String name,
            @NonNull Context context, @NonNull AttributeSet attrs) {
        if (!"fragment".equals(name)) {
        if (!"fragment".equals(name)) {
            return onCreateView(name, context, attrs);
            return onCreateView(name, context, attrs);
        }
        }
+13 −4
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package android.view;
package android.view;


import android.annotation.LayoutRes;
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.SystemService;
import android.annotation.SystemService;
import android.annotation.UnsupportedAppUsage;
import android.annotation.UnsupportedAppUsage;
@@ -154,7 +155,9 @@ public abstract class LayoutInflater {
         * @return View Newly created view. Return null for the default
         * @return View Newly created view. Return null for the default
         *         behavior.
         *         behavior.
         */
         */
        public View onCreateView(String name, Context context, AttributeSet attrs);
        @Nullable
        View onCreateView(@NonNull String name, @NonNull Context context,
                @NonNull AttributeSet attrs);
    }
    }


    public interface Factory2 extends Factory {
    public interface Factory2 extends Factory {
@@ -172,7 +175,9 @@ public abstract class LayoutInflater {
         * @return View Newly created view. Return null for the default
         * @return View Newly created view. Return null for the default
         *         behavior.
         *         behavior.
         */
         */
        public View onCreateView(View parent, String name, Context context, AttributeSet attrs);
        @Nullable
        View onCreateView(@Nullable View parent, @NonNull String name,
                @NonNull Context context, @NonNull AttributeSet attrs);
    }
    }


    private static class FactoryMerger implements Factory2 {
    private static class FactoryMerger implements Factory2 {
@@ -186,13 +191,17 @@ public abstract class LayoutInflater {
            mF22 = f22;
            mF22 = f22;
        }
        }


        public View onCreateView(String name, Context context, AttributeSet attrs) {
        @Nullable
        public View onCreateView(@NonNull String name, @NonNull Context context,
                @NonNull AttributeSet attrs) {
            View v = mF1.onCreateView(name, context, attrs);
            View v = mF1.onCreateView(name, context, attrs);
            if (v != null) return v;
            if (v != null) return v;
            return mF2.onCreateView(name, context, attrs);
            return mF2.onCreateView(name, context, attrs);
        }
        }


        public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
        @Nullable
        public View onCreateView(@Nullable View parent, @NonNull String name,
                @NonNull Context context, @NonNull AttributeSet attrs) {
            View v = mF12 != null ? mF12.onCreateView(parent, name, context, attrs)
            View v = mF12 != null ? mF12.onCreateView(parent, name, context, attrs)
                    : mF1.onCreateView(name, context, attrs);
                    : mF1.onCreateView(name, context, attrs);
            if (v != null) return v;
            if (v != null) return v;