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

Commit d78f2de0 authored by Chaohui Wang's avatar Chaohui Wang
Browse files

New onViewCreated in AbstractPreferenceController

To let fragment's view lifecycle owner passed in to controllers.

For UI usage, view lifecycle owner is the best choice, controller could
use this lifecycle owner to observe events and do UI related works.

Bug: 287005021
Test: presubmit
Change-Id: Ibbfaae1ce350e2721a095783f930928f695e1470
parent 0c86688b
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settingslib.core;

import android.app.admin.DevicePolicyManager;
@@ -6,8 +22,11 @@ import android.os.Build;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.EmptySuper;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.os.BuildCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
@@ -51,6 +70,13 @@ public abstract class AbstractPreferenceController {
        }
    }

    /**
     * Called on view created.
     */
    @EmptySuper
    public void onViewCreated(@NonNull LifecycleOwner viewLifecycleOwner) {
    }

    /**
     * Updates the current status of preference (summary, switch state, etc)
     */