Android Open Source - androidsoft-kids-memory Tile List






From Project

Back to project page androidsoft-kids-memory.

License

The source code is released under:

GNU General Public License

If you think the Android project androidsoft-kids-memory 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

/* Copyright (c) 2010-2014 Pierre LEVY androidsoft.org
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.//from w ww  . ja v a2 s.  com
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.androidsoft.games.memory.kids.model;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.androidsoft.games.memory.kids.ui.MainActivity;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author pierre
 */
public class TileList extends ArrayList<Tile>
{

    /**
     * Constructor
     */
    TileList()
    {
    }

    /**
     * Constructeur
     * @param serialized A serialized list
     */
    TileList(String serialized)
    {
        try
        {
            JSONArray array = new JSONArray(serialized);
            for (int i = 0; i < array.length(); i++)
            {
                JSONObject object = array.getJSONObject(i);
                Tile t = new Tile(object);
                add(t);
            }
        } catch (JSONException ex)
        {
            Logger.getLogger(MainActivity.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /**
     * Serialize the List
     * @return The list as a String
     */
    String serialize()
    {
        JSONArray array = new JSONArray();
        for (Tile t : this)
        {
            array.put(t.json());
        }
        return array.toString();
    }

    ArrayList<Tile> getSelected()
    {
        ArrayList<Tile> list = new ArrayList<Tile>();
        for (Tile t : this)
        {
            if ( t.mSelected && !t.mFound )
            {
                list.add( t );
            }
        }
        return list;
    }
}




Java Source Code List

org.androidsoft.games.memory.kids.Constants.java
org.androidsoft.games.memory.kids.PreferencesService.java
org.androidsoft.games.memory.kids.Rotate3dAnimation.java
org.androidsoft.games.memory.kids.model.Memory.java
org.androidsoft.games.memory.kids.model.TileList.java
org.androidsoft.games.memory.kids.model.Tile.java
org.androidsoft.games.memory.kids.ui.AbstractMainActivity.java
org.androidsoft.games.memory.kids.ui.CreditsActivity.java
org.androidsoft.games.memory.kids.ui.ImageAdapter.java
org.androidsoft.games.memory.kids.ui.MainActivity.java
org.androidsoft.games.memory.kids.ui.MemoryGridView.java
org.androidsoft.games.memory.kids.ui.PreferencesActivity.java