From 701b8617de429313635045ec50f2c14da5e96efb Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 19 Sep 2019 11:47:19 +0200 Subject: cancel spinning wheel on muclumbus error --- .../services/ChannelDiscoveryService.java | 22 +++++++++++++--------- .../messenger/utils/IrregularUnicodeDetector.java | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java b/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java index e78d1702c..a0e0a0219 100644 --- a/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java +++ b/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java @@ -1,5 +1,6 @@ package de.pixart.messenger.services; +import android.support.annotation.NonNull; import android.util.Log; import com.google.common.cache.Cache; @@ -33,12 +34,12 @@ public class ChannelDiscoveryService { private final Cache> cache; - public ChannelDiscoveryService(XmppConnectionService service) { + ChannelDiscoveryService(XmppConnectionService service) { this.service = service; this.cache = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES).build(); } - public void initializeMuclumbusService() { + void initializeMuclumbusService() { OkHttpClient.Builder builder = new OkHttpClient.Builder(); if (service.useTorToConnect()) { try { @@ -57,7 +58,7 @@ public class ChannelDiscoveryService { this.muclumbusService = retrofit.create(MuclumbusService.class); } - public void discover(String query, OnChannelSearchResultsFound onChannelSearchResultsFound) { + void discover(String query, OnChannelSearchResultsFound onChannelSearchResultsFound) { final boolean all = query == null || query.trim().isEmpty(); Log.d(Config.LOGTAG, "discover channels. query=" + query); List result = cache.getIfPresent(all ? "" : query); @@ -77,9 +78,11 @@ public class ChannelDiscoveryService { try { call.enqueue(new Callback() { @Override - public void onResponse(Call call, Response response) { + public void onResponse(@NonNull Call call, @NonNull Response response) { final MuclumbusService.Rooms body = response.body(); if (body == null) { + Log.d(Config.LOGTAG, "code from muclumbus=" + response.code()); + listener.onChannelSearchResultsFound(Collections.emptyList()); return; } cache.put("", body.items); @@ -87,7 +90,7 @@ public class ChannelDiscoveryService { } @Override - public void onFailure(Call call, Throwable throwable) { + public void onFailure(@NonNull Call call, @NonNull Throwable throwable) { Log.d(Config.LOGTAG, "Unable to query muclumbus on " + Config.CHANNEL_DISCOVERY, throwable); listener.onChannelSearchResultsFound(Collections.emptyList()); } @@ -102,10 +105,11 @@ public class ChannelDiscoveryService { searchResultCall.enqueue(new Callback() { @Override - public void onResponse(Call call, Response response) { - System.out.println(response.message()); - MuclumbusService.SearchResult body = response.body(); + public void onResponse(@NonNull Call call, @NonNull Response response) { + final MuclumbusService.SearchResult body = response.body(); if (body == null) { + Log.d(Config.LOGTAG, "code from muclumbus=" + response.code()); + listener.onChannelSearchResultsFound(Collections.emptyList()); return; } cache.put(query, body.result.items); @@ -113,7 +117,7 @@ public class ChannelDiscoveryService { } @Override - public void onFailure(Call call, Throwable throwable) { + public void onFailure(@NonNull Call call, @NonNull Throwable throwable) { Log.d(Config.LOGTAG, "Unable to query muclumbus on " + Config.CHANNEL_DISCOVERY, throwable); listener.onChannelSearchResultsFound(Collections.emptyList()); } diff --git a/src/main/java/de/pixart/messenger/utils/IrregularUnicodeDetector.java b/src/main/java/de/pixart/messenger/utils/IrregularUnicodeDetector.java index 74e3aa6c7..3775494e7 100644 --- a/src/main/java/de/pixart/messenger/utils/IrregularUnicodeDetector.java +++ b/src/main/java/de/pixart/messenger/utils/IrregularUnicodeDetector.java @@ -212,7 +212,7 @@ public class IrregularUnicodeDetector { } return flat; } - + private static boolean containsOnlyAmbiguousCyrillic(Collection codePoints) { for (String codePoint : codePoints) { if (!AMBIGUOUS_CYRILLIC.contains(codePoint)) { -- cgit v1.2.3