mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +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
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue