diff --git a/parts/src/org/lineageos/settings/dirac/DiracSettingsFragment.java b/parts/src/org/lineageos/settings/dirac/DiracSettingsFragment.java index 56175f6..461caff 100644 --- a/parts/src/org/lineageos/settings/dirac/DiracSettingsFragment.java +++ b/parts/src/org/lineageos/settings/dirac/DiracSettingsFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 The LineageOS Project + * Copyright (C) 2018,2020 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,6 +54,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { final ActionBar actionBar = getActivity().getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); + DiracUtils.initialize(getActivity()); boolean enhancerEnabled = DiracUtils.isDiracEnabled(); mHeadsetType = (ListPreference) findPreference(PREF_HEADSET); diff --git a/parts/src/org/lineageos/settings/dirac/DiracUtils.java b/parts/src/org/lineageos/settings/dirac/DiracUtils.java index 6f3c91f..0550011 100644 --- a/parts/src/org/lineageos/settings/dirac/DiracUtils.java +++ b/parts/src/org/lineageos/settings/dirac/DiracUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 The LineageOS Project + * Copyright (C) 2018,2020 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ public final class DiracUtils { public static void initialize(Context context) { if (!mInitialized) { - mInitialized = true; mContext = context; mDiracSound = new DiracSound(0, 0); + mInitialized = true; } } @@ -39,7 +39,7 @@ protected static void setMusic(boolean enable) { } protected static boolean isDiracEnabled() { - return mDiracSound.getMusic() == 1; + return mDiracSound != null && mDiracSound.getMusic() == 1; } protected static void setLevel(String preset) {