title: Glide not working with my custom gallery
body: <p>I have a gallery, but its using too much memory.</p>
  
  <p>I wanted to implement Glide, but it wont work.</p>
  
  <p>My public ImageAdapter class:</p>
  
  <pre><code>public class ImageAdapter extends BaseAdapter {
      private LayoutInflater mInflater;
      private Activity context;
  
      public ImageAdapter() {
          mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
      }
  
      public int getCount() { return count; }
  
      public Object getItem(int position) {
          return position;
      }
  
      public long getItemId(int position) {
          return position;
      }
  
  
      public View getView(int position, View convertView, ViewGroup parent) {
          final ViewHolder holder;
          if (convertView == null) {
              holder = new ViewHolder();
              convertView = mInflater.inflate(
                      R.layout.galleryitem, null);
              holder.imageview = (ImageView) convertView.findViewById(R.id.thumbImage);
              holder.checkbox = (CheckBox) convertView.findViewById(R.id.itemCheckBox);
              holder.checkbox.setId(position);
              holder.imageview.setId(position);
              convertView.setTag(holder);
          } else {
              holder = (ViewHolder) convertView.getTag();
          }
  
  
          View.OnClickListener clickListener = new View.OnClickListener() {
  
  
              public void onClick(View v) {
                  int id = holder.checkbox.getId();
  
                  if (thumbnailsselection[id]) {
                      holder.checkbox.setChecked(false);
                      thumbnailsselection[id] = false;
                  } else {
                      holder.checkbox.setChecked(true);
                      thumbnailsselection[id] = true;
                  }
              }
  
          };
  
          holder.checkbox.setOnClickListener(clickListener);
          holder.imageview.setOnClickListener(clickListener);
  
          holder.imageview.setOnLongClickListener(new View.OnLongClickListener() {
  
              public boolean onLongClick(View v) {
                  // TODO Auto-generated method stub
                  int id = v.getId();
                  Intent intent = new Intent();
                  intent.setAction(Intent.ACTION_VIEW);
                  intent.setDataAndType(Uri.parse("file://" + arrPath[id]), "image/*");
                  startActivity(intent);
                  return true;
              }
  
          });
          holder.imageview.setImageBitmap(thumbnails[position]);
          holder.checkbox.setChecked(thumbnailsselection[position]);
          holder.id = position;
  
  
          Glide.with(context).load(holder.imageview)
                  .placeholder(R.drawable.logo).centerCrop()
                  .into((ImageView) convertView);
  
          return convertView;
      }
  }
  
  class ViewHolder {
      ImageView imageview;
      CheckBox checkbox;
      int id;
  }
  </code></pre>
  
  <p>oncreate method:</p>
  
  <pre><code> GridView imagegrid = (GridView) findViewById(R.id.PhoneImageGrid);
   imagegrid.setAdapter(new ImageAdapter());
  </code></pre>
  
  <p>Logcat:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.app.Activity.isDestroyed()' on a null object reference
  at com.bumptech.glide.manager.RequestManagerRetriever.assertNotDestroyed(RequestManagerRetriever.java:133)
  at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:125)
  at com.bumptech.glide.Glide.with(Glide.java:641)
  at com.example.example.photonet.Gallery$ImageAdapter.getView(Gallery.java:170)
  </code></pre>
  
  <p>I had to cast the convertView into Imageview to AndroidStudio accept it.</p>
  
  <p>Without the Glide part it works well. So the problem is in that part.</p>