Skip to content

Commit

Permalink
Merge branch 'develop' into feature/modularize-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Mar 30, 2015
2 parents 28ca417 + fd92adf commit d2cfae7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.wordpress.android.util;

import android.app.ActivityManager;
import android.content.Context;

public class ServiceUtils {
public static boolean isServiceRunning(Context context, Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wordpress.android.util;

import android.net.Uri;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;

Expand Down Expand Up @@ -195,4 +196,14 @@ public static boolean isValidUrlAndHostNotNull(String url) {
}
return true;
}

// returns true if the passed url is for an image
public static boolean isImageUrl(String url) {
if (TextUtils.isEmpty(url)) return false;

String cleanedUrl = removeQuery(url.toLowerCase());

return cleanedUrl.endsWith("jpg") || cleanedUrl.endsWith("jpeg") ||
cleanedUrl.endsWith("gif") || cleanedUrl.endsWith("png");
}
}

0 comments on commit d2cfae7

Please sign in to comment.