From 706a65fe415ebeedd12e6a132d5dddf47485fbb4 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Wed, 28 Jan 2015 18:04:33 +0100 Subject: [PATCH] new BlogUtils.getHostNameFromAccountMap function --- .../org/wordpress/android/util/BlogUtils.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/BlogUtils.java b/WordPressUtils/src/main/java/org/wordpress/android/util/BlogUtils.java index 1da5d104384d..4944bf0a8a2d 100644 --- a/WordPressUtils/src/main/java/org/wordpress/android/util/BlogUtils.java +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/BlogUtils.java @@ -26,11 +26,25 @@ public int compare(Object blog1, Object blog2) { /** * Return a blog name or blog url (host part only) if trimmed name is an empty string */ - public static String getBlogNameFromAccountMap(Map account) { - String blogName = StringUtils.unescapeHTML(MapUtils.getMapStr(account, "blogName")); + public static String getBlogNameOrHostNameFromAccountMap(Map account) { + String blogName = getBlogNameFromAccountMap(account); if (blogName.trim().length() == 0) { blogName = StringUtils.getHost(MapUtils.getMapStr(account, "url")); } return blogName; } -} \ No newline at end of file + + /** + * Return a blog name or blog url (host part only) if trimmed name is an empty string + */ + public static String getBlogNameFromAccountMap(Map account) { + return StringUtils.unescapeHTML(MapUtils.getMapStr(account, "blogName")); + } + + /** + * Return blog url (host part only) if trimmed name is an empty string + */ + public static String getHostNameFromAccountMap(Map account) { + return StringUtils.getHost(MapUtils.getMapStr(account, "url")); + } +}