// Path: multipleimageselect/src/main/java/com/darsh/multipleimageselect/adapters/CustomImageSelectAdapter.java
// public class CustomImageSelectAdapter extends CustomGenericAdapter<Image> {
//     public CustomImageSelectAdapter(Context context, ArrayList<Image> images) {
//         super(context, images);
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
//         ViewHolder viewHolder;
// 
//         if (convertView == null) {
//             convertView = layoutInflater.inflate(R.layout.grid_view_item_image_select, null);
// 
//             viewHolder = new ViewHolder();
//             viewHolder.imageView = convertView.findViewById(R.id.image_view_image_select);
//             viewHolder.view = convertView.findViewById(R.id.view_alpha);
// 
//             convertView.setTag(viewHolder);
// 
//         } else {
//             viewHolder = (ViewHolder) convertView.getTag();
//         }
// 
//         viewHolder.imageView.getLayoutParams().width = size;
//         viewHolder.imageView.getLayoutParams().height = size;
// 
//         viewHolder.view.getLayoutParams().width = size;
//         viewHolder.view.getLayoutParams().height = size;
// 
//         if (arrayList.get(position).isSelected) {
//             viewHolder.view.setAlpha(0.5f);
//             ((FrameLayout) convertView).setForeground(context.getResources().getDrawable(R.drawable.ic_done_white));
// 
//         } else {
//             viewHolder.view.setAlpha(0.0f);
//             ((FrameLayout) convertView).setForeground(null);
//         }
// 
//         Glide.with(context)
//                 .load(arrayList.get(position).path)
//                 .into(viewHolder.imageView);
// 
//         return convertView;
//     }
// 
//     private static class ViewHolder {
//         public ImageView imageView;
//         public View view;
//     }
// }
// 
// Path: multipleimageselect/src/main/java/com/darsh/multipleimageselect/helpers/Constants.java
// public class Constants {
//     public static final int REQUEST_CODE = 2000;
// 
//     public static final int FETCH_STARTED = 2001;
//     public static final int FETCH_COMPLETED = 2002;
//     public static final int PERMISSION_GRANTED = 2003;
//     public static final int PERMISSION_DENIED = 2004;
//     public static final int ERROR = 2005;
// 
//     public static final int PERMISSION_REQUEST_READ_EXTERNAL_STORAGE = 23;
// 
//     public static final String INTENT_EXTRA_ALBUM = "album";
//     public static final String INTENT_EXTRA_IMAGES = "images";
//     public static final String INTENT_EXTRA_LIMIT = "limit";
//     public static final int DEFAULT_LIMIT = 10;
// 
//     //Maximum number of images that can be selected at a time
//     public static int limit;
// }


import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.provider.MediaStore;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.darsh.multipleimageselect.R;
import com.darsh.multipleimageselect.adapters.CustomImageSelectAdapter;
import com.darsh.multipleimageselect.helpers.Constants;
import com.darsh.multipleimageselect.models.Image;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;

                        loadImages();

                        break;
                    }

                    case Constants.PERMISSION_DENIED: {
                        showPermissionHelperUI();

                        progressBar.setVisibility(View.INVISIBLE);
                        gridView.setVisibility(View.INVISIBLE);

                        break;
                    }

                    case Constants.FETCH_STARTED: {
                        progressBar.setVisibility(View.VISIBLE);
                        gridView.setVisibility(View.INVISIBLE);

                        break;
                    }

                    case Constants.FETCH_COMPLETED: {
                        /*
                        If adapter is null, this implies that the loaded images will be shown
                        for the first time, hence send FETCH_COMPLETED message.
                        However, if adapter has been initialised, this thread was run either
                        due to the activity being restarted or content being changed.
                         */
                        if (adapter == null) {
// Path: multipleimageselect/src/main/java/com/darsh/multipleimageselect/adapters/CustomImageSelectAdapter.java
// public class CustomImageSelectAdapter extends CustomGenericAdapter<Image> {
//     public CustomImageSelectAdapter(Context context, ArrayList<Image> images) {
//         super(context, images);
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
//         ViewHolder viewHolder;
// 
//         if (convertView == null) {
//             convertView = layoutInflater.inflate(R.layout.grid_view_item_image_select, null);
// 
//             viewHolder = new ViewHolder();
//             viewHolder.imageView = convertView.findViewById(R.id.image_view_image_select);
//             viewHolder.view = convertView.findViewById(R.id.view_alpha);
// 
//             convertView.setTag(viewHolder);
// 
//         } else {
//             viewHolder = (ViewHolder) convertView.getTag();
//         }
// 
//         viewHolder.imageView.getLayoutParams().width = size;
//         viewHolder.imageView.getLayoutParams().height = size;
// 
//         viewHolder.view.getLayoutParams().width = size;
//         viewHolder.view.getLayoutParams().height = size;
// 
//         if (arrayList.get(position).isSelected) {
//             viewHolder.view.setAlpha(0.5f);
//             ((FrameLayout) convertView).setForeground(context.getResources().getDrawable(R.drawable.ic_done_white));
// 
//         } else {
//             viewHolder.view.setAlpha(0.0f);
//             ((FrameLayout) convertView).setForeground(null);
//         }
// 
//         Glide.with(context)
//                 .load(arrayList.get(position).path)
//                 .into(viewHolder.imageView);
// 
//         return convertView;
//     }
// 
//     private static class ViewHolder {
//         public ImageView imageView;
//         public View view;
//     }
// }
// 
// Path: multipleimageselect/src/main/java/com/darsh/multipleimageselect/helpers/Constants.java
// public class Constants {
//     public static final int REQUEST_CODE = 2000;
// 
//     public static final int FETCH_STARTED = 2001;
//     public static final int FETCH_COMPLETED = 2002;
//     public static final int PERMISSION_GRANTED = 2003;
//     public static final int PERMISSION_DENIED = 2004;
//     public static final int ERROR = 2005;
// 
//     public static final int PERMISSION_REQUEST_READ_EXTERNAL_STORAGE = 23;
// 
//     public static final String INTENT_EXTRA_ALBUM = "album";
//     public static final String INTENT_EXTRA_IMAGES = "images";
//     public static final String INTENT_EXTRA_LIMIT = "limit";
//     public static final int DEFAULT_LIMIT = 10;
// 
//     //Maximum number of images that can be selected at a time
//     public static int limit;
// }


// Path: multipleimageselect/src/main/java/com/darsh/multipleimageselect/activities/ImageSelectActivity.java
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.provider.MediaStore;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.darsh.multipleimageselect.R;
import com.darsh.multipleimageselect.adapters.CustomImageSelectAdapter;
import com.darsh.multipleimageselect.helpers.Constants;
import com.darsh.multipleimageselect.models.Image;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;


                        loadImages();

                        break;
                    }

                    case Constants.PERMISSION_DENIED: {
                        showPermissionHelperUI();

                        progressBar.setVisibility(View.INVISIBLE);
                        gridView.setVisibility(View.INVISIBLE);

                        break;
                    }

                    case Constants.FETCH_STARTED: {
                        progressBar.setVisibility(View.VISIBLE);
                        gridView.setVisibility(View.INVISIBLE);

                        break;
                    }

                    case Constants.FETCH_COMPLETED: {
                        /*
                        If adapter is null, this implies that the loaded images will be shown
                        for the first time, hence send FETCH_COMPLETED message.
                        However, if adapter has been initialised, this thread was run either
                        due to the activity being restarted or content being changed.
                         */
                        if (adapter == null) {
                            adapter = new CustomImageSelectAdapter(getApplicationContext(), images);