Android Open Source - lostpets Pets






From Project

Back to project page lostpets.

License

The source code is released under:

GNU General Public License

If you think the Android project lostpets 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 fr.esiea.mobile.lostpets.model;
//w  ww .j  a va  2s.  c  o m
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Observable;

/**
 * Created by david on 26/10/2014.
 */
//This class is the Pets model (HashMap<String,Pet>)
public class Pets extends Observable {

    private static Pets instance;
    public static Pets getInstance() {
        if (instance == null) {
            instance = new Pets();
        }
        return instance;
    }

    Map<Integer,Pet> lstPet = new HashMap<Integer,Pet>();
    private Pets(){

    }

    public ArrayList<Pet> getPets(){
        return new ArrayList(lstPet.values());
    }

    public Pet getPetById (Integer id){
        return lstPet.get(id);
    }

    public void resetPets(){
        lstPet.clear();
    }

    public void addPet (Pet pet){
        if (!lstPet.containsKey(pet.getM_petId())){
            lstPet.put(pet.getM_petId(), pet);
        }
    }

    public void updatePets(JSONArray array){
        resetPets();
        for (int i= 0; i< array.length(); i++){
            JSONObject json = array.optJSONObject(i);
            addPet(new Pet(json));
        }
        //Notify observers that the lost pet list has changed
        setChanged();
        notifyObservers();
    }
}




Java Source Code List

fr.esiea.mobile.lostpets.ApplicationTest.java
fr.esiea.mobile.lostpets.activity.CreateLostPetActivity.java
fr.esiea.mobile.lostpets.activity.InfosActivity.java
fr.esiea.mobile.lostpets.activity.MainActivity.java
fr.esiea.mobile.lostpets.activity.MapsActivity.java
fr.esiea.mobile.lostpets.activity.PetActivity.java
fr.esiea.mobile.lostpets.activity.PetMarkerActivity.java
fr.esiea.mobile.lostpets.activity.TakePictureActivity.java
fr.esiea.mobile.lostpets.adapter.PetAdapter.java
fr.esiea.mobile.lostpets.dao.UserDataSource.java
fr.esiea.mobile.lostpets.dao.WebServiceDAO.java
fr.esiea.mobile.lostpets.fragment.PetFragment.java
fr.esiea.mobile.lostpets.fragment.PetListFragment.java
fr.esiea.mobile.lostpets.model.Pet.java
fr.esiea.mobile.lostpets.model.Pets.java
fr.esiea.mobile.lostpets.model.User.java
fr.esiea.mobile.lostpets.sql.MySQLiteHelper.java
fr.esiea.mobile.lostpets.util.PictureFileManager.java