// Path: app/src/main/java/com/bruce/demo/studydata/game/gamepuzzle/util/ScreenUtil.java
// public class ScreenUtil {
// 
//     /**
//      * 获取屏幕相关参数
//      *
//      * @param context context
//      * @return DisplayMetrics 屏幕宽高
//      */
//     public static DisplayMetrics getScreenSize(Context context) {
//         DisplayMetrics metrics = new DisplayMetrics();
//         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
//         Display display = wm.getDefaultDisplay();
//         display.getMetrics(metrics);
//         return metrics;
//     }
// 
//     /**
//      * 获取屏幕density
//      *
//      * @param context context
//      * @return density 屏幕density
//      */
//     public static float getDeviceDensity(Context context) {
//         DisplayMetrics metrics = new DisplayMetrics();
//         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
//         wm.getDefaultDisplay().getMetrics(metrics);
//         return metrics.density;
//     }
// }


import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.bruce.demo.studydata.game.gamepuzzle.util.ScreenUtil;
import java.util.List;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
/*
 * BruceHurrican
 * Copyright (c) 2016.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 *    This document is Bruce's individual learning the android demo, wherein the use of the code from the Internet, only to use as a learning exchanges.
 *   And where any person can download and use, but not for commercial purposes.
 *   Author does not assume the resulting corresponding disputes.
 *   If you have good suggestions for the code, you can contact BurrceHurrican@foxmail.com
 *   本文件为Bruce's个人学习android的demo, 其中所用到的代码来源于互联网，仅作为学习交流使用。
 *   任和何人可以下载并使用, 但是不能用于商业用途。
 *   作者不承担由此带来的相应纠纷。
 *   如果对本代码有好的建议，可以联系BurrceHurrican@foxmail.com
 */

package com.bruce.demo.studydata.game.gamepuzzle.adapter;




/**
 * 程序主界面数据适配器
 *
 * @author xys
 */
public class GridPicListAdapter extends BaseAdapter {

    // 映射List
    private List<Bitmap> picList;
    private Context context;

    public GridPicListAdapter(Context context, List<Bitmap> picList) {
        this.context = context;
        this.picList = picList;
    }

    @Override
    public int getCount() {
        return picList.size();
    }

    @Override
    public Object getItem(int position) {
        return picList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        ImageView iv_pic_item = null;
// Path: app/src/main/java/com/bruce/demo/studydata/game/gamepuzzle/util/ScreenUtil.java
// public class ScreenUtil {
// 
//     /**
//      * 获取屏幕相关参数
//      *
//      * @param context context
//      * @return DisplayMetrics 屏幕宽高
//      */
//     public static DisplayMetrics getScreenSize(Context context) {
//         DisplayMetrics metrics = new DisplayMetrics();
//         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
//         Display display = wm.getDefaultDisplay();
//         display.getMetrics(metrics);
//         return metrics;
//     }
// 
//     /**
//      * 获取屏幕density
//      *
//      * @param context context
//      * @return density 屏幕density
//      */
//     public static float getDeviceDensity(Context context) {
//         DisplayMetrics metrics = new DisplayMetrics();
//         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
//         wm.getDefaultDisplay().getMetrics(metrics);
//         return metrics.density;
//     }
// }


// Path: app/src/main/java/com/bruce/demo/studydata/game/gamepuzzle/adapter/GridPicListAdapter.java
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.bruce.demo.studydata.game.gamepuzzle.util.ScreenUtil;
import java.util.List;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;

/*
 * BruceHurrican
 * Copyright (c) 2016.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 *    This document is Bruce's individual learning the android demo, wherein the use of the code from the Internet, only to use as a learning exchanges.
 *   And where any person can download and use, but not for commercial purposes.
 *   Author does not assume the resulting corresponding disputes.
 *   If you have good suggestions for the code, you can contact BurrceHurrican@foxmail.com
 *   本文件为Bruce's个人学习android的demo, 其中所用到的代码来源于互联网，仅作为学习交流使用。
 *   任和何人可以下载并使用, 但是不能用于商业用途。
 *   作者不承担由此带来的相应纠纷。
 *   如果对本代码有好的建议，可以联系BurrceHurrican@foxmail.com
 */

package com.bruce.demo.studydata.game.gamepuzzle.adapter;




/**
 * 程序主界面数据适配器
 *
 * @author xys
 */
public class GridPicListAdapter extends BaseAdapter {

    // 映射List
    private List<Bitmap> picList;
    private Context context;

    public GridPicListAdapter(Context context, List<Bitmap> picList) {
        this.context = context;
        this.picList = picList;
    }

    @Override
    public int getCount() {
        return picList.size();
    }

    @Override
    public Object getItem(int position) {
        return picList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        ImageView iv_pic_item = null;
        int density = (int) ScreenUtil.getDeviceDensity(context);