aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/utils')
-rw-r--r--main/src/cgeo/geocaching/utils/ImageUtils.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/ImageUtils.java b/main/src/cgeo/geocaching/utils/ImageUtils.java
index 9f47ead..eb91724 100644
--- a/main/src/cgeo/geocaching/utils/ImageUtils.java
+++ b/main/src/cgeo/geocaching/utils/ImageUtils.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.utils;
import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.compatibility.Compatibility;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@@ -225,4 +226,20 @@ public final class ImageUtils {
}
return Uri.fromFile(file);
}
+
+ /**
+ * Check if the URL contains one of the given substrings.
+ *
+ * @param url the URL to check
+ * @param patterns a list of substrings to check against
+ * @return <tt>true</tt> if the URL contains at least one of the patterns, <tt>false</tt> otherwise
+ */
+ public static boolean containsPattern(final String url, final String[] patterns) {
+ for (String entry : patterns) {
+ if (StringUtils.containsIgnoreCase(url, entry)) {
+ return true;
+ }
+ }
+ return false;
+ }
}