3030import java .util .Date ;
3131import java .util .List ;
3232
33+ import eu .faircode .netguard .ServiceSinkhole ;
3334import eu .faircode .netguard .Util ;
3435
3536public class ActivityBlocklists extends AppCompatActivity {
@@ -86,9 +87,16 @@ private void showAddDialog(Blocklist item) {
8687 Blocklist newItem = new Blocklist (url , true );
8788 manager .addBlocklist (newItem );
8889 } else {
90+ if (!url .equals (item .url )) {
91+ item .lastModified = 0 ;
92+ item .lastDownloadSuccess = true ;
93+ item .lastErrorMessage = null ;
94+ manager .getBlocklistFile (item .uuid ).delete ();
95+ }
8996 item .url = url ;
9097 manager .updateBlocklist (item );
9198 }
99+ applyBlocklists ();
92100 adapter .refresh ();
93101 } catch (MalformedURLException e ) {
94102 Toast .makeText (ActivityBlocklists .this , R .string .msg_invalid_url , Toast .LENGTH_SHORT ).show ();
@@ -147,6 +155,7 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
147155 holder .switchEnabled .setOnCheckedChangeListener ((buttonView , isChecked ) -> {
148156 item .enabled = isChecked ;
149157 manager .updateBlocklist (item );
158+ applyBlocklists ();
150159 });
151160
152161 // Edit on click
@@ -158,6 +167,7 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
158167 .setMessage (R .string .msg_delete_blocklist_confirm )
159168 .setPositiveButton (android .R .string .yes , (dialog , which ) -> {
160169 manager .removeBlocklist (item .uuid );
170+ applyBlocklists ();
161171 refresh ();
162172 })
163173 .setNegativeButton (android .R .string .no , null )
@@ -187,4 +197,13 @@ public ViewHolder(View itemView) {
187197 }
188198 }
189199 }
200+
201+ private void applyBlocklists () {
202+ if (!manager .mergeBlocklists ()) {
203+ Toast .makeText (this , R .string .msg_apply_blocklists_failed , Toast .LENGTH_SHORT ).show ();
204+ return ;
205+ }
206+
207+ ServiceSinkhole .reload ("blocklist changed" , this , false );
208+ }
190209}
0 commit comments