Skip to content

Commit

Permalink
Differentiate error for empty food list on active filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Faltenreich committed Jun 14, 2020
1 parent a49c3be commit 08fe725
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.faltenreich.diaguard.feature.preference.data.PreferenceStore;
import com.faltenreich.diaguard.shared.data.database.dao.FoodDao;
import com.faltenreich.diaguard.shared.data.database.entity.Food;
import com.faltenreich.diaguard.shared.data.primitive.StringUtils;
import com.faltenreich.diaguard.shared.data.repository.FoodRepository;
import com.faltenreich.diaguard.shared.event.Events;
import com.faltenreich.diaguard.shared.event.data.FoodDeletedEvent;
Expand Down Expand Up @@ -183,7 +184,9 @@ private void clear() {

private void showEmptyList() {
if (getContext() != null) {
if (NetworkingUtils.isOnline(getContext())) {
if (StringUtils.isBlank(searchView.getQuery())) {
showError(R.drawable.ic_settings, R.string.error_no_data, R.string.error_no_data_settings_desc, R.string.settings_open);
} else if (NetworkingUtils.isOnline(getContext())) {
showError(R.drawable.ic_sad, R.string.error_no_data, R.string.error_no_data_desc, R.string.food_add_desc);
} else {
showError(R.drawable.ic_wifi, R.string.error_no_connection, R.string.error_no_connection_desc, R.string.try_again);
Expand Down Expand Up @@ -220,12 +223,16 @@ void onFabClick() {

@OnClick(R.id.food_search_empty_button)
void onEmptyButtonClick() {
// Workaround since CONNECTIVITY_ACTION broadcasts cannot be caught since API level 24
boolean wasNetworkError = emptyText.getText().toString().equals(getString(R.string.error_no_connection));
if (wasNetworkError) {
newSearch();
if (StringUtils.isBlank(searchView.getQuery())) {
openSettings();
} else {
createFood();
// Workaround since CONNECTIVITY_ACTION broadcasts cannot be caught since API level 24
boolean wasNetworkError = emptyText.getText().toString().equals(getString(R.string.error_no_connection));
if (wasNetworkError) {
newSearch();
} else {
createFood();
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
<string name="error_no_connection_desc">Geh online, um mehr Informationen zu erhalten</string>
<string name="error_no_data">Gähnende Leere?</string>
<string name="error_no_data_desc">Versuche es mit einem anderen Suchbegriff oder erstelle ein</string>
<string name="error_no_data_settings_desc">Ändere die Einstellungen für mehr Ergebnisse</string>
<string name="error_no_mail">Keine App zum Senden von E-Mails gefunden</string>
<string name="error_no_app">Keine App zum Öffnen der Datei gefunden</string>
<string name="error_sd_card">Speicherkarte nicht verfügbar</string>
Expand Down Expand Up @@ -379,5 +380,6 @@
<string name="close">Schließen</string>
<string name="basal_rate">Basalrate</string>
<string name="basal_rate_desc">Grundbedarf an Insulin</string>
<string name="settings_open">Einstellungen öffnen</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
<string name="error_no_connection_desc">Vaya en línea para obtener más información</string>
<string name="error_no_data">Tener los bolsillos vacios?</string>
<string name="error_no_data_desc">Pruebe otra consulta para mejorar sus resultados o</string>
<string name="error_no_data_settings_desc">Cambiar la configuración para obtener más resultados</string>
<string name="food">Alimento</string>
<string name="food_common">Comida alimento</string>
<string name="food_delete">Eliminar alimentos</string>
Expand Down Expand Up @@ -382,5 +383,6 @@
<string name="close">Cerrar</string>
<string name="basal_rate">Tasa basal</string>
<string name="basal_rate_desc">Necesidades básicas de insulina</string>
<string name="settings_open">Abrir los ajustes</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
<string name="error_no_connection_desc">Aller en ligne pour obtenir plus d\'informations</string>
<string name="error_no_data">Rien trouvé</string>
<string name="error_no_data_desc">Essayez une autre requête pour améliorer vos résultats ou</string>
<string name="error_no_data_settings_desc">Modifier les paramètres pour plus de résultats</string>
<string name="food">Aliment</string>
<string name="food_common">Alimentation commune</string>
<string name="food_delete">Supprimer un aliment</string>
Expand Down Expand Up @@ -380,5 +381,6 @@
<string name="close">Fermer</string>
<string name="basal_rate">Débit de base</string>
<string name="basal_rate_desc">Les besoins de base en insuline</string>
<string name="settings_open">Paramètres ouverts</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
<string name="error_no_connection_desc">Go online to get more information</string>
<string name="error_no_data">Gaping emptiness?</string>
<string name="error_no_data_desc">Try another query to improve your results or</string>
<string name="error_no_data_settings_desc">Change settings for more results</string>
<string name="error_no_mail">No app found to send E-Mail</string>
<string name="error_no_app">No app found to open file</string>
<string name="error_sd_card">SD card not available</string>
Expand Down Expand Up @@ -555,5 +556,6 @@
<string name="close">Close</string>
<string name="basal_rate">Basal rate</string>
<string name="basal_rate_desc">Basic insulin needs</string>
<string name="settings_open">Open settings</string>

</resources>

0 comments on commit 08fe725

Please sign in to comment.