MomsSearchMember.java :  » Client » com-android-moms-client » com » moms » android » client » net » Android Open Source

Android Open Source » Client » com android moms client 
com android moms client » com » moms » android » client » net » MomsSearchMember.java
package com.moms.android.client.net;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;

public class MomsSearchMember
{
  private Context    mContext  = null;
  private JSONObject  jsonObj    = null;

  public MomsSearchMember(Context context)
  {
    mContext = context;
  }

  public void setJson(JSONObject jsonObj)
  {

    this.jsonObj = jsonObj;
  }

  public String getId() throws JSONException
  {
    return jsonObj.getString("list_id");
  }

  public String getNickname() throws JSONException
  {
    return jsonObj.getString("list_nick");
  }
  
  public byte[] getProfile() throws JSONException 
  {
    String profileImageName = null;
    
    profileImageName = jsonObj.getString("list_profile");
  
    if(profileImageName==null) {
      return null;
    }
    
    //       
    if(profileImageName.equals(""))  {
      return null;
    } else {
      return downloadProfileImageNoSave(profileImageName);
    }
  }
  
  public byte[] downloadProfileImageNoSave(String filename)
  {
    byte[] bytes = null;
    
    try 
    {
      URL profile_image_url = null;
      
      ImageManager im = new ImageManager(mContext);
      
      String imageDir = "http://www.moms.kr"+filename;
      
      profile_image_url = new URL(imageDir);
      
      String[] values = filename.split("/");

      if (filename.equals("") || values.length < 1)
      {
        bytes = null;
      } 
      else
      {
        bytes = im.DownloadByteFromUrlNoSave(profile_image_url, values[values.length - 1]);
        if (bytes == null)
        {
          bytes = im.loadSavedProfileImageBytes(values[values.length - 1]);
        }

      }
    } 
    catch (MalformedURLException e) 
    {
      bytes = null;
    } 
    catch (IOException e) 
    {
      bytes = null;
    }
          
    return bytes;
  }
  
  public String getIntro() throws JSONException
  {
    return jsonObj.getString("intro");
  }

  public int getTalkCount() throws JSONException
  {
    return jsonObj.getInt("talk_count");
  }

  public int getFriendCount() throws JSONException
  {
    return jsonObj.getInt("fri_count");
  }

  public int getRelation() throws JSONException
  {
    return jsonObj.getInt("relation");
  }

  public int getTimeStamp() throws JSONException
  {
    return jsonObj.getInt("reg_ts");
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.