Skip to content

Commit 5cf9e01

Browse files
author
Quintin Willison
authored
Merge pull request ably#610 from ably/feature/tabs-to-spaces
Convert tabs to spaces in all Java source files
2 parents dd1725f + aec446d commit 5cf9e01

156 files changed

Lines changed: 41843 additions & 41841 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

android/src/androidTest/java/io/ably/lib/test/android/AndroidPushTest.java

Lines changed: 1814 additions & 1814 deletions
Large diffs are not rendered by default.

android/src/androidTest/java/io/ably/lib/test/android/AndroidSuite.java

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,70 +26,70 @@
2626
* Tests specific for Android
2727
*/
2828
public class AndroidSuite {
29-
private static SessionHandlerNanoHTTPD server;
30-
31-
@BeforeClass
32-
public static void setUp() throws IOException {
33-
/* Create custom RouterNanoHTTPD class for getting session object */
34-
server = new SessionHandlerNanoHTTPD(27333);
35-
server.start(NanoHTTPD.SOCKET_READ_TIMEOUT, true);
36-
37-
while (!server.wasStarted()) {
38-
try {
39-
Thread.sleep(100);
40-
} catch (InterruptedException e) {
41-
e.printStackTrace();
42-
}
43-
}
44-
}
45-
46-
@AfterClass
47-
public static void tearDown() {
48-
server.stop();
49-
}
50-
51-
@Test
52-
public void android_http_header_test() {
53-
try {
54-
/* Init values for local server */
55-
Setup.TestVars testVars = Setup.getTestVars();
56-
ClientOptions opts = new ClientOptions(testVars.keys[0].keyStr);
57-
opts.tls = false;
58-
opts.port = server.getListeningPort();
59-
opts.restHost = "localhost";
60-
AblyRest ably = new AblyRest(opts);
61-
62-
ably.time();
63-
64-
Map<String, String> headers = server.getHeaders();
65-
66-
assertNotNull("Verify ably server was reached", headers);
67-
String header = headers.get(Defaults.ABLY_LIB_HEADER.toLowerCase());
68-
assertTrue("Verify correct library header was passed to the server", header != null && header.startsWith("android"));
69-
}
70-
catch (AblyException e) {
71-
e.printStackTrace();
72-
fail();
73-
}
74-
75-
}
76-
77-
private static class SessionHandlerNanoHTTPD extends RouterNanoHTTPD {
78-
public Map<String, String> headers;
79-
80-
public SessionHandlerNanoHTTPD(int port) {
81-
super(port);
82-
}
83-
84-
@Override
85-
public Response serve(IHTTPSession session) {
86-
headers = new HashMap<>(session.getHeaders());
87-
return newFixedLengthResponse(String.format(Locale.US, "[%d]", System.currentTimeMillis()));
88-
}
89-
90-
public Map<String, String> getHeaders() {
91-
return headers;
92-
}
93-
}
29+
private static SessionHandlerNanoHTTPD server;
30+
31+
@BeforeClass
32+
public static void setUp() throws IOException {
33+
/* Create custom RouterNanoHTTPD class for getting session object */
34+
server = new SessionHandlerNanoHTTPD(27333);
35+
server.start(NanoHTTPD.SOCKET_READ_TIMEOUT, true);
36+
37+
while (!server.wasStarted()) {
38+
try {
39+
Thread.sleep(100);
40+
} catch (InterruptedException e) {
41+
e.printStackTrace();
42+
}
43+
}
44+
}
45+
46+
@AfterClass
47+
public static void tearDown() {
48+
server.stop();
49+
}
50+
51+
@Test
52+
public void android_http_header_test() {
53+
try {
54+
/* Init values for local server */
55+
Setup.TestVars testVars = Setup.getTestVars();
56+
ClientOptions opts = new ClientOptions(testVars.keys[0].keyStr);
57+
opts.tls = false;
58+
opts.port = server.getListeningPort();
59+
opts.restHost = "localhost";
60+
AblyRest ably = new AblyRest(opts);
61+
62+
ably.time();
63+
64+
Map<String, String> headers = server.getHeaders();
65+
66+
assertNotNull("Verify ably server was reached", headers);
67+
String header = headers.get(Defaults.ABLY_LIB_HEADER.toLowerCase());
68+
assertTrue("Verify correct library header was passed to the server", header != null && header.startsWith("android"));
69+
}
70+
catch (AblyException e) {
71+
e.printStackTrace();
72+
fail();
73+
}
74+
75+
}
76+
77+
private static class SessionHandlerNanoHTTPD extends RouterNanoHTTPD {
78+
public Map<String, String> headers;
79+
80+
public SessionHandlerNanoHTTPD(int port) {
81+
super(port);
82+
}
83+
84+
@Override
85+
public Response serve(IHTTPSession session) {
86+
headers = new HashMap<>(session.getHeaders());
87+
return newFixedLengthResponse(String.format(Locale.US, "[%d]", System.currentTimeMillis()));
88+
}
89+
90+
public Map<String, String> getHeaders() {
91+
return headers;
92+
}
93+
}
9494

9595
}

android/src/androidTest/java/io/ably/lib/test/loader/ArgumentLoader.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import android.support.test.InstrumentationRegistry;
55

66
public class ArgumentLoader {
7-
public String getTestArgument(String name) {
8-
Bundle arguments = InstrumentationRegistry.getArguments();
9-
return arguments.getString(name);
10-
}
7+
public String getTestArgument(String name) {
8+
Bundle arguments = InstrumentationRegistry.getArguments();
9+
return arguments.getString(name);
10+
}
1111
}

android/src/androidTest/java/io/ably/lib/test/loader/ResourceLoader.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
import java.io.IOException;
99

1010
public class ResourceLoader {
11-
public byte[] read(String resourceName) throws IOException {
12-
InputStream is = null;
13-
byte[] bytes = null;
14-
try {
15-
is = instrumentationCtx.getAssets().open(resourceName);
16-
Log.v(TAG, "Reading " + is.available() + " bytes for resource " + resourceName);
17-
bytes = new byte[is.available()];
18-
is.read(bytes);
19-
} catch(IOException ioe) {
20-
Log.e(TAG, "Unexpected exception reading asset resource", ioe);
21-
} finally {
22-
if(is != null)
23-
is.close();
24-
return bytes;
25-
}
26-
}
11+
public byte[] read(String resourceName) throws IOException {
12+
InputStream is = null;
13+
byte[] bytes = null;
14+
try {
15+
is = instrumentationCtx.getAssets().open(resourceName);
16+
Log.v(TAG, "Reading " + is.available() + " bytes for resource " + resourceName);
17+
bytes = new byte[is.available()];
18+
is.read(bytes);
19+
} catch(IOException ioe) {
20+
Log.e(TAG, "Unexpected exception reading asset resource", ioe);
21+
} finally {
22+
if(is != null)
23+
is.close();
24+
return bytes;
25+
}
26+
}
2727

28-
private static final String TAG = ResourceLoader.class.getName();
29-
private Context instrumentationCtx = InstrumentationRegistry.getContext();
28+
private static final String TAG = ResourceLoader.class.getName();
29+
private Context instrumentationCtx = InstrumentationRegistry.getContext();
3030
}

android/src/main/java/io/ably/lib/platform/AndroidNetworkConnectivity.java

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,65 +13,65 @@
1313

1414
public class AndroidNetworkConnectivity extends NetworkConnectivity {
1515

16-
AndroidNetworkConnectivity(Context applicationContext) {
17-
this.applicationContext = applicationContext;
18-
}
16+
AndroidNetworkConnectivity(Context applicationContext) {
17+
this.applicationContext = applicationContext;
18+
}
1919

20-
public static AndroidNetworkConnectivity getNetworkConnectivity(Context applicationContext) {
21-
AndroidNetworkConnectivity networkConnectivity;
22-
synchronized (contexts) {
23-
networkConnectivity = contexts.get(applicationContext);
24-
if(networkConnectivity == null) {
25-
contexts.put(applicationContext, (networkConnectivity = new AndroidNetworkConnectivity(applicationContext)));
26-
}
27-
}
28-
return networkConnectivity;
29-
}
20+
public static AndroidNetworkConnectivity getNetworkConnectivity(Context applicationContext) {
21+
AndroidNetworkConnectivity networkConnectivity;
22+
synchronized (contexts) {
23+
networkConnectivity = contexts.get(applicationContext);
24+
if(networkConnectivity == null) {
25+
contexts.put(applicationContext, (networkConnectivity = new AndroidNetworkConnectivity(applicationContext)));
26+
}
27+
}
28+
return networkConnectivity;
29+
}
3030

31-
protected void onNonempty() {
32-
activate();
33-
}
31+
protected void onNonempty() {
32+
activate();
33+
}
3434

35-
protected void onEmpty() {
36-
deactivate();
37-
}
35+
protected void onEmpty() {
36+
deactivate();
37+
}
3838

39-
private void activate() {
40-
if(networkStateReceiver == null && applicationContext != null) {
41-
networkStateReceiver = new NetworkStateReceiver();
42-
applicationContext.registerReceiver(networkStateReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
43-
}
44-
}
39+
private void activate() {
40+
if(networkStateReceiver == null && applicationContext != null) {
41+
networkStateReceiver = new NetworkStateReceiver();
42+
applicationContext.registerReceiver(networkStateReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
43+
}
44+
}
4545

46-
private void deactivate() {
47-
if(networkStateReceiver != null) {
48-
applicationContext.unregisterReceiver(networkStateReceiver);
49-
networkStateReceiver = null;
50-
}
51-
}
46+
private void deactivate() {
47+
if(networkStateReceiver != null) {
48+
applicationContext.unregisterReceiver(networkStateReceiver);
49+
networkStateReceiver = null;
50+
}
51+
}
5252

53-
private class NetworkStateReceiver extends BroadcastReceiver {
54-
public NetworkStateReceiver() {
55-
}
53+
private class NetworkStateReceiver extends BroadcastReceiver {
54+
public NetworkStateReceiver() {
55+
}
5656

57-
public void onReceive(Context context, Intent intent) {
58-
if(intent == null || intent.getExtras() == null) {
59-
return;
60-
}
57+
public void onReceive(Context context, Intent intent) {
58+
if(intent == null || intent.getExtras() == null) {
59+
return;
60+
}
6161

62-
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
63-
NetworkInfo ni = manager.getActiveNetworkInfo();
62+
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
63+
NetworkInfo ni = manager.getActiveNetworkInfo();
6464

65-
if(ni != null && ni.getState() == NetworkInfo.State.CONNECTED) {
66-
notifyNetworkAvailable();
67-
} else if(intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,Boolean.FALSE)) {
68-
notifyNetworkUnavailable(new ErrorInfo("No network connection available", 503, 80003));
69-
}
70-
}
71-
}
65+
if(ni != null && ni.getState() == NetworkInfo.State.CONNECTED) {
66+
notifyNetworkAvailable();
67+
} else if(intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,Boolean.FALSE)) {
68+
notifyNetworkUnavailable(new ErrorInfo("No network connection available", 503, 80003));
69+
}
70+
}
71+
}
7272

73-
private final Context applicationContext;
74-
private NetworkStateReceiver networkStateReceiver;
73+
private final Context applicationContext;
74+
private NetworkStateReceiver networkStateReceiver;
7575

76-
private static WeakHashMap<Context, AndroidNetworkConnectivity> contexts = new WeakHashMap<Context, AndroidNetworkConnectivity>();
76+
private static WeakHashMap<Context, AndroidNetworkConnectivity> contexts = new WeakHashMap<Context, AndroidNetworkConnectivity>();
7777
}

android/src/main/java/io/ably/lib/platform/Platform.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,40 @@
1414
import java.util.WeakHashMap;
1515

1616
public class Platform {
17-
public static final String name = "android";
18-
19-
public Platform() {}
20-
21-
public Context getApplicationContext() {
22-
return applicationContext;
23-
}
24-
/**
25-
* Set the Android Context for this instance
26-
*/
27-
public void setAndroidContext(Context context) throws AblyException {
28-
context = context.getApplicationContext();
29-
if(applicationContext != null) {
30-
if(context == applicationContext) {
31-
return;
32-
}
33-
throw AblyException.fromErrorInfo(new ErrorInfo("Incompatible application context set", 40000, 400));
34-
}
35-
applicationContext = context;
36-
AndroidNetworkConnectivity.getNetworkConnectivity(context).addListener(this.networkConnectivity);
37-
}
38-
39-
public boolean hasApplicationContext() {
40-
return applicationContext != null;
41-
}
42-
43-
/**
44-
* Get the NetworkConnectivity tracker instance for this context
45-
* @return
46-
*/
47-
public NetworkConnectivity getNetworkConnectivity() {
48-
return networkConnectivity;
49-
}
50-
51-
private Context applicationContext;
52-
private final DelegatedNetworkConnectivity networkConnectivity = new DelegatedNetworkConnectivity();
17+
public static final String name = "android";
18+
19+
public Platform() {}
20+
21+
public Context getApplicationContext() {
22+
return applicationContext;
23+
}
24+
/**
25+
* Set the Android Context for this instance
26+
*/
27+
public void setAndroidContext(Context context) throws AblyException {
28+
context = context.getApplicationContext();
29+
if(applicationContext != null) {
30+
if(context == applicationContext) {
31+
return;
32+
}
33+
throw AblyException.fromErrorInfo(new ErrorInfo("Incompatible application context set", 40000, 400));
34+
}
35+
applicationContext = context;
36+
AndroidNetworkConnectivity.getNetworkConnectivity(context).addListener(this.networkConnectivity);
37+
}
38+
39+
public boolean hasApplicationContext() {
40+
return applicationContext != null;
41+
}
42+
43+
/**
44+
* Get the NetworkConnectivity tracker instance for this context
45+
* @return
46+
*/
47+
public NetworkConnectivity getNetworkConnectivity() {
48+
return networkConnectivity;
49+
}
50+
51+
private Context applicationContext;
52+
private final DelegatedNetworkConnectivity networkConnectivity = new DelegatedNetworkConnectivity();
5353
}

0 commit comments

Comments
 (0)