title: Display ImagePreview Selected Data from Gallery
body: <p>Selecting the image via the ImageButton then display to image preview in the same position, I can select the images from the gallery but the problem is when I want to display some preview on the same position of ImageButton, but the image preview is from ArrayList items, I can pass the image in one if I will do in the activity_the_grid check the sample image to check the layout and giving me [ java.lang.RuntimeException: Failure delivering result ResultInfo] error
  <a href="https://i.stack.imgur.com/Ftf6g.png" rel="nofollow noreferrer">Select Image </a></p>
  <p><strong>MainActivity</strong></p>
  <pre><code> @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_the_grid);
          dgridPreviewImage = findViewById(R.id.the_grid_image_preview); //layout_item
          mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
          SectionedExpandableLayoutHelper sectionedExpandableLayoutHelper = new SectionedExpandableLayoutHelper(this,
                  mRecyclerView, this, 3);
          //random data
          ArrayList&lt;Item&gt; arrayList = new ArrayList&lt;&gt;();
          arrayList.add(new Item(0));
          arrayList.add(new Item( 1));
          arrayList.add(new Item( 2));
          arrayList.add(new Item( 3));
          arrayList.add(new Item( 4));
          arrayList.add(new Item( 5));
          sectionedExpandableLayoutHelper.notifyDataSetChanged();
      }
      @Override
      public void itemClicked(Item item) {
          openMediaSelectDialog();
      }
  
      private void handleImageSelect(@Nullable Intent intent) {
          if (saveContentLocally(intent)) {
              reset();
              try {
                  Bitmap bitmap = BitmapFactory.decodeStream(new FileInputStream(mSnapFile));
                  dgridPreviewImage.setImageBitmap(bitmap);
  
                  mSnapState = TheGrid.SnapState.IMAGE;
              } catch (FileNotFoundException e) {
                  throw new IllegalStateException(&quot;Saved the image file, but it doesn't exist!&quot;);
              }
          }
      }
  </code></pre>
  <p><strong>Item</strong></p>
  <pre><code>public class Item {
  private final int id;
  public Item( int id) {
      this.id = id;
  }
  public int getId() {
      return id;
  }
  </code></pre>
  <p><strong>layout_item</strong></p>
  <pre><code>&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      xmlns:card_view=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:padding=&quot;3dp&quot;
      android:layout_margin=&quot;@dimen/item_margin&quot;
      android:orientation=&quot;vertical&quot;
      &gt;
      &lt;androidx.cardview.widget.CardView
          android:id=&quot;@+id/card_view&quot;
          card_view:cardElevation=&quot;10dp&quot;
          android:layout_margin=&quot;@dimen/item_margin&quot;
          android:layout_centerHorizontal=&quot;true&quot;
          android:layout_width=&quot;500dp&quot;
          android:layout_height=&quot;wrap_content&quot;
  
          &gt;
          &lt;RelativeLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;&gt;
  
              &lt;ImageView
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;120dp&quot;
                  android:layout_gravity=&quot;center&quot;
                  android:src=&quot;@drawable/select_snap&quot; /&gt;
  
              &lt;ImageView
                  android:id=&quot;@+id/the_grid_image_preview&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;120dp&quot;
                  android:scaleType=&quot;centerInside&quot; /&gt;
  
              &lt;com.snapchat.kit.chickencam.SnapVideoView
                  android:id=&quot;@+id/the_grid_video_preview&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;120dp&quot;
                  android:layout_gravity=&quot;center&quot;
                  android:visibility=&quot;gone&quot; /&gt;
          &lt;/RelativeLayout&gt;
  
      &lt;/androidx.cardview.widget.CardView&gt;
      &lt;Button
          android:id=&quot;@+id/thegrid_share_button&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;Clear&quot;
          android:layout_below=&quot;@id/card_view&quot;
          /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>