Back to project page FisgoDroid.
The source code is released under:
The smiley icons bundled with this application belong to Meneame.NET and are licensed under the Creative Commons by-sa 3.0 license. For more information, please visit http://creativecommons.org/licens...
If you think the Android project FisgoDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.meneame.fisgodroid; //from w w w .jav a 2 s .co m import java.util.regex.Matcher; import java.util.regex.Pattern; public class UserProfileFetcher { private static final Pattern mUsernamePattern = Pattern.compile("<strong>usuario:</strong> ([^<]+)"); private static final Pattern mAvatarPattern = Pattern.compile("<img class=\"avatar big\" style=\"margin-right: 5px\" src=\"([^\"]+)\""); private static final Pattern mNamePattern = Pattern.compile("<strong>nombre:</strong> ([^<]+)<"); private static final Pattern mBioPattern = Pattern.compile("<strong>bio</strong>:<br/>(.*)", Pattern.DOTALL); private static final Pattern mFriendshipPattern = Pattern.compile("width=\"18\" height=\"16\" title=\"([^\"]+)\"/>"); public static UserProfile fetch(FisgoService.FisgoBinder service, String userid) { UserProfile profile = null; IHttpService http = new HttpService(); String result = service.getUserInfo(userid); if ( result != null && !result.equals("") && !result.equals("usuario inexistente") ) { profile = new UserProfile(); // User name Matcher m = mUsernamePattern.matcher(result); if ( !m.find() ) return null; profile.setUsername(m.group(1)); // Avatar m = mAvatarPattern.matcher(result); if ( m.find() ) { profile.setAvatarUrl(m.group(1)); } // Name m = mNamePattern.matcher(result); if ( m.find() ) { profile.setName(m.group(1)); } // Bio m = mBioPattern.matcher(result); if ( m.find() ) { profile.setBio(m.group(1)); } // Friendship status m = mFriendshipPattern.matcher(result); if ( m.find() ) { profile.setFriendship(FriendshipStatus.fromName(m.group(1))); } } return profile; } }