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

Commit 76bb6fe7 authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Call onAttach before finish" into main

parents 6f49ad73 ad6fb766
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ abstract class BluetoothDetailsConfigurableFragment :
            arguments?.getString(KEY_DEVICE_ADDRESS)
                ?: run {
                    Log.w(TAG, "onAttach() address is null!")
                    super.onAttach(context)
                    finish()
                    return
                }
@@ -124,6 +125,7 @@ abstract class BluetoothDetailsConfigurableFragment :
            getCachedDevice(deviceAddress)
                ?: run {
                    Log.w(TAG, "onAttach() CachedDevice is null!")
                    super.onAttach(context)
                    finish()
                    return
                }
@@ -674,6 +676,8 @@ abstract class BluetoothDetailsConfigurableFragment :
        return localBluetoothManager.cachedDeviceManager.addDevice(remoteDevice)
    }

    protected fun isCachedDeviceInitialized() = ::cachedDevice.isInitialized

    private class SpotlightPreference(context: Context) : Preference(context) {
        init {
            layoutResource = R.layout.bluetooth_device_spotlight_preference
+1 −1
Original line number Diff line number Diff line
@@ -402,7 +402,7 @@ public class BluetoothDeviceDetailsFragment extends BluetoothDetailsConfigurable
    @Override
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        ArrayList<AbstractPreferenceController> controllers = new ArrayList<>();
        if (cachedDevice != null) {
        if (isCachedDeviceInitialized()) {
            Lifecycle lifecycle = getSettingsLifecycle();
            controllers.add(
                    new BluetoothDetailsBannerController(
+20 −16
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ class DeviceDetailsMoreSettingsFragment : BluetoothDetailsConfigurableFragment()
    }

    override fun createPreferenceControllers(context: Context): List<AbstractPreferenceController> {
        return listOf(
        return if (isCachedDeviceInitialized()) {
            listOf(
                BluetoothDetailsProfilesController(
                    context,
                    this,
@@ -58,6 +59,9 @@ class DeviceDetailsMoreSettingsFragment : BluetoothDetailsConfigurableFragment()
                    settingsLifecycle,
                ),
            )
        } else {
            emptyList()
        }
    }

    override fun getLogTag(): String = TAG