You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modified preference initialization mechanism to ignore the initialization if the preference is already available within the underlying shared preference.
Copy file name to clipboardExpand all lines: PreferenceStore/src/main/java/com/buggysofts/preferencestore/PreferenceHandler.java
+28-8Lines changed: 28 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,6 @@ public boolean getPreferenceValue(@NonNull BoundedPreference<Boolean> preference
65
65
/**
66
66
* Get value of the specified preference.
67
67
* @param preference The preference from which we want our value.
68
-
* @param clazz Data type of <b>preference</b>. It is a dummy parameter used to avoid method erasure.
69
68
* @param defaultOverride Optional value to override the actual return from underlying {@link SharedPreferences} instance.
70
69
* Although it is declared as a vararg, you should pass at most one value. Others will be discarded.
71
70
*
@@ -677,7 +676,7 @@ public <T extends Serializable> T setPreferenceValue(@NonNull UnBoundedPreferenc
677
676
678
677
// initializers
679
678
/**
680
-
* Initialize the bounded preference.
679
+
* Initialize the bounded preference. This call will return the passed preference immediately (without any further operation) if the preference is already available within the current underlying shared preference.
681
680
* @param preference The preference which we are initializing.
682
681
* @param overrideDefault Optional value to override the default of the specified bounded preference.
683
682
* If it is not provided, the default value of the specified bounded preference will be used to initialize the preference.
@@ -687,6 +686,9 @@ public <T extends Serializable> T setPreferenceValue(@NonNull UnBoundedPreferenc
@@ -703,7 +705,7 @@ public BoundedPreference<Boolean> initializePreference(@NonNull BoundedPreferenc
703
705
returnpreference;
704
706
}
705
707
/**
706
-
* Initialize the bounded preference.
708
+
* Initialize the bounded preference. This call will return the passed preference immediately (without any further operation) if the preference is already available within the current underlying shared preference.
707
709
* @param preference The preference which we are initializing.
708
710
* @param overrideDefault Optional value to override the default of the specified bounded preference.
709
711
* If it is not provided, the default value of the specified bounded preference will be used to initialize the preference.
@@ -713,6 +715,9 @@ public BoundedPreference<Boolean> initializePreference(@NonNull BoundedPreferenc
@@ -729,7 +734,7 @@ public BoundedPreference<Integer> initializePreference(@NonNull BoundedPreferenc
729
734
returnpreference;
730
735
}
731
736
/**
732
-
* Initialize the bounded preference.
737
+
* Initialize the bounded preference. This call will return the passed preference immediately (without any further operation) if the preference is already available within the current underlying shared preference.
733
738
* @param preference The preference which we are initializing.
734
739
* @param overrideDefault Optional value to override the default of the specified bounded preference.
735
740
* If it is not provided, the default value of the specified bounded preference will be used to initialize the preference.
@@ -739,6 +744,9 @@ public BoundedPreference<Integer> initializePreference(@NonNull BoundedPreferenc
@@ -755,7 +763,7 @@ public BoundedPreference<Long> initializePreference(@NonNull BoundedPreference<L
755
763
returnpreference;
756
764
}
757
765
/**
758
-
* Initialize the bounded preference.
766
+
* Initialize the bounded preference. This call will return the passed preference immediately (without any further operation) if the preference is already available within the current underlying shared preference.
759
767
* @param preference The preference which we are initializing.
760
768
* @param overrideDefault Optional value to override the default of the specified bounded preference.
761
769
* If it is not provided, the default value of the specified bounded preference will be used to initialize the preference.
@@ -765,6 +773,9 @@ public BoundedPreference<Long> initializePreference(@NonNull BoundedPreference<L
@@ -781,7 +792,7 @@ public BoundedPreference<Float> initializePreference(@NonNull BoundedPreference<
781
792
returnpreference;
782
793
}
783
794
/**
784
-
* Initialize the bounded preference.
795
+
* Initialize the bounded preference. This call will return the passed preference immediately (without any further operation) if the preference is already available within the current underlying shared preference.
785
796
* @param preference The preference which we are initializing.
786
797
* @param overrideDefault Optional value to override the default of the specified bounded preference.
787
798
* If it is not provided, the default value of the specified bounded preference will be used to initialize the preference.
@@ -791,6 +802,9 @@ public BoundedPreference<Float> initializePreference(@NonNull BoundedPreference<
@@ -807,7 +821,7 @@ public BoundedPreference<String> initializePreference(@NonNull BoundedPreference
807
821
returnpreference;
808
822
}
809
823
/**
810
-
* Initialize the bounded preference.
824
+
* Initialize the bounded preference. This call will return the passed preference immediately (without any further operation) if the preference is already available within the current underlying shared preference.
811
825
* @param preference The preference which we are initializing.
812
826
* @param overrideDefault Optional value to override the default of the specified bounded preference.
813
827
* If it is not provided, the default value of the specified bounded preference will be used to initialize the preference.
@@ -818,6 +832,9 @@ public BoundedPreference<String> initializePreference(@NonNull BoundedPreference
@@ -834,7 +851,7 @@ public final BoundedPreference<Set<String>> initializePreference(@NonNull Bounde
834
851
returnpreference;
835
852
}
836
853
/**
837
-
* Initialize the bounded preference.
854
+
* Initialize the bounded preference. This call will return the passed preference immediately (without any further operation) if the preference is already available within the current underlying shared preference.
838
855
* @param preference The preference which we are initializing.
839
856
* @param overrideDefault Optional value to override the default of the specified bounded preference.
840
857
* If it is not provided, the default value of the specified bounded preference will be used to initialize the preference.
@@ -845,6 +862,9 @@ public final BoundedPreference<Set<String>> initializePreference(@NonNull Bounde
0 commit comments