fix bug in MainActivity and CustomGalleryActivity