Android Open Source - androidsoft-kids-memory Memory Grid View






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 w  w.ja v a2s . co m*/
 *
 * 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.ui;

import org.androidsoft.games.memory.kids.model.Memory;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

/**
 *
 * @author pierre
 */
public class MemoryGridView extends GridView
{
    private static final int MARGIN = 15;

    private Memory mMemory;
    private Context mContext;

    public MemoryGridView(Context context)
    {
        super(context);

        mContext = context;

        setOnItemClickListener(new OnItemClickListener()
        {

            public void onItemClick(AdapterView<?> parent, View v, int position, long id)
            {
                mMemory.onPosition( position );
            }
        });

    }

    public MemoryGridView (Context context, AttributeSet attrs)
    {
        super( context , attrs );
        mContext = context;
        setOnItemClickListener(new OnItemClickListener()
        {

            public void onItemClick(AdapterView<?> parent, View v, int position, long id)
            {
                mMemory.onPosition( position );
            }
        });
    }

    public MemoryGridView (Context context, AttributeSet attrs, int defStyle)
    {
        super( context , attrs , defStyle );
        mContext = context;
        setOnItemClickListener(new OnItemClickListener()
        {

            public void onItemClick(AdapterView<?> parent, View v, int position, long id)
            {
                mMemory.onPosition( position );
            }
        });
    }


    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh)
    {
        super.onSizeChanged(w, h, oldw, oldh);
        update( );
    }

    void update()
    {
        setAdapter(new ImageAdapter( mContext, getWidth(), getHeight(), MARGIN , mMemory));
    }


    public void setMemory( Memory memory )
    {
        mMemory = memory;
    }

}




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