5 Star 0 Fork 0

HarmonyOS-TPC / Lichenwei-Dev_ImagePicker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 2.59 KB
一键复制 编辑 原始数据 按行查看 历史
Abhijith 提交于 2021-04-28 19:15 . update README.md.

ImagePicker

Introduction:

ImagePicker supports functions such as pictures, video single selection, multiple selection, multiple folder switching, large picture preview, and custom picture loader.

Usage Instructions:

  1. How to customize the image loader (indeterminate frame to make the frame more flexible, you need to implement the ImageLoader interface, if you need to display video, the Glide loading frame is recommended first, you can refer to the Demo implementation):
public class GlideLoader implements ImageLoader {
	//to do something
}
  1. A line of code call:
ImagePicker.getInstance()
    .setTitle(ResUtil.getString(getAbility(), ResourceTable.String_title))//Set Title
    .showCamera(true)//Sets whether to display the photographing button.
    .showImage(true)//Set whether to display images.
    .showVideo(true)//Set whether to display videos.
    .filterGif(false)//Specifies whether to filter GIF images.
    .setMaxCount(9)//Sets the maximum number of images to be selected. The default 	value is 1.
    .setSingleType(true)//The image and video cannot be selected at the same time.
    .setImagePaths(mImagePaths)//Setting History Selection Records
    .setImageLoader(new GlideLoader())//Setting up a Custom Picture Loader
    .start(getAbility(), REQUEST_SELECT_IMAGES_CODE);//REQUEST_SELECT_IMAGES_CODE is the request code of Intent invoking.
  1. How to get the selected picture collection:
@Override
protected void onAbilityResult(int requestCode, int resultCode, Intent resultData) {
    if (requestCode == REQUEST_SELECT_IMAGES_CODE && resultCode == TConstant.RESULT_OK) {
		mImagePaths = resultData.getStringArrayListParam(ImagePicker.EXTRA_SELECT_IMAGES);
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("Path of the selected image:\n\n");
        for (String imagePath : mImagePaths) {
        	stringBuffer.append(imagePath).append("\n\n");
        }
        if (!TextUtils.isEmpty(stringBuffer.toString())) {
            mTextView.setText(stringBuffer.toString());
        }
    }
}

Installation tutorial

Method 1:
    Generate the .har package through the library and add the .har package to the libs folder.
    Add the following code to the entry gradle:
        implementation fileTree  (dir: 'libs', include: ['*.jar', '*.har'])
        implementation 'io.openharmony.tpc.thirdlib:glide:1.0.4'

Method 2:
    allprojects{
        repositories{
            mavenCentral()
        }
    }
    implementation 'io.openharmony.tpc.thirdlib:glide:1.0.4'
    implementation 'io.openharmony.tpc.thirdlib:Lichenwei-Dev_ImagePicker:1.0.0'
1
https://gitee.com/HarmonyOS-tpc/Lichenwei-Dev_ImagePicker.git
git@gitee.com:HarmonyOS-tpc/Lichenwei-Dev_ImagePicker.git
HarmonyOS-tpc
Lichenwei-Dev_ImagePicker
Lichenwei-Dev_ImagePicker
master

搜索帮助