Refactoring

This commit is contained in:
M66B 2023-12-29 13:06:50 +01:00
parent 42af314c79
commit e533c07a1f
2 changed files with 7 additions and 6 deletions

View File

@ -29,12 +29,14 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -127,15 +129,13 @@ public class DisconnectBlacklist {
if (status != HttpsURLConnection.HTTP_OK)
throw new FileNotFoundException("Error " + status + ": " + connection.getResponseMessage());
String response = Helper.readStream(connection.getInputStream());
Helper.writeText(file, response);
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
Helper.copy(connection.getInputStream(), os);
}
} finally {
connection.disconnect();
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putLong("disconnect_last", new Date().getTime()).apply();
init(file);
}

View File

@ -485,6 +485,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
@Override
protected void onExecuted(Bundle args, Void data) {
prefs.edit().putLong("disconnect_last", new Date().getTime()).apply();
setOptions();
}