Skip to content

Instantly share code, notes, and snippets.

View CodeBoy722's full-sized avatar
:octocat:
Coding better than ever

Codeboy CodeBoy722

:octocat:
Coding better than ever
View GitHub Profile
private ArrayList<imageFolder> getPicturePaths(){
ArrayList<imageFolder> picFolders = new ArrayList<>();
ArrayList<String> picPaths = new ArrayList<>();
Uri allImagesuri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = { MediaStore.Images.ImageColumns.DATA ,MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME,MediaStore.Images.Media.BUCKET_ID};
Cursor cursor = this.getContentResolver().query(allImagesuri, projection, null, null, null);
try {
if (cursor != null) {
cursor.moveToFirst();
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:required="true" />
package com.androidcodeman.simpleimagegallery;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
package com.androidcodeman.simpleimagegallery.utils;
/**
* author CodeBoy722
*
* Custom Class that holds information of a folder containing images
* on the device external storage, used to populate our RecyclerView of
* picture folders
*/
public class imageFolder {
@CodeBoy722
CodeBoy722 / itemClickListener.java
Created May 13, 2019 00:14
Android-Simple-Image-Gallery's itemClickListener.java
package com.androidcodeman.simpleimagegallery.utils;
import java.util.ArrayList;
/**
* Author CodeBoy722
*/
public interface itemClickListener {
/**
@CodeBoy722
CodeBoy722 / pictureFolderAdapter.java
Created May 13, 2019 00:18
Android-Simple-Image-Gallery's pictureFolderAdapter.java
package com.androidcodeman.simpleimagegallery.utils;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
folderName = findViewById(R.id.foldername);
folderName.setText(getIntent().getStringExtra("folderName")); //setting the folder name
//this line gets the folderpath from Intent
foldePath = getIntent().getStringExtra("folderPath");
public ArrayList<pictureFacer> getAllImagesByFolder(String path){
ArrayList<pictureFacer> images = new ArrayList<>();
Uri allVideosuri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = { MediaStore.Images.ImageColumns.DATA ,MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.SIZE};
Cursor cursor = ImageDisplay.this.getContentResolver().query( allVideosuri, projection, MediaStore.Images.Media.DATA + " like ? ", new String[] {"%"+path+"%"}, null);
try {
cursor.moveToFirst();
do{
pictureFacer pic = new pictureFacer();
package com.androidcodeman.simpleimagegallery.utils;
/**
* Author CodeBoy722
*
* Custom class for holding data of images on the device external storage
*/
public class pictureFacer {
private String picturName;