From 476504a3669403deb2ee07e6b21b1a3201c7e77e Mon Sep 17 00:00:00 2001 From: PeratX <1215714524@qq.com> Date: Tue, 2 May 2017 21:28:13 +0800 Subject: [PATCH] Improved custom server id --- .../org/itxtech/daedalus/util/Configurations.java | 11 +++++++++++ .../org/itxtech/daedalus/util/CustomDnsServer.java | 4 +++- .../java/org/itxtech/daedalus/util/DnsServer.java | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/itxtech/daedalus/util/Configurations.java b/app/src/main/java/org/itxtech/daedalus/util/Configurations.java index 1896294..3460092 100644 --- a/app/src/main/java/org/itxtech/daedalus/util/Configurations.java +++ b/app/src/main/java/org/itxtech/daedalus/util/Configurations.java @@ -21,10 +21,21 @@ import java.util.ArrayList; * the Free Software Foundation, version 3. */ public class Configurations { + private static final int CUSTOM_DNS_ID_START = 32; + private static File file; private ArrayList customDnsServers; + private int totalId; + + public int getNextId() { + if (totalId < CUSTOM_DNS_ID_START) { + totalId = CUSTOM_DNS_ID_START; + } + return totalId++; + } + public ArrayList getCustomDnsServers() { if (customDnsServers == null) { customDnsServers = new ArrayList<>(); diff --git a/app/src/main/java/org/itxtech/daedalus/util/CustomDnsServer.java b/app/src/main/java/org/itxtech/daedalus/util/CustomDnsServer.java index d3929c0..2be822c 100644 --- a/app/src/main/java/org/itxtech/daedalus/util/CustomDnsServer.java +++ b/app/src/main/java/org/itxtech/daedalus/util/CustomDnsServer.java @@ -1,5 +1,7 @@ package org.itxtech.daedalus.util; +import org.itxtech.daedalus.Daedalus; + /** * Daedalus Project * @@ -20,7 +22,7 @@ public class CustomDnsServer { this.name = name; this.address = address; this.port = port; - this.id = String.valueOf(DnsServer.totalId++); + this.id = String.valueOf(Daedalus.configurations.getNextId()); } public String getId() { diff --git a/app/src/main/java/org/itxtech/daedalus/util/DnsServer.java b/app/src/main/java/org/itxtech/daedalus/util/DnsServer.java index c965780..42d3be5 100644 --- a/app/src/main/java/org/itxtech/daedalus/util/DnsServer.java +++ b/app/src/main/java/org/itxtech/daedalus/util/DnsServer.java @@ -13,7 +13,7 @@ import android.content.Context; * the Free Software Foundation, version 3. */ public class DnsServer { - public static int totalId = 0; + private static int totalId = 0; private String id; private String address;