OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 @Override | 44 @Override |
45 public void onPause() | 45 public void onPause() |
46 { | 46 { |
47 super.onPause(); | 47 super.onPause(); |
48 getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceCha
ngeListener(this); | 48 getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceCha
ngeListener(this); |
49 } | 49 } |
50 | 50 |
51 @Override | 51 @Override |
52 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str
ing key) | 52 public void onSharedPreferenceChanged(final SharedPreferences sharedPreference
s, final String key) |
53 { | 53 { |
54 Preference pref = findPreference(key); | 54 final Preference pref = findPreference(key); |
55 setPrefSummary(pref); | 55 setPrefSummary(pref); |
56 } | 56 } |
57 | 57 |
58 protected void setPrefSummary(Preference pref) | 58 protected void setPrefSummary(final Preference pref) |
59 { | 59 { |
60 if (pref instanceof ListPreference) | 60 if (pref instanceof ListPreference) |
61 { | 61 { |
62 CharSequence summary = ((ListPreference) pref).getEntry(); | 62 final CharSequence summary = ((ListPreference) pref).getEntry(); |
63 if (summary != null) | 63 if (summary != null) |
64 { | 64 { |
65 pref.setSummary(summary); | 65 pref.setSummary(summary); |
66 } | 66 } |
67 } | 67 } |
68 if (pref instanceof EditTextPreference) | 68 if (pref instanceof EditTextPreference) |
69 { | 69 { |
70 CharSequence summary = ((EditTextPreference) pref).getText(); | 70 final CharSequence summary = ((EditTextPreference) pref).getText(); |
71 if (summary != null) | 71 if (summary != null) |
72 { | 72 { |
73 pref.setSummary(summary); | 73 pref.setSummary(summary); |
74 } | 74 } |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 protected void initSummaries(PreferenceGroup preference) | 78 protected void initSummaries(final PreferenceGroup preference) |
79 { | 79 { |
80 for (int i = preference.getPreferenceCount() - 1; i >= 0; i--) | 80 for (int i = preference.getPreferenceCount() - 1; i >= 0; i--) |
81 { | 81 { |
82 Preference pref = preference.getPreference(i); | 82 final Preference pref = preference.getPreference(i); |
83 | 83 |
84 if (pref instanceof PreferenceGroup || pref instanceof PreferenceScreen) | 84 if (pref instanceof PreferenceGroup || pref instanceof PreferenceScreen) |
85 { | 85 { |
86 initSummaries((PreferenceGroup) pref); | 86 initSummaries((PreferenceGroup) pref); |
87 } | 87 } |
88 else | 88 else |
89 { | 89 { |
90 setPrefSummary(pref); | 90 setPrefSummary(pref); |
91 } | 91 } |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 } | 95 } |
OLD | NEW |