Giter VIP home page Giter VIP logo

medialoader's Introduction

image MediaLoader

Use this library , you can load pictures,videos,audios very fast in Phone Storage.
you can visit my site : MediaLoader

Dependency

dependencies {
    compile 'com.jiajunhui.xapp.medialoader:medialoader:1.2.1'
}

release jar

add permission

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

In android M device , please pay attention to the Runtime Permission.

Default Loader

Load Images

load images folders

MediaLoader.loadPhotoFolders(this, new OnPhotoFolderLoaderCallBack() {
            @Override
            public void onResultFolders(List<PhotoFolder> folders) {
                
            }
        });

load all images
MediaLoader.loadPhotos(this, new OnPhotoLoaderCallBack() {
            @Override
            public void onResultList(List<PhotoItem> items) {
                
            }
        });

Load Videos

load videos folders

MediaLoader.loadVideoFolders(this, new OnVideoFolderLoaderCallBack() {
            @Override
            public void onResultFolders(List<VideoFolder> folders, int totalNum) {
                
            }
        });

load all videos
MediaLoader.loadVideos(this, new OnVideoLoaderCallBack() {
            @Override
            public void onResultList(List<VideoItem> items) {
                
            }
        });

Load Audios

load all audios

MediaLoader.loadAudios(this, new OnAudioLoaderCallBack() {
            @Override
            public void onResultList(List<AudioItem> items) {
                
            }
        });

Custom Loader

public class MyPhotoCursorLoaderCallBack extends BasePhotoCursorLoaderCallBack {
    public MyPhotoCursorLoaderCallBack(Context context, OnLoaderCallBack onLoaderCallBack) {
        super(context, onLoaderCallBack);
    }

    @Override
    public String[] getSelectProjection() {
        String[] PROJECTION = {
                MediaStore.Images.Media._ID,
                MediaStore.Images.Media.DATA,
                MediaStore.Images.Media.BUCKET_ID,
                MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
                MediaStore.Images.Media.DISPLAY_NAME,
                MediaStore.Images.Media.WIDTH,
                MediaStore.Images.Media.HEIGHT,
                MediaStore.Images.Media.DATE_MODIFIED
        };
        return PROJECTION;
    }

    @Override
    public String getSelections() {
        return MediaStore.MediaColumns.SIZE + " > ?" + " and " + MediaStore.Images.Media.WIDTH + " > ? and " + MediaStore.Images.Media.HEIGHT + " > ?";
    }

    @Override
    public String[] getSelectionsArgs() {
        return new String[]{"0","500","500"};
    }
}

MediaLoader.loadMedia(this,new MyPhotoCursorLoaderCallBack(getApplicationContext(), new OnLoaderCallBack() {
            @Override
            public void onLoadFinish(Loader<Cursor> loader, Cursor data) {
                List<MyPhoto> photos = new ArrayList<>();
                MyPhoto photo;
                while (data.moveToNext()) {
                    photo = new MyPhoto();
                    int imageId = data.getInt(data.getColumnIndexOrThrow(_ID));
                    String name = data.getString(data.getColumnIndexOrThrow(DISPLAY_NAME));
                    String path = data.getString(data.getColumnIndexOrThrow(DATA));
                    int width = data.getInt(data.getColumnIndexOrThrow(WIDTH));
                    int height = data.getInt(data.getColumnIndexOrThrow(HEIGHT));
                    photo.setId(imageId);
                    photo.setDisplayName(name);
                    photo.setPath(path);
                    photo.setWidth(width);
                    photo.setHeight(height);
                    photos.add(photo);
                }
                tv_photo_info.setText("宽高均大于500的图片: " + photos.size() + " 张");
            }
        }));

medialoader's People

Contributors

jiajunhui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.