Android Open Source - ara-twitter Identifier List






From Project

Back to project page ara-twitter.

License

The source code is released under:

Apache License

If you think the Android project ara-twitter 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.bakingcode.io.twitter.model;
/* w  w  w.j  av a 2  s . co m*/
import java.util.ArrayList;

import static com.bakingcode.io.twitter.tools.TwitterLogging.LT;

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

public class IdentifierList extends Cursor{

  /**
   * Logging tag
   */
  private static final String TAG = "IdentifierList";
  
  private ArrayList<Id> idList;
  private long[] idArray;
  
  public IdentifierList(JSONObject json) {
    super(json);
    if (json != null) {
      idList = new ArrayList<Id>();
      try {
        JSONArray array = json.getJSONArray("ids");
        if (array != null) {
          int size = array.length();
          idArray = new long[size];
          Id id;
          for (int i = 0; i < size; i++) {
            id = null;
            Object item = array.get(i);
            if (item instanceof String) {
              String idStr = (String) item;
              id = new Id(idStr);              
            } else if (item instanceof Long) {
              long idLong = (Long) item;
              id = new Id(idLong);              
            } else if (item instanceof Integer) {              
              long idLong = (Integer) item;
              id = new Id(idLong);
              
            }
            if (id != null) {
              idList.add(id);      
              idArray[i] = id.getId();
            }
            
          }
        }        
        
      } catch (JSONException e) {
        LT(TAG, e);
      }
    }
  }
  
  public void add(Id id) {
    if (idList != null) {
      idList.add(id);
    }
  }
  
  public void add(IdentifierList anotherList) {
    if (idList == null) {
      idList = new ArrayList<Id>();
    }
    
    if (anotherList != null) {
      idList.addAll(anotherList.idList);
    }
  }
  
  
  public int size() {
    return (idList != null) ? idList.size() : 0;
  }
  
  public Id elementAt(int index) {
    return (idList != null) ? idList.get(index) : null;
  }
  
  public int indexOf(Id object) {
    return (idList != null) ? idList.indexOf(object) : -1;
  }
  
  public void clear() {
    if (idList != null) {
      idList.clear();
    }
  }
  
  public long[] getIDs() {
    return this.idArray;
  }

}




Java Source Code List

com.bakingcode.io.twitter.Parameters.java
com.bakingcode.io.twitter.TwitterHttpClient.java
com.bakingcode.io.twitter.TwitterOAuth.java
com.bakingcode.io.twitter.Twitter.java
com.bakingcode.io.twitter.Urls.java
com.bakingcode.io.twitter.exceptions.TwitterCommunicationException.java
com.bakingcode.io.twitter.exceptions.TwitterErrorRequestException.java
com.bakingcode.io.twitter.exceptions.TwitterException.java
com.bakingcode.io.twitter.model.ApiConfiguration.java
com.bakingcode.io.twitter.model.ApiMethod.java
com.bakingcode.io.twitter.model.ApiResourceFamily.java
com.bakingcode.io.twitter.model.Coordinates.java
com.bakingcode.io.twitter.model.Cursor.java
com.bakingcode.io.twitter.model.Friendship.java
com.bakingcode.io.twitter.model.IError.java
com.bakingcode.io.twitter.model.Id.java
com.bakingcode.io.twitter.model.IdentifierList.java
com.bakingcode.io.twitter.model.MediaEntity.java
com.bakingcode.io.twitter.model.Place.java
com.bakingcode.io.twitter.model.ResponseString.java
com.bakingcode.io.twitter.model.TrendPlace.java
com.bakingcode.io.twitter.model.Trend.java
com.bakingcode.io.twitter.model.Tweet.java
com.bakingcode.io.twitter.model.TwitterError.java
com.bakingcode.io.twitter.model.User.java
com.bakingcode.io.twitter.tools.HTMLEntity.java
com.bakingcode.io.twitter.tools.Tools.java
com.bakingcode.io.twitter.tools.TwitterLogging.java