Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad6d793

Browse files
committed
Removed unused android files, optimized code and fixed typos
1 parent 355fa3e commit ad6d793

File tree

6 files changed

+21
-29
lines changed

6 files changed

+21
-29
lines changed

library/src/main/AndroidManifest.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

library/src/main/java/com/stealthcopter/networktools/MACTools.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private MACTools() {
1717
* Validates a provided MAC address
1818
*
1919
* @param macAddress - the MAC address to check
20-
* @return - true if it is valid MAC address in IEEE802 format (either hyphen or colon seperated)
20+
* @return - true if it is valid MAC address in IEEE802 format (either hyphen or colon separated)
2121
* eg: "01:23:45:67:89:AB" or "01-23-45-67-89-AB"
2222
*/
2323
public static boolean isValidMACAddress(final String macAddress) {
@@ -28,7 +28,7 @@ public static boolean isValidMACAddress(final String macAddress) {
2828
/**
2929
* Convert a MAC string to bytes
3030
*
31-
* @param macStr - MAC string in IEEE802 format (either hyphen or colon seperated)
31+
* @param macStr - MAC string in IEEE802 format (either hyphen or colon separated)
3232
* eg: "01:23:45:67:89:AB" or "01-23-45-67-89-AB"
3333
* @return - MAC formatted in bytes
3434
* @throws IllegalArgumentException - if mac address is invalid

library/src/main/java/com/stealthcopter/networktools/ping/PingNative.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,21 @@ public static PingResult ping(InetAddress host, PingOptions pingOptions) throws
5050
proc.waitFor();
5151
int exit = proc.exitValue();
5252
String pingError;
53-
if (exit == 0) {
54-
InputStreamReader reader = new InputStreamReader(proc.getInputStream());
55-
BufferedReader buffer = new BufferedReader(reader);
56-
String line;
57-
while ((line = buffer.readLine()) != null) {
58-
echo.append(line).append("\n");
59-
}
60-
return getPingStats(pingResult, echo.toString());
61-
} else if (exit == 1) {
62-
pingError = "failed, exit = 1";
63-
} else {
64-
pingError = "error, exit = 2";
53+
switch (exit) {
54+
case 0:
55+
InputStreamReader reader = new InputStreamReader(proc.getInputStream());
56+
BufferedReader buffer = new BufferedReader(reader);
57+
String line;
58+
while ((line = buffer.readLine()) != null) {
59+
echo.append(line).append("\n");
60+
}
61+
return getPingStats(pingResult, echo.toString());
62+
case 1:
63+
pingError = "failed, exit = 1";
64+
break;
65+
default:
66+
pingError = "error, exit = 2";
67+
break;
6568
}
6669
pingResult.error = pingError;
6770
return pingResult;

library/src/main/java/com/stealthcopter/networktools/ping/PingTools.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.io.IOException;
44
import java.net.InetAddress;
5-
import java.net.NetworkInterface;
65

76
/**
87
* Created by mat on 09/12/15.
@@ -47,7 +46,7 @@ public static PingResult doPing(InetAddress ia, PingOptions pingOptions) {
4746
* @param pingOptions - ping command options
4847
* @return - the ping results
4948
* @throws IOException - IO error running ping command
50-
* @throws InterruptedException - thread interupt
49+
* @throws InterruptedException - thread interrupt
5150
*/
5251
public static PingResult doNativePing(InetAddress ia, PingOptions pingOptions) throws IOException, InterruptedException {
5352
return PingNative.ping(ia, pingOptions);

library/src/main/java/com/stealthcopter/networktools/subnet/Device.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import java.net.InetAddress;
44

55
public class Device {
6-
public String ip = "";
7-
public String hostname = "";
8-
public String mac = "";
9-
10-
6+
public String ip;
7+
public String hostname;
8+
public String mac;
119
public float time = 0;
1210

1311
public Device(InetAddress ip) {

library/src/main/res/values/strings.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)