Gligar

Additional

Language
Kotlin
Version
v1.1.0 (Apr 7, 2020)
Created
Dec 1, 2019
Updated
Aug 27, 2021 (Retired)
Owner
OpenSooq
Contributors
Hani Al-momani (hani-momanii)
Faisal rasak (monsterbrain)
2
Activity
Badge
Generate
Download
Source code

Gliger [Android Image Picker Library]

⭐ Star us on GitHub — it helps!

Gliger is an Easy, lightweight and high performance image picker library for Android!
Gliger load images using Android content resolver with the help of coroutines to lazy load the images and improve the performance!
Gliger handle permission requests, support camera capture, and limit for the max number of images to pick.

Demo

Table of content

Download

This library is available in jCenter which is the default Maven repository used in Android Studio. You can also import this library from source as a module.

dependencies {
    // other dependencies here
    implementation 'com.opensooq.supernova:gligar:1.1.0'
}

Sample Project

We have a sample project demonstrating how to use the library.

Checkout the demo here

Usage

Simpler than ever!

To open the Picker:

Kotlin

GligarPicker().requestCode(PICKER_REQUEST_CODE).withActivity(this).show()

Java

new GligarPicker().requestCode(PICKER_REQUEST_CODE).withActivity(this).show();

To get the result override onActivityResult method:

Kotlin

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode != Activity.RESULT_OK) {
            return
        }

        when (requestCode) {
            PICKER_REQUEST_CODE -> {
                val imagesList = data?.extras?.getStringArray(GligarPicker.IMAGES_RESULT)// return list of selected images paths.
                if (!imagesList.isNullOrEmpty()) {
                    imagesCount.text = "Number of selected Images: ${imagesList.size}"
                }
            }
        }
    }

Java

@Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode != Activity.RESULT_OK) {
            return;
        }
        switch (requestCode){
            case PICKER_REQUEST_CODE : {
              String pathsList[]= data.getExtras().getStringArray(GligarPicker.IMAGES_RESULT); // return list of selected images paths.
                imagesCount.text = "Number of selected Images: " + pathsList.length;
                break;
            }   
        }
    }
Method usage
withActivity(activity: Activity) used to set the activity will recive the result
withFragment(fragment: Fragment) used to set the fragment will recive the result
requestCode(requestCode: Int) used to set the request code for the result
limit(limit: Int) used to set the max number of images to select
disableCamera(disableCamera: Boolean) by default the value of disableCamera is false, it determine to allow camera captures or not
cameraDirect(cameraDirect: Boolean) by default the value of cameraDirect is false, it determine to open the camera before showing the picker or not

UI customization

Customizable Colors

override any color to change inside your project colors.xml

Property Description
counter_bg selection counter background color
counter_color selection counter text color
selector_color selection tint color
place_holder_color empty image holder color
ripple_color selection ripple color
toolbar_bg toolbar color
done Done button color
change_album_color change album text color
camera_icon_color camera icon color
camera_text_color camera text color
permission_alert_bg permission alert background color
permission_alert_color permission alert text color

Customizable Texts

override any string to change inside your project strings.xml

Property Description
over_limit_msg selection limit reached message
capture_new_image capture image text
change_album_text change album text
permission_storage_never_ask permission denied message
all_images all images album name

License

Copyright 2019 OpenSooq

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.