GithubHelp home page GithubHelp logo

angadtiwari / mediapicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robertlevonyan/media-picker

0.0 0.0 0.0 475 KB

Easy customizable picker for all your needs in Android application

License: Apache License 2.0

Kotlin 99.29% Java 0.71%

mediapicker's Introduction

    Universal Media Picker

Easy customizable picker for all your needs in Android application

Android ArsenalAPI Download

Setup

Gradle:

Add following line of code to your module(app) level gradle file

    implementation 'com.robertlevonyan.components:Picker:1.1.5'

Maven:

  <dependency>
    <groupId>com.robertlevonyan.components</groupId>
    <artifactId>Picker</artifactId>
    <version>1.1.3</version>
    <type>pom</type>
  </dependency>

Usage

Buildung picker

  val pickerDialog = PickerDialog.Builder(this)// Activity or Fragment
                       .setTitle(...)          // String value or resource ID
                       .setTitleTextSize(...)  // Text size of title
                       .setTitleTextColor(...) // Color of title text
                       .setListType(...)       // Type of the picker, must be PickerDialog.TYPE_LIST or PickerDialog.TYPE_Grid
                       .setItems(...)          // List of ItemModel-s which should be in picker
                       .setDialogStyle(...)    // PickerDialog.DIALOG_STANDARD (square corners) or PickerDialog.DIALOG_MATERIAL (rounded corners)
                       .create()               // Create picker

Creating items

  /*  Create a camera item, can be
      ItemModel.ITEM_CAMERA 
      ItemModel.ITEM_GALLERY
      ItemModel.ITEM_VIDEO
      ItemModel.ITEM_VIDEO_GALLERY 
      ItemModel.ITEM_FILES 
  */
  val itemModel = ItemModel(ItemModel.ITEM_CAMERA)
  
  // Some optional parameters
  val itemModel = ItemModel(
                    ItemModel.ITEM_CAMERA,
                    itemLabel, // Default value is "", in this case default text value will be set
                    itemIcon,  // Default value is 0, in this case default icon will be set
                    hasBackground, // draw a shape background over the icon, default value is true
                    backgroundType, // choose a type for icon background, only works if hasBackground is true, can have one of
                                    // this values: ItemType.TYPE_CIRCLE, ItemType.TYPE_SQUARE, ItemType.TYPE_ROUNDED_SQUARE
                    itemBackgroundColor, // custom color for background shape, only works if hasBackground is true, 
                                         // default color is accent color of your app
                    )

Passing permissions from Activity

    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        pickerDialog.onPermissionsResult(requestCode, permissions, grantResults)
    }
    
    // or if you have a fragment
    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        myFragment.pickerDialog.onPermissionsResult(requestCode, permissions, grantResults)
    }

Showing picker

  pickerDialog.show()

And the result is

List picker Grid picker
Standard picker Material picker

Getting the result

    pickerDialog.setPickerCloseListener { type, uri ->
        when (type) {
            ItemModel.ITEM_CAMERA -> /* do something with the photo you've taken */
            ItemModel.ITEM_GALLERY -> /* do something with the image you've chosen */
            ItemModel.ITEM_VIDEO -> /* do something with the video you've recorded */
            ItemModel.ITEM_VIDEO_GALLERY -> /* do something with the video you've chosen */
            ItemModel.ITEM_FILES -> /* do something with the file you've chosen */
        }
     }

Versions

1.1.1 - 1.1.2

Refactoring and some UI changes

1.0.0 - 1.0.5

First version of library

Contact

Special thanks to @chimzycash for createing an amazing logo for this project ☺️

Licence

    Universal Media Picker©
    Copyright 2018 Robert Levonyan
    Url: https://github.com/robertlevonyan/MediaPicker

    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.

mediapicker's People

Contributors

robertlevonyan 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.