{"id":19723800,"url":"https://github.com/qingmei2/rximagepicker","last_synced_at":"2025-05-16T11:04:00.991Z","repository":{"id":44855523,"uuid":"116668295","full_name":"qingmei2/RxImagePicker","owner":"qingmei2","description":":rocket:RxJava2 and RxJava3 external support. Android flexible picture selector, provides the support for theme of Zhihu and WeChat (灵活的Android图片选择器，提供了知乎和微信主题的支持）.","archived":false,"fork":false,"pushed_at":"2022-05-13T02:02:52.000Z","size":20825,"stargazers_count":1198,"open_issues_count":20,"forks_count":155,"subscribers_count":16,"default_branch":"2.x","last_synced_at":"2025-04-09T06:06:53.491Z","etag":null,"topics":["android","android-image-picker","android-image-selector","android-library","imagepicker","picture-selector","rximagepicker"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qingmei2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-08T11:27:25.000Z","updated_at":"2025-03-14T03:57:49.000Z","dependencies_parsed_at":"2022-08-30T20:10:49.273Z","dependency_job_id":null,"html_url":"https://github.com/qingmei2/RxImagePicker","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qingmei2%2FRxImagePicker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qingmei2%2FRxImagePicker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qingmei2%2FRxImagePicker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qingmei2%2FRxImagePicker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qingmei2","download_url":"https://codeload.github.com/qingmei2/RxImagePicker/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-image-picker","android-image-selector","android-library","imagepicker","picture-selector","rximagepicker"],"created_at":"2024-11-11T23:23:32.953Z","updated_at":"2025-05-16T11:04:00.972Z","avatar_url":"https://github.com/qingmei2.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxImagePicker\n\n#### English Documentation | [中文文档](https://github.com/qingmei2/RxImagePicker/blob/2.x/README_ZH.md)\n\n\u003cp/\u003e\n\n\u003ca target=\"_blank\" href=\"https://bintray.com/mq2553299/maven/rximagepicker\"\u003e\u003cimg\n        src=\"https://api.bintray.com/packages/mq2553299/maven/rximagepicker/images/download.svg?version=3.0.0-beta02\"\u003e\u003c/a\u003e(RxJava3)\n\u003ca target=\"_blank\" href='https://bintray.com/mq2553299/maven/rximagepicker/2.5.4/link'\u003e\u003cimg\n        src='https://api.bintray.com/packages/mq2553299/maven/rximagepicker/images/download.svg?version=2.5.4'\u003e\u003c/a\u003e(RxJava2)\n\u003ca target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/API-16+-green.svg\"\u003e\u003c/a\u003e\n\u003ca target=\"_blank\" href=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg\"\u003e\u003c/a\u003e\n\n\nSupport for `RxJava2`. Flexible picture selector of Android, provides the support for theme of Zhihu and WeChat.\n\n\u003e `Zhihu`: Famous Online Q\u0026A Community APP in China.  \n\u003e `WeChat`: Most Used Instant Messaging Social Networking App in China.\n\n## Introduction\n\n**Purpose** of RxImagePicker: Let developers realize the demand of selecting picture in the development of Android in a simple and flexible way.\n\nRxImagePicker 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`.\n\n## Support\n\n- [x] Android Camera Photograph  \n- [x] Android photo album picture selection  \n- [x] Returns data in the format of reactive data stream ( such as `Observable/Flowable/Single/Maybe` )  \n- [x] [AndroidX](https://developer.android.com/jetpack/androidx/) support ( after v2.3.0 )\n\n## Support of UI\n\n- [x] System Picture Selector\n- [x] [Optional] Theme Picture Selector of Zhihu\n- [x] [Optional] Theme Picture Selector of WeChat ()\n- [x] [Optional] Custom UI Picture Selector\n\n## Screenshots\n\n### Selection and result display of system picture:\n\n\u003cdiv align:left;display:inline;\u003e\n\u003cimg width=\"200\" height=\"360\" src=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/screenshot/screenshot_sysytem.png\"/\u003e\n\u003cimg width=\"200\" height=\"360\" src=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/screenshot/screenshot_result.png\"/\u003e\n\u003c/div\u003e\n\n### Theme of Zhihu\n\n\u003cdiv align:left;display:inline;\u003e\n\u003cimg width=\"200\" height=\"360\" src=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/screenshot/screenshot_zhihu_dracula.png\"/\u003e\n\u003cimg width=\"200\" height=\"360\" src=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/screenshot/screenshot_zhihu_normal.png\"/\u003e\n\u003c/div\u003e\n\n### Theme of WeChat\n\n\u003cdiv align:left;display:inline;\u003e\n\u003cimg width=\"200\" height=\"360\" src=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/screenshot/screenshot_wechat.png\"/\u003e\n\u003cimg width=\"200\" height=\"360\" src=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/screenshot/screenshot_wechat_expand.png\"/\u003e\n\u003c/div\u003e\n\n### UI Test\n\n\u003cdiv align:left;display:inline;\u003e\n\u003cimg width=\"235\" height=\"360\" src=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/screenshot/rximagepicker_test.gif\"/\u003e\n\u003c/div\u003e\n\n\u003cdiv align:left;display:inline;\u003e\n\u003cimg width=\"608\" height=\"175\" src=\"https://github.com/qingmei2/RxImagePicker/blob/2.x/screenshot/test_result.png\"/\u003e\n\u003c/div\u003e\n\n## Basic Usage\n\nThe following code will show you how to use photo album or camera at the Android system-level :\n\n### 1.Add the following depending on the file of build.gradle:\n\n```groovy\n// The most basic architecture, only provides the default\n// picture selector and photographing function of system.\n\nimplementation 'com.github.qingmei2:rximagepicker:${last_version}'\n\n// Provide the basic components of custom UI picture selector\n// and this dependency needs to be added to the requirements of the custom UI\nimplementation 'com.github.qingmei2:rximagepicker_support:${last_version}'\n\n\n// If you need additional UI support, choose to rely on the corresponding UI extension library\n\n// Zhihu picture selector\nimplementation 'com.github.qingmei2:rximagepicker_support_zhihu:${last_version}'\n\n// WeChat picture selector\nimplementation 'com.github.qingmei2:rximagepicker_support_wechat:${last_version}'\n```\n\n\u003e **If your project not migrate to `androidx`, please use version `2.2.0`**.\n\n### 2.Interface Configuration\n\nDeclare an interface and carry out the following configuration:\n\n```java\npublic interface MyImagePicker {\n\n    @Gallery    // open gallery\n    Observable\u003cResult\u003e openGallery(Context context);\n\n    @Camera     // take photos\n    Observable\u003cResult\u003e openCamera(Context context);\n}\n```\n\n### 3.Instantiate and use it\n\nInstantiate the interface in your `Activity` or `Fragment` to open the default album and camera screen of system:\n\n```Java\nRxImagePicker\n        .create(MyImagePicker.class)\n        .openGallery(this)\n        .subscribe(new Consumer\u003cResult\u003e() {\n            @Override\n            public void accept(Result result) throws Exception {\n                // do something, ex:\n                Uri uri = result.getUri();\n                GlideApp.with(this)\n                         .load(uri)\n                         .into(ivPickedImage);\n            }\n        });\n```\n\n## Support UI theme Usage\n\n### 1.Add the following depending on the file of build.gradle:\n\n```groovy\n// Zhihu picture selector\nimplementation 'com.github.qingmei2:rximagepicker_support_zhihu:${last_version}'\n```\n\n### 2.Interface Configuration\n\nDeclare an interface and carry out the following configuration:\n\n```kotlin\ninterface ZhihuImagePicker {\n\n    // normal style\n    @Gallery(componentClazz = ZhihuImagePickerActivity::class,\n            openAsFragment = false)\n    fun openGalleryAsNormal(context: Context,\n                            config: ICustomPickerConfiguration): Observable\u003cResult\u003e\n\n    // dracula style                        \n    @Gallery(componentClazz = ZhihuImagePickerActivity::class,\n            openAsFragment = false)\n    fun openGalleryAsDracula(context: Context,\n                             config: ICustomPickerConfiguration): Observable\u003cResult\u003e\n\n    // take photo                         \n    @Camera\n    fun openCamera(context: Context): Observable\u003cResult\u003e\n}\n```\n\n### 3.Instantiate and use it\n\n```Kotlin\nval rxImagePicker: ZhihuImagePicker = RxImagePicker\n                .create(ZhihuImagePicker::class.java)\n\nrxImagePicker.openGalleryAsNormal(this,\n                ZhihuConfigurationBuilder(MimeType.ofImage(), false)\n                        .maxSelectable(9)\n                        .countable(true)\n                        .spanCount(4)\n                        .theme(R.style.Zhihu_Normal)\n                        .build())\n               .subscribe {\n                    Glide.with(this@ZhihuActivity)\n                            .load(it.uri)\n                            .into(imageView)\n                }\n```\n\nsee [sample](https://github.com/qingmei2/RxImagePicker/blob/2.x/sample/src/main/java/com/qingmei2/sample/zhihu/ZhihuActivity.kt) for more informations.\n\n## Advanced Usage\n\n### 1. Action Annotation\n\nRxImagePicker provides two action annovation, respectively `@Gallery` and `@Camera`.\n\n`@Camera` will declare the way annovated by the annovation  Open the camera to take a photo.\n\nPlease 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.\n\n#### @Gallery\n\n`@Gallery` will open the photo album to choose picture.\n\nIt has three parameters:\n\n* `componentClazz：KClass\u003c*\u003e` The class object of UI component, opens `SystemGalleryPickerView::class`—— the system Gallery by default.\n\n* `openAsFragment：Boolean` Whether UI component is displayed as `Fragment` in some parts of `Activity` is true by default.\n\n* `containerViewId: Int`  If UI needs to be displayed as `Fragment` in ViewGroup, the id corresponding to the ViewGroup needs to be assigned to it.\n\nAt present UI component only supports two kinds: `FragmentActivity` or `Fragment`(support-v4).\n\n**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:\n\n```kotlin\ninterface SystemImagePicker {\n\n    @Gallery   // by default,componentClazz：KClass = SystemGalleryPickerView::class，openAsFragment：Boolean=true\n    fun openGallery(context: Context): Observable\u003cResult\u003e\n}\n```\n\nWhen 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`:\n\n```kotlin\ninterface ZhihuImagePicker {\n\n    @Gallery(componentClazz = ZhihuImagePickerActivity::class,\n            openAsFragment = false)\n    fun openGalleryAsNormal(context: Context,\n                            config: ICustomPickerConfiguration): Observable\u003cResult\u003e\n\n    @Gallery(componentClazz = ZhihuImagePickerActivity::class,\n            openAsFragment = false)\n    fun openGalleryAsDracula(context: Context,\n                             config: ICustomPickerConfiguration): Observable\u003cResult\u003e\n\n    @Camera\n    fun openCamera(context: Context): Observable\u003cResult\u003e\n}\n```\n\nFor more information, please refer to the [ZhihuActivity](https://github.com/qingmei2/RxImagePicker/blob/2.x/sample/src/main/java/com/qingmei2/sample/zhihu/ZhihuActivity.kt) in sample.\n\nAt 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`.\n\n#### @Camera\n\n`@Camera` will declare the way annotated by the annotation open the camera to take photo.\n\nPlease 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.\n\n### 2.ICustomPickerView\n\n`ICustomPickerView` is an underneath interface, it is used for:\n\n* 1. Show the picture selector interface\n* 2. Obtain selection results of users\n\n```kotlin\ninterface ICustomPickerView {\n\n    fun display(fragmentActivity: FragmentActivity,\n                @IdRes viewContainer: Int,\n                configuration: ICustomPickerConfiguration?)\n\n    fun pickImage(): Observable\u003cResult\u003e\n}\n```\n\nIt has several classic implementation classes, for example, [ImagePickerDisplayer](https://github.com/qingmei2/RxImagePicker/blob/2.x/rximagepicker/src/main/java/com/qingmei2/rximagepicker/core/ImagePickerDisplayer.kt) when open the corresponding activity through configuration;\n\n### 3.Context: necessary parameters.\n\nEach 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`:\n\n\u003e ${method.name} requires just one instance of type: Context, but none.\n\nThis is understandable. Starting the UI component of a picture selector must depend on the instance of `Context`.\n\nNote, This `Context` must be a `FragmentActivity`, not `Application` or others, or else throw out the abnormity of `IllegalArgumentException`!\n\n### 4.ICustomPickerConfiguration: optional parameters\n\n`ICustomPickerConfiguration` interface, similar to a tag. RxImagePicker will treat it as the configuration class.\n\nAs 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 ).\n\nThe basic components of RxImagePicker do not provide the implementation class, please refer to [SelectionSpec](https://github.com/qingmei2/RxImagePicker/blob/2.x/rximagepicker_support/src/main/java/com/qingmei2/rximagepicker_extension/entity/SelectionSpec.kt) if any questions.\n\n### 2.5 Complete full custom UI\n\nThough 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.\n\nRxImagePicker 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.\n\nThe above WeChat theme and Zhihu theme are based on its to implement. Please refer to the source code for detailed implementation.\n\n## Another author's libraries using RxJava:\n\n* [RxWeaver: A lightweight and flexible error handler tools of RxJava2.](https://github.com/qingmei2/RxWeaver)\n\n* [MVVM-Rhine: The MVVM using RxJava and Android databinding.](https://github.com/qingmei2/MVVM-Rhine)\n\n## License\n    The RxImagePicker：MIT License\n\n    Copyright (c) 2018 qingmei2\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqingmei2%2Frximagepicker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqingmei2%2Frximagepicker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqingmei2%2Frximagepicker/lists"}