Android Open Source - spots Static Database






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  w w.  jav a2  s  .c  om*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.dcc.matc89.spots.network.PostSpots;
import com.dcc.matc89.spots.network.PostSpots.OnSpotReceiver;

public class StaticDatabase {
  
  private static StaticDatabase singleton = new StaticDatabase();
  
  private List<Group> groups = new ArrayList<Group>();
  private List<Long> groupsId;
  private List<User> users;
  private List<Sport> sports;
  private List<Spot> spots;

  public StaticDatabase() {
    groupsId = Arrays.asList(Long.valueOf(1), Long.valueOf(2), Long.valueOf(3), Long.valueOf(4));
    users = Arrays.asList(
        new User(1, "Jo?o", "Salvador - BA", null, "1203029403293", groupsId),
        new User(2, "Jose", "Salvador - BA", null, "1203029403293", groupsId),
        new User(3, "Joaquim", "Salvador - BA", "1203029403293", null, groupsId),
        new User(4, "Jorge", "Salvador - BA", "1203029403293", null, groupsId));
    sports = Arrays.asList(
        new Sport(1, "Basquete"),
        new Sport(2, "Vlei"),
        new Sport(3, "Parkour"));
    spots  = Arrays.asList(
        new Spot(1, "Est?dio de Esportes UFBA", "Um spot qualquer", groupsId, sports, -12.971111, -38.510833),
        new Spot(2, "Parque Foo", "Um spot qualquer", groupsId, sports, -12.971111, -38.510833),
        new Spot(3, "Pra?a Orl?stica", "Um spot qualquer", groupsId, sports, -12.971111, -38.510833),
        new Spot(4, "Lugar para praticar esportes", "Um spot qualquer", groupsId, sports, -12.971111, -38.510833));
    groups = Arrays.asList(
        new Group(1, "Carcar?", "Um grupo qualquer", groupsId, groupsId, sports.get(0)),
        new Group(2, "Chacal", "Um grupo qualquer", groupsId, groupsId, sports.get(0)),
        new Group(3, "Cutia", "Um grupo qualquer", groupsId, groupsId, sports.get(0)),
        new Group(4, "Limite Radical", "Um grupo qualquer", groupsId, groupsId, sports.get(0)));
    setSports(Arrays.asList(
        new Sport(2, "Vlei"),
        new Sport(4, "Futebol"),
        new Sport(1, "Basquete"),
        new Sport(5, "Slackline"),
        new Sport(6, "Escalada"),
        new Sport(3, "Parkour"))
        );
    OnSpotReceiver receiver = new OnSpotReceiver(){
      @Override
      public void onSpotsReceived(Spot spot){}
    };
    for (int i = 0; i < 4; i++){
      new PostSpots().newSpot(receiver, spots.get(i), 1);
    }
  }
  
  public static StaticDatabase getSingleton(){
    return singleton;
  }

  public List<Group> getGroups() {
    return groups;
  }

  public void setGroups(List<Group> groups) {
    this.groups = groups;
  }

  public List<User> getUsers() {
    return users;
  }

  public void setUsers(List<User> users) {
    this.users = users;
  }

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

  public void setSports(List<Sport> sports) {
    this.sports = sports;
  }

  public List<Spot> getSpots() {
    return spots;
  }

  public void setSpots(List<Spot> spots) {
    this.spots = spots;
  }
  
  public void addGroup(Group group){
    this.groups.add(group);
  }
  
  public void addSpot(Spot spot){
    this.spots.add(spot);
  }
  
  public void addUser(User user){
    this.users.add(user);
  }
  
  public void addSport(Sport sport){
    this.sports.add(sport);
  }
  
  public Group getGroupByName(String name){
    int i = 0;
    while(i < this.groups.size()){
      if(this.groups.get(i).getName().equalsIgnoreCase(name)){
        return this.groups.get(i);
      } else {
        i = i+1;
      }
    }
    return null;
  }
  
  public User getUserByFId (String facebookId) {
    int i = 0;
    while(i < this.users.size()){
      if (this.users.get(i).getFacebookId().equalsIgnoreCase(facebookId)) {
        return this.users.get(i);
      } else {
        i = i+1;
      }
    }
    return null;
  }
  
  public Sport getSportByName (String name) {
    int i = 0;
    while (i < this.sports.size()){
      if (this.sports.get(i).getName().equalsIgnoreCase(name)) {
        return this.sports.get(i);
      } else {
        i = i+1;
      }
    }
    return null;
  }
  
  public Spot getSpotByName (String name) {
    int i = 0;
    while (i < this.spots.size()){
      if (this.spots.get(i).getName().equalsIgnoreCase(name)){
        return this.spots.get(i);
      } else {
        i = i+1;
      }
    }
    return null;
  }
  
}




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