Giter Site home page Giter Site logo

parag2385 / picker Goto Github PK

View Code? Open in Web Editor NEW
102.0 2.0 11.0 6.86 MB

Picker - A CameraX based WhatsApp Style Image-Video Picker

Kotlin 100.00%
imagepicker camerax whatsapp photo-gallery picker android image camera android-library picker-library

picker's Introduction

Picker

Download

A CameraX based WhatsApp Style Image-Video Picker

Gif Screenshot 1

Features

  1. Pick Multiple Images and Videos
  2. Restrict User to Pick no of Images and Videos
  3. Capture Images and Videos
  4. Latest CameraX API
  5. Android 10 and above Support using Scoped Storage

Installation

Picker is distributed using jcenter.

   repositories { 
        jcenter()
   }
   
   dependencies {
         implementation "com.appexecutors.picker:picker:$version"
   }

Usage

Initialization

  val mPickerOptions = 
    PickerOptions.init().apply {
        maxCount = 5                        //maximum number of images/videos to be picked
        maxVideoDuration = 10               //maximum duration for video capture in seconds
        allowFrontCamera = true             //allow front camera use
        excludeVideos = false               //exclude or include video functionalities
    }
        
   button.setOnClickListener {
        Picker.startPicker(this, mPickerOptions)    //this -> context of Activity or Fragment
   }

Callback

   override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)

        if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_PICKER){
            val mImageList = data?.getStringArrayListExtra(PICKED_MEDIA_LIST) as ArrayList //List of selected/captured images/videos
            mImageList.map {
                Log.e(TAG, "onActivityResult: $it" )
            }
        }
    }

Note

If you're using a theme for activity from which you're going to start Picker, then consider adding android:windowTranslucentStatus:true in that theme

    <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">        //If you're using this theme
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowTranslucentStatus">true</item>                          //Add this line
    </style>

For detailed example of usage, please look at the included sample app.

Try PicEditor - A WhatsApp style Image Editor

License

Copyright 2020 Parag Pawar

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.

picker's People

Contributors

akshaaatt avatar parag2385 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

picker's Issues

Flickering Issue on start Camera.

Hello,
Great work.
One thing really not looks good that when we start Camera there is a little flicker of previous activity is shown. I think it's just happening in the sample project but it's also the shows in my project.

Android Version: Pie(28)

Camera preview not started

Device: meizu 15
logcat:

2020-08-03 22:46:42.337 24580-24580/com.appexecutors.pickersample E/Picker: Use case binding failed
    java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 0.  May be attempting to bind too many use cases. Existing surfaces: [] New configs: [androidx.camera.core.impl.VideoCaptureConfig@4fba973, androidx.camera.core.impl.ImageCaptureConfig@fa82aad, androidx.camera.core.impl.PreviewConfig@f9076d7]
        at androidx.camera.lifecycle.LifecycleCameraRepository.bindToLifecycleCamera(LifecycleCameraRepository.java:266)
        at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:424)
        at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:275)
        at com.appexecutors.picker.Picker.bindCameraUseCases(Picker.kt:276)
        at com.appexecutors.picker.Picker.access$bindCameraUseCases(Picker.kt:74)
        at com.appexecutors.picker.Picker$startCamera$1.run(Picker.kt:134)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6394)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1000)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:890)
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)

if i replace
cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture, videoCapture)
to
cameraProvider.bindToLifecycle(this, cameraSelector, preview)
then preview is started, but i cant take picture

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.