Android Open Source - FisgoDroid User Profile Fetcher






From Project

Back to project page FisgoDroid.

License

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.

Java Source Code

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>&nbsp;([^<]+)");
    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>&nbsp;([^<]+)<");
    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;
    }
}




Java Source Code List

jp.tomorrowkey.android.GifDecoder.java
net.meneame.fisgodroid.AnimatedGifDrawable.java
net.meneame.fisgodroid.ChatActivity.java
net.meneame.fisgodroid.ChatBaseView.java
net.meneame.fisgodroid.ChatBubbleView.java
net.meneame.fisgodroid.ChatLineView.java
net.meneame.fisgodroid.ChatMessage.java
net.meneame.fisgodroid.ChatType.java
net.meneame.fisgodroid.DynamicTextView.java
net.meneame.fisgodroid.FisgoScheduler.java
net.meneame.fisgodroid.FisgoService.java
net.meneame.fisgodroid.FisgodroidApplication.java
net.meneame.fisgodroid.FriendshipStatus.java
net.meneame.fisgodroid.HttpService.java
net.meneame.fisgodroid.IHttpService.java
net.meneame.fisgodroid.ImageUpload.java
net.meneame.fisgodroid.LogSaver.java
net.meneame.fisgodroid.LoginActivity.java
net.meneame.fisgodroid.LoginStatus.java
net.meneame.fisgodroid.Notifications.java
net.meneame.fisgodroid.ProfileActivity.java
net.meneame.fisgodroid.SettingsActivity.java
net.meneame.fisgodroid.SmileyPickerView.java
net.meneame.fisgodroid.SmileySpan.java
net.meneame.fisgodroid.Smiley.java
net.meneame.fisgodroid.Smileys.java
net.meneame.fisgodroid.ThreeStateChecboxHackView.java
net.meneame.fisgodroid.UserProfileFetcher.java
net.meneame.fisgodroid.UserProfile.java
net.meneame.fisgodroid.adapters.BubblesChatAdapter.java
net.meneame.fisgodroid.adapters.ChatMessageAdapter.java
net.meneame.fisgodroid.adapters.LegacyChatAdapter.java
net.meneame.fisgodroid.notifications.ElementAdapter.java
net.meneame.fisgodroid.notifications.NotificationElement.java
net.meneame.fisgodroid.notifications.NotificationView.java
net.meneame.fisgodroid.notifications.NotificationsIndicatorDrawable.java
net.meneame.fisgodroid.notifications.NotificationsLayout.java
net.meneame.fisgodroid.notifications.NotificationsPoller.java