diff options
author | Martin Fietz <martin.fietz@gmail.com> | 2018-01-14 17:47:43 +0100 |
---|---|---|
committer | Martin Fietz <martin.fietz@gmail.com> | 2018-01-14 17:47:43 +0100 |
commit | 332943effb89dcfb7aa05d85e7019abb70c965d6 (patch) | |
tree | eb459ac920efd0d2fbb871200af7feef87552f5d /app/src/main/java/de/danoeh/antennapod/dialog | |
parent | 7257a6c76e002e39eef8d1f28c70b654e9954d4e (diff) | |
download | AntennaPod-332943effb89dcfb7aa05d85e7019abb70c965d6.zip |
Replace anonymous type with lambda
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/dialog')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java index 0bd75b5b0..53d200991 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java @@ -243,47 +243,44 @@ public class ProxyDialog { txtvMessage.setTextColor(textColorPrimary); txtvMessage.setText("{fa-circle-o-notch spin} " + checking); txtvMessage.setVisibility(View.VISIBLE); - subscription = Observable.create(new Observable.OnSubscribe<Response>() { - @Override - public void call(Subscriber<? super Response> subscriber) { - String type = (String) spType.getSelectedItem(); - String host = etHost.getText().toString(); - String port = etPort.getText().toString(); - String username = etUsername.getText().toString(); - String password = etPassword.getText().toString(); - int portValue = 8080; - if(!TextUtils.isEmpty(port)) { - portValue = Integer.valueOf(port); - } - SocketAddress address = InetSocketAddress.createUnresolved(host, portValue); - Proxy.Type proxyType = Proxy.Type.valueOf(type.toUpperCase()); - Proxy proxy = new Proxy(proxyType, address); - OkHttpClient.Builder builder = AntennapodHttpClient.newBuilder() - .connectTimeout(10, TimeUnit.SECONDS) - .proxy(proxy); - builder.interceptors().clear(); - OkHttpClient client = builder.build(); - if(!TextUtils.isEmpty(username)) { - String credentials = Credentials.basic(username, password); - client.interceptors().add(chain -> { - Request request = chain.request().newBuilder() - .header("Proxy-Authorization", credentials).build(); - return chain.proceed(request); - }); - } - Request request = new Request.Builder() - .url("http://www.google.com") - .head() - .build(); - try { - Response response = client.newCall(request).execute(); - subscriber.onNext(response); - } catch(IOException e) { - subscriber.onError(e); - } - subscriber.onCompleted(); - } - }) + subscription = Observable.create((Observable.OnSubscribe<Response>) subscriber -> { + String type = (String) spType.getSelectedItem(); + String host = etHost.getText().toString(); + String port = etPort.getText().toString(); + String username = etUsername.getText().toString(); + String password = etPassword.getText().toString(); + int portValue = 8080; + if(!TextUtils.isEmpty(port)) { + portValue = Integer.valueOf(port); + } + SocketAddress address = InetSocketAddress.createUnresolved(host, portValue); + Proxy.Type proxyType = Proxy.Type.valueOf(type.toUpperCase()); + Proxy proxy = new Proxy(proxyType, address); + OkHttpClient.Builder builder = AntennapodHttpClient.newBuilder() + .connectTimeout(10, TimeUnit.SECONDS) + .proxy(proxy); + builder.interceptors().clear(); + OkHttpClient client = builder.build(); + if(!TextUtils.isEmpty(username)) { + String credentials = Credentials.basic(username, password); + client.interceptors().add(chain -> { + Request request = chain.request().newBuilder() + .header("Proxy-Authorization", credentials).build(); + return chain.proceed(request); + }); + } + Request request = new Request.Builder() + .url("http://www.google.com") + .head() + .build(); + try { + Response response = client.newCall(request).execute(); + subscriber.onNext(response); + } catch(IOException e) { + subscriber.onError(e); + } + subscriber.onCompleted(); + }) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( |