File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
WordPressUtils/src/main/java/org/wordpress/android/util Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .wordpress .android .util ;
2+
3+ import android .app .ActivityManager ;
4+ import android .content .Context ;
5+
6+ public class ServiceUtils {
7+ public static boolean isServiceRunning (Context context , Class <?> serviceClass ) {
8+ ActivityManager manager = (ActivityManager ) context .getSystemService (Context .ACTIVITY_SERVICE );
9+ for (ActivityManager .RunningServiceInfo service : manager .getRunningServices (Integer .MAX_VALUE )) {
10+ if (serviceClass .getName ().equals (service .service .getClassName ())) {
11+ return true ;
12+ }
13+ }
14+ return false ;
15+ }
16+ }
Original file line number Diff line number Diff line change 11package org .wordpress .android .util ;
22
33import android .net .Uri ;
4+ import android .text .TextUtils ;
45import android .webkit .MimeTypeMap ;
56import android .webkit .URLUtil ;
67
@@ -195,4 +196,14 @@ public static boolean isValidUrlAndHostNotNull(String url) {
195196 }
196197 return true ;
197198 }
199+
200+ // returns true if the passed url is for an image
201+ public static boolean isImageUrl (String url ) {
202+ if (TextUtils .isEmpty (url )) return false ;
203+
204+ String cleanedUrl = removeQuery (url .toLowerCase ());
205+
206+ return cleanedUrl .endsWith ("jpg" ) || cleanedUrl .endsWith ("jpeg" ) ||
207+ cleanedUrl .endsWith ("gif" ) || cleanedUrl .endsWith ("png" );
208+ }
198209}
You can’t perform that action at this time.
0 commit comments