Android Open Source - spots Spot






From Project

Back to project page spots.

License

The source code is released under:

MIT License

If you think the Android project spots 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.dcc.matc89.spots.model;
//  w  ww .jav a 2s. c o m
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

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

import com.google.android.gms.maps.model.LatLng;

public class Spot  implements Serializable{

  private static final long serialVersionUID = 1217102246152910571L;

  private long id;
  private String name, description;
  private List<Long> groupsId;
  private List<Sport> sports;
  private double latitude;
  private double longitude;
  
  public Spot(long id, String name, String description, List<Long> groups, List<Sport> sports, double lat, double lng) {
    this.id = id;
    this.name = name;
    this.description = description;
    this.groupsId = groups;
    this.sports = sports;
    this.latitude = lat;
    this.longitude = lng;
  }
  
  public static Spot createFromJSONObject(JSONObject object) throws JSONException{
    JSONArray groupsArray = object.getJSONArray("groups");
    List<Long> groups = new ArrayList<Long>(groupsArray.length());
    for(int i = 0; i < groupsArray.length(); i++)
      groups.add(groupsArray.getLong(i));
    JSONArray sportsArray = object.getJSONArray("sports");
    List<Sport> sports = new ArrayList<Sport>(sportsArray.length());
    for(int i = 0; i < sportsArray.length(); i++)
      sports.add(Sport.createFromJSONObject(sportsArray.getJSONObject(i)));
    
    return new Spot(
        object.getLong("id"), 
        object.getString("name"), 
        object.getString("description"), 
        groups,
        sports,
        object.getDouble("latitude"), 
        object.getDouble("longitude"));
  }
  
  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }

  public int getGroupsCount() {
    return groupsId.size();
  }

  public String getName() {
    return name;
  }


  public void setName(String name) {
    this.name = name;
  }


  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public List<Long> getGroupsIds() {
    return groupsId;
  }

  public void setGroupsId(List<Long> groupsId) {
    this.groupsId = groupsId;
  }

  public List<Sport> getSports() {
    return sports;
  }

  public double getLongitude() {
    return longitude;
  }

  public void setLongitude(double longitude) {
    this.longitude = longitude;
  }

  public double getLatitude() {
    return latitude;
  }

  public void setLatitude(double latitude) {
    this.latitude = latitude;
  }

  public void setSports(List<Sport> sports) {
    this.sports = sports;
  }
  
  public LatLng getLatLng(){
    return new LatLng (this.latitude,this.longitude);
  }
  
  @Override
  public String toString() { 
    return getName();
  }
  
}




Java Source Code List

com.dcc.matc89.spots.activity.GroupDetailActivity.java
com.dcc.matc89.spots.activity.GroupEditActivity.java
com.dcc.matc89.spots.activity.GroupListActivity.java
com.dcc.matc89.spots.activity.LoginActionBarActivity.java
com.dcc.matc89.spots.activity.LoginActivity.java
com.dcc.matc89.spots.activity.MainActivity.java
com.dcc.matc89.spots.activity.MyGroupsListActivity.java
com.dcc.matc89.spots.activity.SpotDetailActivity.java
com.dcc.matc89.spots.activity.SpotEditActivity.java
com.dcc.matc89.spots.activity.SpotListActivity.java
com.dcc.matc89.spots.activity.UserDetailActivity.java
com.dcc.matc89.spots.activity.UserListActivity.java
com.dcc.matc89.spots.model.Group.java
com.dcc.matc89.spots.model.Sport.java
com.dcc.matc89.spots.model.Spot.java
com.dcc.matc89.spots.model.StaticDatabase.java
com.dcc.matc89.spots.model.User.java
com.dcc.matc89.spots.network.FetchGroupsAsyncTask.java
com.dcc.matc89.spots.network.FetchGroups.java
com.dcc.matc89.spots.network.FetchSportsAsyncTask.java
com.dcc.matc89.spots.network.FetchSports.java
com.dcc.matc89.spots.network.FetchSpotsAsyncTask.java
com.dcc.matc89.spots.network.FetchSpots.java
com.dcc.matc89.spots.network.FetchUsersAsyncTask.java
com.dcc.matc89.spots.network.FetchUsers.java
com.dcc.matc89.spots.network.OnResultReceiver.java
com.dcc.matc89.spots.network.PostGroupsAsyncTask.java
com.dcc.matc89.spots.network.PostGroups.java
com.dcc.matc89.spots.network.PostLinkSpotGroupAsyncTask.java
com.dcc.matc89.spots.network.PostLinkSpotGroup.java
com.dcc.matc89.spots.network.PostSpotsAsyncTask.java
com.dcc.matc89.spots.network.PostSpots.java
com.dcc.matc89.spots.network.PostUsersAsyncTask.java
com.dcc.matc89.spots.network.PostUsers.java
com.dcc.matc89.spots.network.Utils.java
com.dcc.matc89.spots.social.FacebookFragment.java
com.dcc.matc89.spots.social.LoginFragment.java
com.dcc.matc89.spots.social.OnUserLoginListener.java
com.dcc.matc89.spots.view.CheckboxesDropdownView.java
com.dcc.matc89.spots.view.DropdownView.java