// Path: app/src/main/java/eu/codlab/amiiwrite/amiibo/AmiiboMethods.java
// public class AmiiboMethods {
//     private static byte[] ERROR = new byte[]{0};
// 
//     public static boolean isError(@Nullable byte[] check) {
//         return check == null || Arrays.equals(check, ERROR);
//     }
// 
//     @NonNull
//     public static byte[] keygen(@NonNull byte[] uuid) {
//         byte[] key = new byte[4];
//         int[] uuid_to_ints = new int[uuid.length];
// 
//         for (int i = 0; i < uuid.length; i++)
//             uuid_to_ints[i] = (0xFF & uuid[i]);
// 
//         if (uuid.length == 7) {
//             key[0] = ((byte) (0xFF & (0xAA ^ (uuid_to_ints[1] ^ uuid_to_ints[3]))));
//             key[1] = ((byte) (0xFF & (0x55 ^ (uuid_to_ints[2] ^ uuid_to_ints[4]))));
//             key[2] = ((byte) (0xFF & (0xAA ^ (uuid_to_ints[3] ^ uuid_to_ints[5]))));
//             key[3] = ((byte) (0xFF & (0x55 ^ (uuid_to_ints[4] ^ uuid_to_ints[6]))));
//             return key;
//         }
// 
//         return ERROR;
//     }
// 
//     @NonNull
//     public static byte[] amiiboIdentifier(@Nullable byte[] read_data) {
//         if (read_data == null) return ERROR;
//         return AmiiboHelper.getPage(read_data, Constants.AMIIBO_IDENTIFIER_PAGE_1, 2);
//     }
// 
//     public static int getAmiiboDrawable(@NonNull Context context,
//                                         @NonNull String amiibo_identifier) {
//         String output = String.format("icon_%s", amiibo_identifier.toLowerCase());
//         return context.getResources().getIdentifier(output, "drawable", context.getPackageName());
//     }
// }
// 
// Path: app/src/main/java/eu/codlab/amiiwrite/database/holders/AmiiboIdentifiersHolder.java
// public class AmiiboIdentifiersHolder {
//     public String identifier;
//     public String name;
//     public long count;
// 
//     public AmiiboIdentifiersHolder(@NonNull String identifier,
//                                    @NonNull String name,
//                                    long count) {
//         this.identifier = identifier;
//         this.count = count;
//         this.name = name;
//     }
// }
// 
// Path: app/src/main/java/eu/codlab/amiiwrite/ui/my_list/adapters/AmiiboListAdapter.java
// public class AmiiboListAdapter extends RecyclerView.Adapter<LoadableHolder> {
//     private final static int AMIIBO_CATEGORY = 0;
//     private final static int AMIIBO = 1;
//     private final static int AMIIBO_LOADER = 2;
// 
//     private List<Container> _containers;
//     private IAmiiboListListener _listener;
// 
// 
//     public AmiiboListAdapter(IAmiiboListListener listener) {
//         _listener = listener;
//         _containers = null;
//     }
// 
//     public AmiiboListAdapter(IAmiiboListListener listener, List<Container> container) {
//         this(listener);
//         _containers = container;
//     }
// 
//     public Container getObject(int position) {
//         return _containers.get(position);
//     }
// 
//     public IAmiiboListListener getListener() {
//         return _listener;
//     }
// 
//     @Override
//     public LoadableHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// 
//         switch (viewType) {
//             case AMIIBO_CATEGORY:
//                 return new AmiiboCategory(inflater.inflate(R.layout.fragment_my_amibo_item_with_count, parent, false));
//             case AMIIBO:
//                 return new AmiiboItem(inflater.inflate(R.layout.fragment_my_amibo_item, parent, false));
//             case AMIIBO_LOADER:
//                 return new LoadableHolder(inflater.inflate(R.layout.fragment_my_amibo_loading, parent, false));
//             default:
//         }
//         return null;
//     }
// 
//     @Override
//     public void onBindViewHolder(LoadableHolder holder, int position) {
//         holder.onBindViewHolder(this, position);
//     }
// 
//     @Override
//     public int getItemViewType(int position) {
//         if (_containers == null) return AMIIBO_LOADER;
//         if (_containers.get(position) instanceof AmiiboContainer) return AMIIBO;
//         return AMIIBO_CATEGORY;
//     }
// 
//     @Override
//     public int getItemCount() {
//         if (_containers == null) return 1;
//         return _containers.size();
//     }
// }


import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import eu.codlab.amiiwrite.R;
import eu.codlab.amiiwrite.amiibo.AmiiboMethods;
import eu.codlab.amiiwrite.database.holders.AmiiboIdentifiersHolder;
import eu.codlab.amiiwrite.ui.my_list.adapters.AmiiboListAdapter;
    private String TAG = AmiiboCategory.class.getSimpleName();

    @Override
    public void onBindViewHolder(final AmiiboListAdapter parent, int position) {
        _container = parent.getObject(position);

        updateHeaderFooter(parent, position);

        name.setText(_container.name);
        if (count != null) count.setText(Long.toString(_container.data));

        int drawable = AmiiboMethods.getAmiiboDrawable(itemView.getContext(), _container.identifier);
        if (drawable != 0) {
            icon.setImageResource(drawable);
        }

        _clickable.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (parent.getListener() != null)
                    parent.getListener().onClick(_container);
            }
        });
    }

    public void onBindViewHolder(AmiiboIdentifiersHolder parent,
                                 View.OnClickListener listener) {
        name.setText(parent.name);
        if (count != null) count.setText(Long.toString(parent.count));

// Path: app/src/main/java/eu/codlab/amiiwrite/amiibo/AmiiboMethods.java
// public class AmiiboMethods {
//     private static byte[] ERROR = new byte[]{0};
// 
//     public static boolean isError(@Nullable byte[] check) {
//         return check == null || Arrays.equals(check, ERROR);
//     }
// 
//     @NonNull
//     public static byte[] keygen(@NonNull byte[] uuid) {
//         byte[] key = new byte[4];
//         int[] uuid_to_ints = new int[uuid.length];
// 
//         for (int i = 0; i < uuid.length; i++)
//             uuid_to_ints[i] = (0xFF & uuid[i]);
// 
//         if (uuid.length == 7) {
//             key[0] = ((byte) (0xFF & (0xAA ^ (uuid_to_ints[1] ^ uuid_to_ints[3]))));
//             key[1] = ((byte) (0xFF & (0x55 ^ (uuid_to_ints[2] ^ uuid_to_ints[4]))));
//             key[2] = ((byte) (0xFF & (0xAA ^ (uuid_to_ints[3] ^ uuid_to_ints[5]))));
//             key[3] = ((byte) (0xFF & (0x55 ^ (uuid_to_ints[4] ^ uuid_to_ints[6]))));
//             return key;
//         }
// 
//         return ERROR;
//     }
// 
//     @NonNull
//     public static byte[] amiiboIdentifier(@Nullable byte[] read_data) {
//         if (read_data == null) return ERROR;
//         return AmiiboHelper.getPage(read_data, Constants.AMIIBO_IDENTIFIER_PAGE_1, 2);
//     }
// 
//     public static int getAmiiboDrawable(@NonNull Context context,
//                                         @NonNull String amiibo_identifier) {
//         String output = String.format("icon_%s", amiibo_identifier.toLowerCase());
//         return context.getResources().getIdentifier(output, "drawable", context.getPackageName());
//     }
// }
// 
// Path: app/src/main/java/eu/codlab/amiiwrite/database/holders/AmiiboIdentifiersHolder.java
// public class AmiiboIdentifiersHolder {
//     public String identifier;
//     public String name;
//     public long count;
// 
//     public AmiiboIdentifiersHolder(@NonNull String identifier,
//                                    @NonNull String name,
//                                    long count) {
//         this.identifier = identifier;
//         this.count = count;
//         this.name = name;
//     }
// }
// 
// Path: app/src/main/java/eu/codlab/amiiwrite/ui/my_list/adapters/AmiiboListAdapter.java
// public class AmiiboListAdapter extends RecyclerView.Adapter<LoadableHolder> {
//     private final static int AMIIBO_CATEGORY = 0;
//     private final static int AMIIBO = 1;
//     private final static int AMIIBO_LOADER = 2;
// 
//     private List<Container> _containers;
//     private IAmiiboListListener _listener;
// 
// 
//     public AmiiboListAdapter(IAmiiboListListener listener) {
//         _listener = listener;
//         _containers = null;
//     }
// 
//     public AmiiboListAdapter(IAmiiboListListener listener, List<Container> container) {
//         this(listener);
//         _containers = container;
//     }
// 
//     public Container getObject(int position) {
//         return _containers.get(position);
//     }
// 
//     public IAmiiboListListener getListener() {
//         return _listener;
//     }
// 
//     @Override
//     public LoadableHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         LayoutInflater inflater = LayoutInflater.from(parent.getContext());
// 
//         switch (viewType) {
//             case AMIIBO_CATEGORY:
//                 return new AmiiboCategory(inflater.inflate(R.layout.fragment_my_amibo_item_with_count, parent, false));
//             case AMIIBO:
//                 return new AmiiboItem(inflater.inflate(R.layout.fragment_my_amibo_item, parent, false));
//             case AMIIBO_LOADER:
//                 return new LoadableHolder(inflater.inflate(R.layout.fragment_my_amibo_loading, parent, false));
//             default:
//         }
//         return null;
//     }
// 
//     @Override
//     public void onBindViewHolder(LoadableHolder holder, int position) {
//         holder.onBindViewHolder(this, position);
//     }
// 
//     @Override
//     public int getItemViewType(int position) {
//         if (_containers == null) return AMIIBO_LOADER;
//         if (_containers.get(position) instanceof AmiiboContainer) return AMIIBO;
//         return AMIIBO_CATEGORY;
//     }
// 
//     @Override
//     public int getItemCount() {
//         if (_containers == null) return 1;
//         return _containers.size();
//     }
// }


// Path: app/src/main/java/eu/codlab/amiiwrite/ui/my_list/adapters/internal/AmiiboCategory.java
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import eu.codlab.amiiwrite.R;
import eu.codlab.amiiwrite.amiibo.AmiiboMethods;
import eu.codlab.amiiwrite.database.holders.AmiiboIdentifiersHolder;
import eu.codlab.amiiwrite.ui.my_list.adapters.AmiiboListAdapter;

    private String TAG = AmiiboCategory.class.getSimpleName();

    @Override
    public void onBindViewHolder(final AmiiboListAdapter parent, int position) {
        _container = parent.getObject(position);

        updateHeaderFooter(parent, position);

        name.setText(_container.name);
        if (count != null) count.setText(Long.toString(_container.data));

        int drawable = AmiiboMethods.getAmiiboDrawable(itemView.getContext(), _container.identifier);
        if (drawable != 0) {
            icon.setImageResource(drawable);
        }

        _clickable.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (parent.getListener() != null)
                    parent.getListener().onClick(_container);
            }
        });
    }

    public void onBindViewHolder(AmiiboIdentifiersHolder parent,
                                 View.OnClickListener listener) {
        name.setText(parent.name);
        if (count != null) count.setText(Long.toString(parent.count));

        int drawable = AmiiboMethods.getAmiiboDrawable(itemView.getContext(), parent.identifier);