Call onViewCreated in DashboardFragment

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.

Usage DataSaverController as first example.

Bug: 287005021
Test: Manually for DataSaverController
Change-Id: Id965ea3a24d61f4d0ec6735632944f41f72ba06a
This commit is contained in:
Chaohui Wang
2023-06-13 17:08:33 +08:00
parent f2f899106d
commit eb4fea1a36
4 changed files with 13 additions and 18 deletions

View File

@@ -21,10 +21,6 @@ import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGE_DE
import android.app.settings.SettingsEnums;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -50,12 +46,6 @@ public class SpecialAccessSettings extends DashboardFragment {
MANAGE_DEVICE_ADMIN_APPS, R.string.manage_device_admin);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
use(DataSaverController.class).init(getViewLifecycleOwner());
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.special_access;