Giter Site home page Giter Site logo

imagepicker's Introduction

ImagePicker for Android

原作者地址,因作者不再维护,存在些许bug,复制一份自我维护,修复若干bug,并已经发布到了jcenter


Requirements

  • Android miniSDK 16

Usage

Gradle dependency

repositories {
    jcenter()
}

dependencies {
    compile 'com.moonljt521.imagepicker:imagepicker:1.1.3'
}

Sample Code

With preview:

// you can init this in application ,
private ImagePicker imagePicker;
imagePicker.setImageLoader(new GlideImageLoader());   //设置图片加载器
imagePicker.setShowCamera(false);  //显示拍照按钮
imagePicker.setCrop(false);        //允许裁剪(单选才有效)
imagePicker.setSaveRectangle(true); //是否按矩形区域保存
imagePicker.setMultiMode(false);
imagePicker.setSelectLimit(1);    //选中数量限制
imagePicker.setStyle(CropImageView.Style.RECTANGLE);  //裁剪框的形状
imagePicker.setFocusWidth(800);   //裁剪框的宽度。单位像素(圆形自动取宽高最小值)
imagePicker.setFocusHeight(800);  //裁剪框的高度。单位像素(圆形自动取宽高最小值)
imagePicker.setOutPutX(300);   //保存文件的宽度。单位像素
imagePicker.setOutPutY(300);  //保存文件的高度。单位像素

// call camera
Intent intent = new Intent(context.getActivity(), ImageGridActivity.class);
intent.putExtra(ImageGridActivity.EXTRAS_TAKE_PICKERS, true); // 是否是直接打开相机
context.startActivityForResult(intent, requestCode);

// start album
Intent intent = new Intent(context.getActivity(), ImageGridActivity.class);
context.startActivityForResult(intent, requestCode);

// receive the result data
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
            if (data != null && requestCode == 100) {
                // ...
        } else {
                Toast.makeText(this, "no data", Toast.LENGTH_SHORT).show();
        }
    }
}

Gradle

Make sure that you run the clean target when using maven.

gradle clean assemble

imagepicker's People

Contributors

moonljt521 avatar

Stargazers

 avatar

Watchers

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