All Projects → qingmei2 → Rximagepicker

qingmei2 / Rximagepicker

Licence: mit
🚀RxJava2 and RxJava3 external support. Android flexible picture selector, provides the support for theme of Zhihu and WeChat (灵活的Android图片选择器,提供了知乎和微信主题的支持).

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Rximagepicker

Filepicker
🔥🔥🔥Android文件、图片选择器,可按文件夹查找,文件类型查找,支持自定义相机
Stars: ✭ 265 (-75.87%)
Mutual labels:  imagepicker
Imagepicker
完全仿微信的图片选择,并且提供了多种图片加载接口,选择图片后可以旋转,可以裁剪成矩形或圆形,可以配置各种其他的参数
Stars: ✭ 4,225 (+284.79%)
Mutual labels:  imagepicker
Lpalbum
an albums that can preview, multiple-choice
Stars: ✭ 17 (-98.45%)
Mutual labels:  imagepicker
Photopicker
[DEPRECATED] Image Picker like Wechat
Stars: ✭ 2,852 (+159.74%)
Mutual labels:  imagepicker
Zlphotobrowser
Wechat-like image picker. Support select normal photos, videos, gif and livePhoto. Support edit image and crop video. 微信样式的图片选择器,支持预览/相册内拍照及录视频、拖拽/滑动选择,编辑图片/视频,支持多语言国际化等功能;
Stars: ✭ 3,962 (+260.84%)
Mutual labels:  imagepicker
Imagepicker
📷 Reinventing the way ImagePicker works.
Stars: ✭ 4,634 (+322.04%)
Mutual labels:  imagepicker
ImagePicker-OLX
No description or website provided.
Stars: ✭ 77 (-92.99%)
Mutual labels:  imagepicker
Pgimagepicker
类似于微博、微信的多图浏览/查看
Stars: ✭ 39 (-96.45%)
Mutual labels:  imagepicker
Insgallery
📸 Instagram-like image picker for Android (一款 UI 炫酷高仿 Instagram 的图片、视频选择器)
Stars: ✭ 409 (-62.75%)
Mutual labels:  imagepicker
Imagepicker
Super Image Picker is a powerful image selector. Support for huge image preview (such as 10000 * 5000px), support for image cropping, configurable avatar mode and normal mode, support for a variety of image load library
Stars: ✭ 891 (-18.85%)
Mutual labels:  imagepicker
Coco
基于kotlin、简洁易用的调用系统拍照或图片选择库
Stars: ✭ 276 (-74.86%)
Mutual labels:  imagepicker
Imagepicker
高仿微信图片选择器(支持单图,多图,视频选择,支持图片自由缩放,视频播放等功能)
Stars: ✭ 372 (-66.12%)
Mutual labels:  imagepicker
Androidpicker
安卓选择器类库,包括日期及时间选择器(可用于出生日期、营业时间等)、单项选择器(可用于性别、民族、职业、学历、星座等)、二三级联动选择器(可用于车牌号、基金定投日期等)、城市地址选择器(分省级、地市级及区县级)、数字选择器(可用于年龄、身高、体重、温度等)、日历选日期择器(可用于酒店及机票预定日期)、颜色选择器、文件及目录选择器、图片选择器等……WheelPicker/DatePicker/TimePicker/OptionPicker/NumberPicker/LinkagePicker/AddressPicker/CarPlatePicker/CalendarPicker/ColorPicker/FilePicker/ImagePicker etc.
Stars: ✭ 5,320 (+384.52%)
Mutual labels:  imagepicker
Bottomsheet Imagepicker
Modern image picker for Android
Stars: ✭ 267 (-75.68%)
Mutual labels:  imagepicker
Yimagepicker
小红书多图剪裁+微信图片选择器+大图预览+图片剪裁(支持圆形剪裁和镂空剪裁),已适配androidQ,借鉴并升级matisse加载内核!超强定制性可轻松实现知乎/马蜂窝/微博等特殊样式!支持跨进程回调!内部结构轻量级,无任何第三方开源库!支持support依赖!
Stars: ✭ 975 (-11.2%)
Mutual labels:  imagepicker
ImagePickerView
🌇 PHPickerViewController / UIImagePickerController for SwiftUI
Stars: ✭ 18 (-98.36%)
Mutual labels:  imagepicker
Piximagepicker
Pix is a Whatsapp image picker replica. with this, you can integrate an image picker just like WhatsApp.
Stars: ✭ 488 (-55.56%)
Mutual labels:  imagepicker
Wclimagepickercontroller
可自定义的图片选择器
Stars: ✭ 49 (-95.54%)
Mutual labels:  imagepicker
Tzimagepickercontroller
一个支持多选、选原图和视频的图片选择器,同时有预览、裁剪功能,支持iOS6+。 A clone of UIImagePickerController, support picking multiple photos、original photo、video, also allow preview photo and video, support iOS6+
Stars: ✭ 7,740 (+604.92%)
Mutual labels:  imagepicker
Imagepicker
📸Image Picker for Android, Pick an image from Gallery or Capture a new image with Camera
Stars: ✭ 623 (-43.26%)
Mutual labels:  imagepicker

RxImagePicker

English Documentation | 中文文档

(RxJava3) (RxJava2)

Support for RxJava2. Flexible picture selector of Android, provides the support for theme of Zhihu and WeChat.

Zhihu: Famous Online Q&A Community APP in China.
WeChat: Most Used Instant Messaging Social Networking App in China.

Introduction

Purpose of RxImagePicker: Let developers realize the demand of selecting picture in the development of Android in a simple and flexible way.

RxImagePicker is a reactive picture selector for Android, which converts your selection requirements of picture into an interface for configuration and displays any UI theme in Activity or Fragment.

Support

  • [x] Android Camera Photograph
  • [x] Android photo album picture selection
  • [x] Returns data in the format of reactive data stream ( such as Observable/Flowable/Single/Maybe )
  • [x] AndroidX support ( after v2.3.0 )

Support of UI

  • [x] System Picture Selector
  • [x] [Optional] Theme Picture Selector of Zhihu
  • [x] [Optional] Theme Picture Selector of WeChat ()
  • [x] [Optional] Custom UI Picture Selector

Screenshots

Selection and result display of system picture:

Theme of Zhihu

Theme of WeChat

UI Test

Basic Usage

The following code will show you how to use photo album or camera at the Android system-level :

1.Add the following depending on the file of build.gradle:

// The most basic architecture, only provides the default
// picture selector and photographing function of system.

implementation 'com.github.qingmei2:rximagepicker:${last_version}'

// Provide the basic components of custom UI picture selector
// and this dependency needs to be added to the requirements of the custom UI
implementation 'com.github.qingmei2:rximagepicker_support:${last_version}'


// If you need additional UI support, choose to rely on the corresponding UI extension library

// Zhihu picture selector
implementation 'com.github.qingmei2:rximagepicker_support_zhihu:${last_version}'

// WeChat picture selector
implementation 'com.github.qingmei2:rximagepicker_support_wechat:${last_version}'

If your project not migrate to androidx, please use version 2.2.0.

2.Interface Configuration

Declare an interface and carry out the following configuration:

public interface MyImagePicker {

    @Gallery    // open gallery
    Observable<Result> openGallery(Context context);

    @Camera     // take photos
    Observable<Result> openCamera(Context context);
}

3.Instantiate and use it

Instantiate the interface in your Activity or Fragment to open the default album and camera screen of system:

RxImagePicker
        .create(MyImagePicker.class)
        .openGallery(this)
        .subscribe(new Consumer<Result>() {
            @Override
            public void accept(Result result) throws Exception {
                // do something, ex:
                Uri uri = result.getUri();
                GlideApp.with(this)
                         .load(uri)
                         .into(ivPickedImage);
            }
        });

Support UI theme Usage

1.Add the following depending on the file of build.gradle:

// Zhihu picture selector
implementation 'com.github.qingmei2:rximagepicker_support_zhihu:${last_version}'

2.Interface Configuration

Declare an interface and carry out the following configuration:

interface ZhihuImagePicker {

    // normal style
    @Gallery(componentClazz = ZhihuImagePickerActivity::class,
            openAsFragment = false)
    fun openGalleryAsNormal(context: Context,
                            config: ICustomPickerConfiguration): Observable<Result>

    // dracula style                        
    @Gallery(componentClazz = ZhihuImagePickerActivity::class,
            openAsFragment = false)
    fun openGalleryAsDracula(context: Context,
                             config: ICustomPickerConfiguration): Observable<Result>

    // take photo                         
    @Camera
    fun openCamera(context: Context): Observable<Result>
}

3.Instantiate and use it

val rxImagePicker: ZhihuImagePicker = RxImagePicker
                .create(ZhihuImagePicker::class.java)

rxImagePicker.openGalleryAsNormal(this,
                ZhihuConfigurationBuilder(MimeType.ofImage(), false)
                        .maxSelectable(9)
                        .countable(true)
                        .spanCount(4)
                        .theme(R.style.Zhihu_Normal)
                        .build())
               .subscribe {
                    Glide.with([email protected])
                            .load(it.uri)
                            .into(imageView)
                }

see sample for more informations.

Advanced Usage

1. Action Annotation

RxImagePicker provides two action annovation, respectively @Gallery and @Camera.

@Camera will declare the way annovated by the annovation Open the camera to take a photo.

Please note, each method of the interface must add an action annotation to declare the corresponding action. If the method is not configured with @Gallery or @Camera, RxImagePicker will throw an Exception at runtime.

@Gallery

@Gallery will open the photo album to choose picture.

It has three parameters:

  • componentClazz:KClass<*> The class object of UI component, opens SystemGalleryPickerView::class—— the system Gallery by default.

  • openAsFragment:Boolean Whether UI component is displayed as Fragment in some parts of Activity is true by default.

  • containerViewId: Int If UI needs to be displayed as Fragment in ViewGroup, the id corresponding to the ViewGroup needs to be assigned to it.

At present UI component only supports two kinds: FragmentActivity or Fragment(support-v4).

Taking turning on the system camera for example, its principle is to instantiate an invisible Fragment in the current Activity, and Fragment opens the system photo album through Intent and processes the returned data through the method of onActivityResult(). The code is as the following:

interface SystemImagePicker {

    @Gallery   // by default,componentClazz:KClass = SystemGalleryPickerView::class,openAsFragment:Boolean=true
    fun openGallery(context: Context): Observable<Result>
}

When need to custom UI, taking Zhihu theme as an example, we will configure ZhihuImagePickerActivity::class to componentClazz and set the value of openAsFragment to false:

interface ZhihuImagePicker {

    @Gallery(componentClazz = ZhihuImagePickerActivity::class,
            openAsFragment = false)
    fun openGalleryAsNormal(context: Context,
                            config: ICustomPickerConfiguration): Observable<Result>

    @Gallery(componentClazz = ZhihuImagePickerActivity::class,
            openAsFragment = false)
    fun openGalleryAsDracula(context: Context,
                             config: ICustomPickerConfiguration): Observable<Result>

    @Camera
    fun openCamera(context: Context): Observable<Result>
}

For more information, please refer to the ZhihuActivity in sample.

At the same time, when UI needs to be displayed as Fragment, RxImagePicker needs to be informed of the id of the ViewGroup control so that RxImagePicker can be correctly displayed in the corresponding ViewGroup.

@Camera

@Camera will declare the way annotated by the annotation open the camera to take photo.

Please note, @Camera only provides the function of calling the system camera to take a photo at present. Although this annotation provides the same API as @Gallery, there is no sense to configure them at present.

2.ICustomPickerView

ICustomPickerView is an underneath interface, it is used for:

    1. Show the picture selector interface
    1. Obtain selection results of users
interface ICustomPickerView {

    fun display(fragmentActivity: FragmentActivity,
                @IdRes viewContainer: Int,
                configuration: ICustomPickerConfiguration?)

    fun pickImage(): Observable<Result>
}

It has several classic implementation classes, for example, ImagePickerDisplayer when open the corresponding activity through configuration;

3.Context: necessary parameters.

Each interface method of RxImagePicker must be configured with a Context as parameters. If the method does not have any parameters, it will throw out NullPointerException:

${method.name} requires just one instance of type: Context, but none.

This is understandable. Starting the UI component of a picture selector must depend on the instance of Context.

Note, This Context must be a FragmentActivity, not Application or others, or else throw out the abnormity of IllegalArgumentException!

4.ICustomPickerConfiguration: optional parameters

ICustomPickerConfiguration interface, similar to a tag. RxImagePicker will treat it as the configuration class.

As for opening the system photo album or system camera, it makes no sense to configure, but it must be configured for custom UI ( such as WeChat theme and Zhihu theme ).

The basic components of RxImagePicker do not provide the implementation class, please refer to SelectionSpec if any questions.

2.5 Complete full custom UI

Though RxImagePicker provides the UI style of WeChat picture selector and Zhihu picture selector, two sets of models are still not enough to cover more and more sophisticated UI demands of APP.

RxImagePicker provides enough degree of freedom interface to provide private customized UI for developers. Whether a new Activity is created or displayed in a ViewGroup container at present, it is enough.

The above WeChat theme and Zhihu theme are based on its to implement. Please refer to the source code for detailed implementation.

Another author's libraries using RxJava:

License

The RxImagePicker:MIT License

Copyright (c) 2018 qingmei2

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].