// Path: app/src/main/java/org/mars3142/android/toaster/data/PackageEntry.java
// public class PackageEntry {
// 
//     private ApplicationInfo mInfo;
// 
//     private File mApkFile;
//     private String mLabel;
//     private Drawable mIcon;
//     private Boolean mMounted;
// 
//     public PackageEntry(ApplicationInfo applicationInfo) {
//         mInfo = applicationInfo;
//         mApkFile = new File(mInfo.sourceDir);
//     }
// 
//     public String getPackageName() {
//         if (mInfo != null) {
//             return mInfo.packageName;
//         }
// 
//         return null;
//     }
// 
//     public String getLabel(Context context) {
//         if (mLabel == null || !mMounted) {
//             if (!mApkFile.exists()) {
//                 mMounted = false;
//                 mLabel = mInfo.packageName;
//             } else {
//                 mMounted = true;
//                 CharSequence label = mInfo.loadLabel(context.getPackageManager());
//                 mLabel = label != null ? label.toString() : mInfo.packageName;
//             }
//         }
// 
//         return mLabel;
//     }
// 
//     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
//     public Drawable getIcon(Context context) {
//         if (mIcon == null) {
//             if (mApkFile.exists()) {
//                 mIcon = mInfo.loadIcon(context.getPackageManager());
//                 return mIcon;
//             } else {
//                 mMounted = false;
//             }
//         } else if (!mMounted) {
//             if (mApkFile.exists()) {
//                 mMounted = true;
//                 mIcon = mInfo.loadIcon(context.getPackageManager());
//                 return mIcon;
//             }
//         } else {
//             return mIcon;
//         }
// 
//         Drawable drawable;
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//             drawable = context.getDrawable(android.R.drawable.sym_def_app_icon);
//         } else {
//             drawable = context.getResources().getDrawable(android.R.drawable.sym_def_app_icon);
//         }
//         return drawable;
//     }
// 
//     @Override
//     public String toString() {
//         return mLabel;
//     }
// }
// 
// Path: app/src/main/java/org/mars3142/android/toaster/viewholder/NavDrawerRecyclerViewHolder.java
// public class NavDrawerRecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
// 
//     private OnItemClickListener mOnItemClickListener;
//     public ImageView mPackageIcon;
//     public TextView mAppName;
//     public String mPackageName;
// 
//     public NavDrawerRecyclerViewHolder(View itemView, OnItemClickListener onItemClickListener) {
//         super(itemView);
// 
//         mOnItemClickListener = onItemClickListener;
//         mAppName = (TextView) itemView.findViewById(R.id.app_name);
//         mPackageIcon = (ImageView) itemView.findViewById(R.id.package_icon);
//         itemView.setOnClickListener(this);
//     }
// 
//     @Override
//     public void onClick(View view) {
//         if (mOnItemClickListener != null) {
//             mOnItemClickListener.onItemClick(mPackageName);
//         }
//     }
// 
//     public interface OnItemClickListener {
//         void onItemClick(String packageName);
//     }
// }


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.mars3142.android.toaster.R;
import org.mars3142.android.toaster.data.PackageEntry;
import org.mars3142.android.toaster.viewholder.NavDrawerRecyclerViewHolder;
/*
 * This file is part of Toaster
 *
 * Copyright (c) 2014, 2017 Peter Siegmund
 *
 * 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.
 *
 * 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.mars3142.android.toaster.adapter;



/**
 * @author mars3142
 */
public class PackageRecyclerAdapter
        extends RecyclerView.Adapter<NavDrawerRecyclerViewHolder>
        implements NavDrawerRecyclerViewHolder.OnItemClickListener {

    private Context mContext;
// Path: app/src/main/java/org/mars3142/android/toaster/data/PackageEntry.java
// public class PackageEntry {
// 
//     private ApplicationInfo mInfo;
// 
//     private File mApkFile;
//     private String mLabel;
//     private Drawable mIcon;
//     private Boolean mMounted;
// 
//     public PackageEntry(ApplicationInfo applicationInfo) {
//         mInfo = applicationInfo;
//         mApkFile = new File(mInfo.sourceDir);
//     }
// 
//     public String getPackageName() {
//         if (mInfo != null) {
//             return mInfo.packageName;
//         }
// 
//         return null;
//     }
// 
//     public String getLabel(Context context) {
//         if (mLabel == null || !mMounted) {
//             if (!mApkFile.exists()) {
//                 mMounted = false;
//                 mLabel = mInfo.packageName;
//             } else {
//                 mMounted = true;
//                 CharSequence label = mInfo.loadLabel(context.getPackageManager());
//                 mLabel = label != null ? label.toString() : mInfo.packageName;
//             }
//         }
// 
//         return mLabel;
//     }
// 
//     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
//     public Drawable getIcon(Context context) {
//         if (mIcon == null) {
//             if (mApkFile.exists()) {
//                 mIcon = mInfo.loadIcon(context.getPackageManager());
//                 return mIcon;
//             } else {
//                 mMounted = false;
//             }
//         } else if (!mMounted) {
//             if (mApkFile.exists()) {
//                 mMounted = true;
//                 mIcon = mInfo.loadIcon(context.getPackageManager());
//                 return mIcon;
//             }
//         } else {
//             return mIcon;
//         }
// 
//         Drawable drawable;
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//             drawable = context.getDrawable(android.R.drawable.sym_def_app_icon);
//         } else {
//             drawable = context.getResources().getDrawable(android.R.drawable.sym_def_app_icon);
//         }
//         return drawable;
//     }
// 
//     @Override
//     public String toString() {
//         return mLabel;
//     }
// }
// 
// Path: app/src/main/java/org/mars3142/android/toaster/viewholder/NavDrawerRecyclerViewHolder.java
// public class NavDrawerRecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
// 
//     private OnItemClickListener mOnItemClickListener;
//     public ImageView mPackageIcon;
//     public TextView mAppName;
//     public String mPackageName;
// 
//     public NavDrawerRecyclerViewHolder(View itemView, OnItemClickListener onItemClickListener) {
//         super(itemView);
// 
//         mOnItemClickListener = onItemClickListener;
//         mAppName = (TextView) itemView.findViewById(R.id.app_name);
//         mPackageIcon = (ImageView) itemView.findViewById(R.id.package_icon);
//         itemView.setOnClickListener(this);
//     }
// 
//     @Override
//     public void onClick(View view) {
//         if (mOnItemClickListener != null) {
//             mOnItemClickListener.onItemClick(mPackageName);
//         }
//     }
// 
//     public interface OnItemClickListener {
//         void onItemClick(String packageName);
//     }
// }


// Path: app/src/main/java/org/mars3142/android/toaster/adapter/PackageRecyclerAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.mars3142.android.toaster.R;
import org.mars3142.android.toaster.data.PackageEntry;
import org.mars3142.android.toaster.viewholder.NavDrawerRecyclerViewHolder;

/*
 * This file is part of Toaster
 *
 * Copyright (c) 2014, 2017 Peter Siegmund
 *
 * 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.
 *
 * 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.mars3142.android.toaster.adapter;



/**
 * @author mars3142
 */
public class PackageRecyclerAdapter
        extends RecyclerView.Adapter<NavDrawerRecyclerViewHolder>
        implements NavDrawerRecyclerViewHolder.OnItemClickListener {

    private Context mContext;
    private PackageEntry[] mPackages;