diff options
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java | 22 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/IrregularUnicodeDetector.java | 2 |
2 files changed, 14 insertions, 10 deletions
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<String, List<MuclumbusService.Room>> 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<MuclumbusService.Room> result = cache.getIfPresent(all ? "" : query); @@ -77,9 +78,11 @@ public class ChannelDiscoveryService { try { call.enqueue(new Callback<MuclumbusService.Rooms>() { @Override - public void onResponse(Call<MuclumbusService.Rooms> call, Response<MuclumbusService.Rooms> response) { + public void onResponse(@NonNull Call<MuclumbusService.Rooms> call, @NonNull Response<MuclumbusService.Rooms> 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<MuclumbusService.Rooms> call, Throwable throwable) { + public void onFailure(@NonNull Call<MuclumbusService.Rooms> 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<MuclumbusService.SearchResult>() { @Override - public void onResponse(Call<MuclumbusService.SearchResult> call, Response<MuclumbusService.SearchResult> response) { - System.out.println(response.message()); - MuclumbusService.SearchResult body = response.body(); + public void onResponse(@NonNull Call<MuclumbusService.SearchResult> call, @NonNull Response<MuclumbusService.SearchResult> 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<MuclumbusService.SearchResult> call, Throwable throwable) { + public void onFailure(@NonNull Call<MuclumbusService.SearchResult> 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<String> codePoints) { for (String codePoint : codePoints) { if (!AMBIGUOUS_CYRILLIC.contains(codePoint)) { |