Refactoring

pull/214/head
M66B 8 months ago
parent 42af314c79
commit e533c07a1f

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

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

Loading…
Cancel
Save