Mholloway has uploaded a new change for review.
https://gerrit.wikimedia.org/r/264953
Change subject: Prevent crash in prod content service when requesting empty
definition
......................................................................
Prevent crash in prod content service when requesting empty definition
Sending an empty string to the production content service to request
a Wiktionary definition causes the app to crash (though oddly enough this
does not happen when running locally). This adds a check to immediately
fire a "no definitions found" dialog rather than sending the request when
selectedText.trim() is empty.
Also added a minor fix to hide the progress bar consistently when the "no
definitions found" message is displayed.
Bug: T123783
Change-Id: Iba04e02e16ca5cd1d7d8723999f618c8995fa761
---
M app/src/main/java/org/wikipedia/wiktionary/WiktionaryDialog.java
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia
refs/changes/53/264953/1
diff --git a/app/src/main/java/org/wikipedia/wiktionary/WiktionaryDialog.java
b/app/src/main/java/org/wikipedia/wiktionary/WiktionaryDialog.java
index 1ac95cf..2104c1f 100644
--- a/app/src/main/java/org/wikipedia/wiktionary/WiktionaryDialog.java
+++ b/app/src/main/java/org/wikipedia/wiktionary/WiktionaryDialog.java
@@ -101,7 +101,7 @@
private void loadDefinitions() {
PageService contentService = ContentServiceFactory.create(new
Site(pageTitle.getSite().getLanguageCode() + WIKTIONARY_DOMAIN));
- if (contentService instanceof RbContentService) {
+ if (!selectedText.trim().isEmpty() && contentService instanceof
RbContentService) {
((RbContentService) contentService).define(
addUnderscores(selectedText),
definitionOnLoadCallback);
@@ -132,7 +132,6 @@
if (!isAdded()) {
return;
}
- progressBar.setVisibility(View.GONE);
displayNoDefinitionsFound();
L.e("Wiktionary definition fetch error: " + error);
}
@@ -141,6 +140,7 @@
private void displayNoDefinitionsFound() {
TextView noDefinitionsFoundView = (TextView)
rootView.findViewById(R.id.wiktionary_no_definitions_found);
noDefinitionsFoundView.setVisibility(View.VISIBLE);
+ progressBar.setVisibility(View.GONE);
}
private void layOutDefinitionsByUsage() {
--
To view, visit https://gerrit.wikimedia.org/r/264953
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba04e02e16ca5cd1d7d8723999f618c8995fa761
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mholloway <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits