From cceace8e6533cf00bc2c6b0b4bab933f50158c7e Mon Sep 17 00:00:00 2001 From: tom79 Date: Mon, 25 Mar 2019 18:50:48 +0100 Subject: [PATCH] Fix typo --- .../mastodon/drawers/StatusListAdapter.java | 2 +- .../webview/MastalabWebViewClient.java | 47 ++++++++++--------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index 9c70f131a..2e37c1186 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -560,7 +560,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct if( status.getPoll() != null && status.getPoll().getOptionsList() != null ){ Poll poll = status.getPoll(); int choiceCount = status.getPoll().getOptionsList().size(); - if( poll.isVoted()){ + if( poll.isVoted() || poll.isExpired()){ holder.rated.setVisibility(View.VISIBLE); List items = new ArrayList<>(); int greaterValue = 0; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java b/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java index ae92ac483..10c2ee225 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java @@ -57,25 +57,9 @@ public class MastalabWebViewClient extends WebViewClient { @Override public WebResourceResponse shouldInterceptRequest (final WebView view, String url) { - URI uri; - try { - uri = new URI(url); - String domain = uri.getHost(); - if( domain != null) { - domain = domain.startsWith("www.") ? domain.substring(4) : domain; - } - if (domain != null && WebviewActivity.trackingDomains.contains(domain)) { - if( activity instanceof WebviewActivity){ - count++; - domains.add(url); - ((WebviewActivity)activity).setCount(activity, String.valueOf(count)); - } - ByteArrayInputStream nothing = new ByteArrayInputStream("".getBytes()); - return new WebResourceResponse("text/plain", "utf-8", nothing); - } - } catch (URISyntaxException e) { + if( WebviewActivity.trackingDomains != null){ + URI uri; try { - url = url.substring(0,50); uri = new URI(url); String domain = uri.getHost(); if( domain != null) { @@ -89,11 +73,30 @@ public class MastalabWebViewClient extends WebViewClient { } ByteArrayInputStream nothing = new ByteArrayInputStream("".getBytes()); return new WebResourceResponse("text/plain", "utf-8", nothing); - } - } catch (URISyntaxException ignored) { - ignored.printStackTrace(); - } } + } catch (URISyntaxException e) { + try { + url = url.substring(0, 50); + uri = new URI(url); + String domain = uri.getHost(); + if (domain != null) { + domain = domain.startsWith("www.") ? domain.substring(4) : domain; + } + if (domain != null && WebviewActivity.trackingDomains.contains(domain)) { + if (activity instanceof WebviewActivity) { + count++; + domains.add(url); + ((WebviewActivity) activity).setCount(activity, String.valueOf(count)); + } + ByteArrayInputStream nothing = new ByteArrayInputStream("".getBytes()); + return new WebResourceResponse("text/plain", "utf-8", nothing); + + } + } catch (URISyntaxException ignored) { + ignored.printStackTrace(); + } + } + } return super.shouldInterceptRequest(view, url); }