Android Open Source - Android-VKontakte-SDK Group






From Project

Back to project page Android-VKontakte-SDK.

License

The source code is released under:

MIT License

If you think the Android project Android-VKontakte-SDK 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 com.perm.kate.api;
//from   www . j  a v a2 s  .  c  om
import java.io.Serializable;
import java.util.ArrayList;

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

public class Group implements Serializable {
    
    private static final long serialVersionUID = 1L;
    public long gid;
    public String name;
    public String photo;//50*50
    public Boolean is_closed;
    public Boolean is_member;
    
    //???? ????? ?????, ??????? ? ???? ???? ??? ? ????
    //public String screen_name;
    public String photo_medium;//100*100
    public String photo_big;//200*200
    public String description;
    public String wiki_page;
    public Long fixed_post;
    public Boolean can_see_all_posts;//can_see_all_posts=false ???????? ??? ?????? ???????
    public Boolean is_admin;
    public Integer admin_level;//1-moder, 2-editor, 3-admin
    public ArrayList<Contact> contacts; 
    public Integer members_count;
    public Integer type; //0 - group, 1 - page, 2 - event    
    public ArrayList<Link> links;

    public static Group parse(JSONObject o) throws JSONException{
        Group g=new Group();
        g.gid = o.getLong("id");
        g.name = Api.unescape(o.getString("name"));
        g.photo = o.optString("photo_50");
        g.photo_medium = o.optString("photo_100");
        g.photo_big = o.optString("photo_200");
        String is_closed = o.optString("is_closed");
        if(is_closed != null)
            g.is_closed = is_closed.equals("1");
        String is_member = o.optString("is_member");
        if(is_member != null)
            g.is_member = is_member.equals("1");
        g.description = Api.unescape(o.optString("description", null));
        g.wiki_page = Api.unescape(o.optString("wiki_page", null));
        
        //fixed post
        g.fixed_post=o.optLong("fixed_post", -1);//may be just false - boolean. If failed to parse long it means no post is fixed.
        if(g.fixed_post==-1)
            g.fixed_post=null;
        
        //???? ????? ?????, ??????? ? ???? ???? ??? ? ????
        //g.screen_name=o.optString("screen_name");

        if(o.has("can_see_all_posts"))
            g.can_see_all_posts=o.optInt("can_see_all_posts", 1)==1;
        
        //if doesn't exist it means value is unknown
        if(o.has("is_admin"))
            //opt because there may be something unparseable
            g.is_admin=o.optInt("is_admin", 0)==1;
        
        //if doesn't exist it means value is unknown
        if(o.has("admin_level"))
            //opt because there may be something unparseable
            g.admin_level=o.optInt("admin_level", 1);
        
        JSONArray jcontacts = o.optJSONArray("contacts");
        if (jcontacts != null) {
            g.contacts = new ArrayList<Contact>();
            for (int i = 0; i < jcontacts.length(); i++) {
                JSONObject jcontact = (JSONObject)jcontacts.get(i);
                Contact contact = Contact.parse(jcontact);
                if (contact != null)
                    g.contacts.add(contact);
            }
        }
        
        //if doesn't exist it means value is unknown
        if(o.has("members_count"))
            //opt because there may be something unparseable
            g.members_count=o.optInt("members_count", 0);
        if (o.has("type")) {
            String str_type = o.optString("type");
            if ("group".equals(str_type))
                g.type = 0;
            else if ("page".equals(str_type))
                g.type = 1;
            else if ("event".equals(str_type))
                g.type = 2;
        }
        
        JSONArray jlinks = o.optJSONArray("links");
        if (jlinks != null) {
            g.links = new ArrayList<Link>();
            for (int i = 0; i < jlinks.length(); i++) {
                JSONObject jlink = (JSONObject)jlinks.get(i);
                Link link = Link.parseFromGroup(jlink);
                if (link != null)
                    g.links.add(link);
            }
        }
        return g;
    }
    
    public static ArrayList<Group> parseGroups(JSONArray jgroups) throws JSONException {
        ArrayList<Group> groups=new ArrayList<Group>();
        for(int i = 0; i < jgroups.length(); i++) {
            //???? ?????? groups.get ?????? ???????? - ???????????
            if(!(jgroups.get(i) instanceof JSONObject))
                continue;
            JSONObject jgroup = (JSONObject)jgroups.get(i);
            Group group = Group.parse(jgroup);
            groups.add(group);
        }
        return groups;
    }
}




Java Source Code List

com.perm.kate.api.Album.java
com.perm.kate.api.Api.java
com.perm.kate.api.Attachment.java
com.perm.kate.api.AudioAlbum.java
com.perm.kate.api.Audio.java
com.perm.kate.api.Auth.java
com.perm.kate.api.BanInfo.java
com.perm.kate.api.BannArg.java
com.perm.kate.api.City.java
com.perm.kate.api.CommentList.java
com.perm.kate.api.Comment.java
com.perm.kate.api.Constants.java
com.perm.kate.api.Contact.java
com.perm.kate.api.Counters.java
com.perm.kate.api.Country.java
com.perm.kate.api.Document.java
com.perm.kate.api.FriendsList.java
com.perm.kate.api.Geo.java
com.perm.kate.api.Gift.java
com.perm.kate.api.Graffiti.java
com.perm.kate.api.GroupBanItem.java
com.perm.kate.api.GroupTopic.java
com.perm.kate.api.Group.java
com.perm.kate.api.IdsPair.java
com.perm.kate.api.KException.java
com.perm.kate.api.LastActivity.java
com.perm.kate.api.Link.java
com.perm.kate.api.Media.java
com.perm.kate.api.Message.java
com.perm.kate.api.NameCases.java
com.perm.kate.api.NewsItem.java
com.perm.kate.api.NewsJTags.java
com.perm.kate.api.NewsTypes.java
com.perm.kate.api.Newsfeed.java
com.perm.kate.api.Note.java
com.perm.kate.api.Notification.java
com.perm.kate.api.Notifications.java
com.perm.kate.api.Page.java
com.perm.kate.api.Params.java
com.perm.kate.api.PhotoComment.java
com.perm.kate.api.PhotoTag.java
com.perm.kate.api.Photo.java
com.perm.kate.api.Place.java
com.perm.kate.api.Reply.java
com.perm.kate.api.SearchDialogItem.java
com.perm.kate.api.User.java
com.perm.kate.api.Video.java
com.perm.kate.api.VkApp.java
com.perm.kate.api.VkPollAnswer.java
com.perm.kate.api.VkPoll.java
com.perm.kate.api.VkStatus.java
com.perm.kate.api.WallMessage.java
com.perm.kate.api.sample.Account.java
com.perm.kate.api.sample.Constants.java
com.perm.kate.api.sample.LoginActivity.java
com.perm.kate.api.sample.MainActivity.java
com.perm.utils.Utils.java
com.perm.utils.WrongResponseCodeException.java