| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 @Override | 90 @Override |
| 91 public void run() | 91 public void run() |
| 92 { | 92 { |
| 93 SubscriptionPreferenceCategory.this.initEntries(); | 93 SubscriptionPreferenceCategory.this.initEntries(); |
| 94 } | 94 } |
| 95 }); | 95 }); |
| 96 } | 96 } |
| 97 }); | 97 }); |
| 98 } | 98 } |
| 99 | 99 |
| 100 private CheckBoxPreference createDisabledCheckBox(final int titleId, final int
summaryId) | 100 private Preference createDisabledPreference(final int titleId, final int summa
ryId) |
| 101 { | 101 { |
| 102 final CheckBoxPreference cbp = new CheckBoxPreference(this.getContext()); | 102 final Preference preference = new Preference(this.getContext()); |
| 103 cbp.setTitle(titleId); | 103 preference.setTitle(titleId); |
| 104 cbp.setSummary(summaryId); | 104 preference.setSummary(summaryId); |
| 105 cbp.setEnabled(false); | 105 preference.setEnabled(false); |
| 106 cbp.setShouldDisableView(true); | 106 preference.setShouldDisableView(true); |
| 107 cbp.setSelectable(false); | 107 preference.setSelectable(false); |
| 108 return cbp; | 108 return preference; |
| 109 } | 109 } |
| 110 | 110 |
| 111 private CheckBoxPreference createEnabledCheckBox( | 111 private CheckBoxPreference createEnabledCheckBox( |
| 112 final SubscriptionContainer.Subscription subscription) | 112 final SubscriptionContainer.Subscription subscription) |
| 113 { | 113 { |
| 114 final CheckBoxPreference cbp = new CheckBoxPreference(this.getContext()); | 114 final CheckBoxPreference cbp = new CheckBoxPreference(this.getContext()); |
| 115 cbp.setTitle(subscription.specialization); | 115 cbp.setTitle(subscription.specialization); |
| 116 cbp.setSummary(subscription.title); | 116 cbp.setSummary(subscription.title); |
| 117 cbp.setChecked(true); | 117 cbp.setChecked(true); |
| 118 cbp.setKey(subscription.url); | 118 cbp.setKey(subscription.url); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 142 } | 142 } |
| 143 | 143 |
| 144 private void initEntries(final int titleId, final int summaryId, boolean enabl
ed) | 144 private void initEntries(final int titleId, final int summaryId, boolean enabl
ed) |
| 145 { | 145 { |
| 146 this.removeAll(); | 146 this.removeAll(); |
| 147 final List<SubscriptionContainer.Subscription> entries = | 147 final List<SubscriptionContainer.Subscription> entries = |
| 148 subscriptionContainer.getSubscriptions(enabled); | 148 subscriptionContainer.getSubscriptions(enabled); |
| 149 | 149 |
| 150 if (entries.isEmpty()) | 150 if (entries.isEmpty()) |
| 151 { | 151 { |
| 152 this.addPreference(this.createDisabledCheckBox(titleId, summaryId)); | 152 this.addPreference(this.createDisabledPreference(titleId, summaryId)); |
| 153 } | 153 } |
| 154 else | 154 else |
| 155 { | 155 { |
| 156 for (SubscriptionContainer.Subscription e : entries) | 156 for (SubscriptionContainer.Subscription e : entries) |
| 157 { | 157 { |
| 158 this.addPreference(this.createEnabledCheckBox(e)); | 158 this.addPreference(this.createEnabledCheckBox(e)); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 private static class CheckBoxChangeListener implements OnPreferenceChangeListe
ner | 163 private static class CheckBoxChangeListener implements OnPreferenceChangeListe
ner |
| 164 { | 164 { |
| 165 @Override | 165 @Override |
| 166 public boolean onPreferenceChange(Preference preference, Object newValue) | 166 public boolean onPreferenceChange(Preference preference, Object newValue) |
| 167 { | 167 { |
| 168 if (preference instanceof CheckBoxPreference && newValue instanceof Boolea
n) | 168 if (preference instanceof CheckBoxPreference && newValue instanceof Boolea
n) |
| 169 { | 169 { |
| 170 final CheckBoxPreference cbp = (CheckBoxPreference) preference; | 170 final CheckBoxPreference cbp = (CheckBoxPreference) preference; |
| 171 final boolean enable = ((Boolean) newValue).booleanValue(); | 171 final boolean enable = ((Boolean) newValue).booleanValue(); |
| 172 SubscriptionPreferenceCategory.subscriptionContainer.changeSubscriptionS
tate( | 172 SubscriptionPreferenceCategory.subscriptionContainer.changeSubscriptionS
tate( |
| 173 cbp.getKey(), | 173 cbp.getKey(), |
| 174 enable); | 174 enable); |
| 175 } | 175 } |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| OLD | NEW |