提交 bc5ee2f1 编写于 作者: N Nereo

add doc

.gradle
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
/*/build/
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
The MIT License (MIT)
Copyright (c) 2015 Nereo
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.
# MultiImageSelector
Image selector for Android device. Support single choice and multi-choice.
[中文文档](README_zh.md)
###ART
![Example1](art/example_1.png) ![Select1](art/select_1.png) ![Select2](art/select_2.png) ![Select3](art/select_3.png)
-------------------
###Quick Start
* Step 0
Add module `multi-image-selector` as your dependence.
* Step 1
Declare permission `android.permission.READ_EXTERNAL_STORAGE` in your `AndroidManifest.xml` .
Declare `MultiImageSelectorActivity` in your `AndroidManifest.xml` .
* Step 2
Call image selector activity in your code, eg.
``` java
Intent intent = new Intent(mContext, MultiImageSelectorActivity.class);
// whether show camera
intent.putExtra(MultiImageSelectorActivity.EXTRA_SHOW_CAMERA, true);
// max select image amount
intent.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_COUNT, 9);
// select mode (MultiImageSelectorActivity.MODE_SINGLE OR MultiImageSelectorActivity.MODE_MULTI)
intent.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_MODE, MultiImageSelectorActivity.MODE_MULTI);
startActivityForResult(intent, REQUEST_IMAGE);
```
* Step 3
Receive result in your `onActivityResult` Method. eg.
```java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_IMAGE){
if(resultCode == RESULT_OK){
// Get the result list of select image paths
List<String> path = data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT);
// do your logic ....
}
}
}
```
* Step 4
No more steps, just enjoy. :)
-------------------
###Custom Activity Style
* Custome your own Activity
``` java
class CustomerActivity extends Activity implements MultiImageSelectorFragment.Callback{
@Override
protected void onCreate(Bundle savedInstanceState) {
// customer logic here...
Bundle bundle = new Bundle();
bundle.putInt(MultiImageSelectorFragment.EXTRA_SELECT_COUNT, mDefaultCount);
bundle.putInt(MultiImageSelectorFragment.EXTRA_SELECT_MODE, mode);
bundle.putBoolean(MultiImageSelectorFragment.EXTRA_SHOW_CAMERA, isShow);
// Add fragment to your Activity
getSupportFragmentManager().beginTransaction()
.add(R.id.image_grid, Fragment.instantiate(this, MultiImageSelectorFragment.class.getName(), bundle))
.commit();
}
@Override
public void onSingleImageSelected(String path) {
// When select mode set to MODE_SINGLE, this method will received result from fragment
}
@Override
public void onImageSelected(String path) {
// You can specify your ActionBar behavior here
}
@Override
public void onImageUnselected(String path) {
// You can specify your ActionBar behavior here
}
@Override
public void onCameraShot(File imageFile) {
// When user take phone by camera, this method will be called.
}
}
```
* Take a glance of `MultiImageSelectorActivity.java`
-------------------
###Thanks
* [square-picasso](https://github.com/square/picasso) A powerful image downloading and caching library for Android
-------------------
###License
>The MIT License (MIT)
>Copyright (c) 2015 Nereo
>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.
\ No newline at end of file
# MultiImageSelector
仿微信实现多图选择。支持单选和多选两张模式
[English Doc](README.md)
###截图
![Example1](art/example_1.png) ![Select1](art/select_1.png) ![Select2](art/select_2.png) ![Select3](art/select_3.png)
-------------------
###快速开始
* 第0步
把模块 `multi-image-selector` 作为你的项目依赖添加到工程中.
* 第1步
在你的 `AndroidManifest.xml` 文件中添加权限 `android.permission.READ_EXTERNAL_STORAGE`.
别忘了同时在 `AndroidManifest.xml` 中声明 `MultiImageSelectorActivity` 这个Activity.
* 第2步
代码中调用,例如:
``` java
Intent intent = new Intent(mContext, MultiImageSelectorActivity.class);
// 是否显示调用相机拍照
intent.putExtra(MultiImageSelectorActivity.EXTRA_SHOW_CAMERA, true);
// 最大图片选择数量
intent.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_COUNT, 9);
// 设置模式 (支持 单选/MultiImageSelectorActivity.MODE_SINGLE 或者 多选/MultiImageSelectorActivity.MODE_MULTI)
intent.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_MODE, MultiImageSelectorActivity.MODE_MULTI);
startActivityForResult(intent, REQUEST_IMAGE);
```
* 第3步
在你的 `onActivityResult` 方法中接受结果. 例如:
```java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_IMAGE){
if(resultCode == RESULT_OK){
// 获取返回的图片列表
List<String> path = data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT);
// 处理你自己的逻辑 ....
}
}
}
```
* 第4步
没第4步了,就这样就OK啦~ :)
-------------------
###自定义显示
* 自定义Activity
``` java
class CustomerActivity extends Activity implements MultiImageSelectorFragment.Callback{
@Override
protected void onCreate(Bundle savedInstanceState) {
// 你自己的逻辑...
Bundle bundle = new Bundle();
bundle.putInt(MultiImageSelectorFragment.EXTRA_SELECT_COUNT, mDefaultCount);
bundle.putInt(MultiImageSelectorFragment.EXTRA_SELECT_MODE, mode);
<bundle class="putBo"></bundle>olean(MultiImageSelectorFragment.EXTRA_SHOW_CAMERA, isShow);
// 添加主Fragment到Activity
getSupportFragmentManager().beginTransaction()
.add(R.id.image_grid, Fragment.instantiate(this, MultiImageSelectorFragment.class.getName(), bundle))
.commit();
}
@Override
public void onSingleImageSelected(String path) {
// 当选择模式设定为 单选/MODE_SINGLE, 这个方法就会接受到Fragment返回的数据
}
@Override
public void onImageSelected(String path) {
// 一个图片被选择是触发,这里可以自定义的自己的Actionbar行为
}
@Override
public void onImageUnselected(String path) {
// 一个图片被反选是触发,这里可以自定义的自己的Actionbar行为
}
@Override
public void onCameraShot(File imageFile) {
// 当设置了使用摄像头,用户拍照后会返回照片文件
}
}
```
* 具体可以参考`MultiImageSelectorActivity.java`的实现
-------------------
###感谢
* [square-picasso](https://github.com/square/picasso) A powerful image downloading and caching library for Android
-------------------
###License
>The MIT License (MIT)
>Copyright (c) 2015 Nereo
>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.
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册