// Path: app/src/main/java/org/secuso/privacyfriendlymemory/common/MemoGameLayoutProvider.java
// public class MemoGameLayoutProvider {
// 
//     private final static int MARGIN_LEFT = 35;               // in pixel
//     private final static int MARGIN_RIGHT = 35;            // in pixel
//     private final Context context;
//     private final MemoGame memory;
//     private final MemoGameDifficulty memoryDifficulty;
//     private static Map<MemoGameDifficulty, Integer> columnCountMapping = new HashMap<>();
// 
//     static {
//         columnCountMapping.put(MemoGameDifficulty.Easy, 4);
//         columnCountMapping.put(MemoGameDifficulty.Moderate, 6);
//         columnCountMapping.put(MemoGameDifficulty.Hard, 8);
//     }
// 
//     public MemoGameLayoutProvider(Context context, MemoGame memory) {
//         this.context = context;
//         this.memory = memory;
//         this.memoryDifficulty = memory.getDifficulty();
//     }
// 
//     public int getColumnCount() {
//         return columnCountMapping.get(memoryDifficulty);
//     }
// 
//     public int getDeckSize() {
//         return memoryDifficulty.getDeckSize();
//     }
// 
//     public int getImageResID(int position) {
//         return memory.getImageResID(position);
//     }
// 
//     public Uri getImageUri(int position) {
//         return memory.getImageUri(position);
//     }
// 
//     public int getCardSizePixel() {
//         // calculate the card size in pixel based on the screen width
//         // [remember: card = square, so width=height]
//         int orientation=context.getResources().getConfiguration().orientation;
//         if(orientation== Configuration.ORIENTATION_PORTRAIT){
//             int displayWidth = context.getResources().getDisplayMetrics().widthPixels;
//             int cardSize = (displayWidth - getMarginLeft() - getMarginRight()) / getColumnCount();
//             return cardSize;
//         }
//         else{
//             int displayHeight = context.getResources().getDisplayMetrics().heightPixels;
//             int displayHeightWithoutStats = (int)(displayHeight*(47.5f/100.f));
//             int cardSize = displayHeightWithoutStats/getColumnCount();
//             return cardSize;
//         }
//     }
// 
//     public int getMargin() {
//         int displayHeight = context.getResources().getDisplayMetrics().heightPixels;
//         int cardsHeight = getColumnCount() * getCardSizePixel();
//         int heightLeft = displayHeight - cardsHeight;
//         return heightLeft / 2;
//     }
// 
// 
//     public int getMarginLeft() {
//         int orientation=context.getResources().getConfiguration().orientation;
//         if(orientation== Configuration.ORIENTATION_PORTRAIT){
//             return MARGIN_LEFT;
//         }else{
//             return calculateLandscapeSideMargin();
//         }
//     }
// 
//     public int getMarginRight() {
//         int orientation=context.getResources().getConfiguration().orientation;
//         if(orientation== Configuration.ORIENTATION_PORTRAIT){
//             return MARGIN_RIGHT;
//         }else{
//             return calculateLandscapeSideMargin();
//         }
//     }
// 
//     private int calculateLandscapeSideMargin(){
//         int cardSpaceWidth = getColumnCount()*getCardSizePixel();
//         int displayWidth = context.getResources().getDisplayMetrics().widthPixels;
//         int spaceLeft = displayWidth-cardSpaceWidth;
//         return spaceLeft/2;
//     }
// 
//     public boolean isCustomDeck() {
//         return memory.isCustomDesign();
//     }
// 
// }


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import org.secuso.privacyfriendlymemory.common.MemoGameLayoutProvider;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
package org.secuso.privacyfriendlymemory.ui;




/**
 * Created by Hannes on 21.05.2016.
 */
public class MemoImageAdapter extends BaseAdapter {

    private final Context context;
    private final MemoGameLayoutProvider layoutProvider;
    private Map<Integer, Bitmap> positionBitmapCache = new HashMap<>();
    private final Uri notFoundUri;
    private final Bitmap notFoundBitmap;

// Path: app/src/main/java/org/secuso/privacyfriendlymemory/common/MemoGameLayoutProvider.java
// public class MemoGameLayoutProvider {
// 
//     private final static int MARGIN_LEFT = 35;               // in pixel
//     private final static int MARGIN_RIGHT = 35;            // in pixel
//     private final Context context;
//     private final MemoGame memory;
//     private final MemoGameDifficulty memoryDifficulty;
//     private static Map<MemoGameDifficulty, Integer> columnCountMapping = new HashMap<>();
// 
//     static {
//         columnCountMapping.put(MemoGameDifficulty.Easy, 4);
//         columnCountMapping.put(MemoGameDifficulty.Moderate, 6);
//         columnCountMapping.put(MemoGameDifficulty.Hard, 8);
//     }
// 
//     public MemoGameLayoutProvider(Context context, MemoGame memory) {
//         this.context = context;
//         this.memory = memory;
//         this.memoryDifficulty = memory.getDifficulty();
//     }
// 
//     public int getColumnCount() {
//         return columnCountMapping.get(memoryDifficulty);
//     }
// 
//     public int getDeckSize() {
//         return memoryDifficulty.getDeckSize();
//     }
// 
//     public int getImageResID(int position) {
//         return memory.getImageResID(position);
//     }
// 
//     public Uri getImageUri(int position) {
//         return memory.getImageUri(position);
//     }
// 
//     public int getCardSizePixel() {
//         // calculate the card size in pixel based on the screen width
//         // [remember: card = square, so width=height]
//         int orientation=context.getResources().getConfiguration().orientation;
//         if(orientation== Configuration.ORIENTATION_PORTRAIT){
//             int displayWidth = context.getResources().getDisplayMetrics().widthPixels;
//             int cardSize = (displayWidth - getMarginLeft() - getMarginRight()) / getColumnCount();
//             return cardSize;
//         }
//         else{
//             int displayHeight = context.getResources().getDisplayMetrics().heightPixels;
//             int displayHeightWithoutStats = (int)(displayHeight*(47.5f/100.f));
//             int cardSize = displayHeightWithoutStats/getColumnCount();
//             return cardSize;
//         }
//     }
// 
//     public int getMargin() {
//         int displayHeight = context.getResources().getDisplayMetrics().heightPixels;
//         int cardsHeight = getColumnCount() * getCardSizePixel();
//         int heightLeft = displayHeight - cardsHeight;
//         return heightLeft / 2;
//     }
// 
// 
//     public int getMarginLeft() {
//         int orientation=context.getResources().getConfiguration().orientation;
//         if(orientation== Configuration.ORIENTATION_PORTRAIT){
//             return MARGIN_LEFT;
//         }else{
//             return calculateLandscapeSideMargin();
//         }
//     }
// 
//     public int getMarginRight() {
//         int orientation=context.getResources().getConfiguration().orientation;
//         if(orientation== Configuration.ORIENTATION_PORTRAIT){
//             return MARGIN_RIGHT;
//         }else{
//             return calculateLandscapeSideMargin();
//         }
//     }
// 
//     private int calculateLandscapeSideMargin(){
//         int cardSpaceWidth = getColumnCount()*getCardSizePixel();
//         int displayWidth = context.getResources().getDisplayMetrics().widthPixels;
//         int spaceLeft = displayWidth-cardSpaceWidth;
//         return spaceLeft/2;
//     }
// 
//     public boolean isCustomDeck() {
//         return memory.isCustomDesign();
//     }
// 
// }


// Path: app/src/main/java/org/secuso/privacyfriendlymemory/ui/MemoImageAdapter.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import org.secuso.privacyfriendlymemory.common.MemoGameLayoutProvider;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

package org.secuso.privacyfriendlymemory.ui;




/**
 * Created by Hannes on 21.05.2016.
 */
public class MemoImageAdapter extends BaseAdapter {

    private final Context context;
    private final MemoGameLayoutProvider layoutProvider;
    private Map<Integer, Bitmap> positionBitmapCache = new HashMap<>();
    private final Uri notFoundUri;
    private final Bitmap notFoundBitmap;

    public MemoImageAdapter(Context context, MemoGameLayoutProvider layoutProvider) {