Improved custom server id

This commit is contained in:
PeratX 2017-05-02 21:28:13 +08:00
parent 820b8d53c3
commit 476504a366
3 changed files with 15 additions and 2 deletions

View File

@ -21,10 +21,21 @@ import java.util.ArrayList;
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
*/ */
public class Configurations { public class Configurations {
private static final int CUSTOM_DNS_ID_START = 32;
private static File file; private static File file;
private ArrayList<CustomDnsServer> customDnsServers; private ArrayList<CustomDnsServer> customDnsServers;
private int totalId;
public int getNextId() {
if (totalId < CUSTOM_DNS_ID_START) {
totalId = CUSTOM_DNS_ID_START;
}
return totalId++;
}
public ArrayList<CustomDnsServer> getCustomDnsServers() { public ArrayList<CustomDnsServer> getCustomDnsServers() {
if (customDnsServers == null) { if (customDnsServers == null) {
customDnsServers = new ArrayList<>(); customDnsServers = new ArrayList<>();

View File

@ -1,5 +1,7 @@
package org.itxtech.daedalus.util; package org.itxtech.daedalus.util;
import org.itxtech.daedalus.Daedalus;
/** /**
* Daedalus Project * Daedalus Project
* *
@ -20,7 +22,7 @@ public class CustomDnsServer {
this.name = name; this.name = name;
this.address = address; this.address = address;
this.port = port; this.port = port;
this.id = String.valueOf(DnsServer.totalId++); this.id = String.valueOf(Daedalus.configurations.getNextId());
} }
public String getId() { public String getId() {

View File

@ -13,7 +13,7 @@ import android.content.Context;
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
*/ */
public class DnsServer { public class DnsServer {
public static int totalId = 0; private static int totalId = 0;
private String id; private String id;
private String address; private String address;