mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
nearby: Show 'no images in this area' message instead of generic error (#5541)
This commit is contained in:
parent
74f2e9cd60
commit
9a8b89c19a
4 changed files with 46 additions and 2 deletions
|
|
@ -447,6 +447,9 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
|||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(explorePlacesInfo -> {
|
||||
mediaList = explorePlacesInfo.mediaList;
|
||||
if(mediaList == null) {
|
||||
showResponseMessage(getString(R.string.no_pictures_in_this_area));
|
||||
}
|
||||
updateMapMarkers(explorePlacesInfo);
|
||||
lastMapFocus = new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude());
|
||||
},
|
||||
|
|
@ -475,6 +478,10 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
|||
ViewUtil.showLongToast(getActivity(), message);
|
||||
}
|
||||
|
||||
private void showResponseMessage(final String message) {
|
||||
ViewUtil.showLongSnackbar(getView(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPermissionsAndPerformAction() {
|
||||
Timber.d("Checking permission and perfoming action");
|
||||
|
|
|
|||
|
|
@ -167,7 +167,6 @@ public class ExploreMapPresenter
|
|||
if (explorePlacesInfo.mediaList != null) {
|
||||
prepareNearbyBaseMarkers(explorePlacesInfo, selectedMarker);
|
||||
} else {
|
||||
//TODO: SHOW SNACKBAR
|
||||
lockUnlockNearby(false); // So that new location updates wont come
|
||||
exploreMapFragmentView.setProgressBarVisibility(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,22 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
import static java.security.AccessController.getContext;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class ViewUtil {
|
||||
|
|
@ -32,6 +38,37 @@ public class ViewUtil {
|
|||
}
|
||||
});
|
||||
}
|
||||
public static void showLongSnackbar(View view, String text) {
|
||||
if(view.getContext() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecutorUtils.uiExecutor().execute(()-> {
|
||||
try {
|
||||
Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_SHORT);
|
||||
|
||||
View snack_view = snackbar.getView();
|
||||
TextView snack_text = snack_view.findViewById(R.id.snackbar_text);
|
||||
|
||||
snack_view.setBackgroundColor(Color.LTGRAY);
|
||||
snack_text.setTextColor(ContextCompat.getColor(view.getContext(), R.color.primaryColor));
|
||||
snackbar.setActionTextColor(Color.RED);
|
||||
|
||||
snackbar.setAction("Dismiss", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Handle the action click
|
||||
snackbar.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
snackbar.show();
|
||||
|
||||
}catch (IllegalStateException e) {
|
||||
Timber.e(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showLongToast(Context context, String text) {
|
||||
if (context == null) {
|
||||
|
|
|
|||
|
|
@ -355,6 +355,7 @@
|
|||
<string name="rotate">Rotate</string>
|
||||
|
||||
<string name="error_fetching_nearby_places">Error fetching nearby places.</string>
|
||||
<string name="no_pictures_in_this_area">No pictures in this area</string>
|
||||
<string name="no_nearby_places_around">No nearby places around</string>
|
||||
<string name="error_fetching_nearby_monuments">Error fetching nearby monuments.</string>
|
||||
<string name="no_recent_searches">No recent searches</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue