Giter Site home page Giter Site logo

crop's Introduction

Crop

使用系统自带裁剪,返回Uri。解决4.4以后改变Uri规则兼容问题

Usage

1、Using Crop Library in your application

Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects { repositories { ... maven { url "https://jitpack.io" } } }

Add the dependency

dependencies { compile 'com.github.2tu:crop:1.0.1' }

2、init CropParams

裁剪
mCropParams = CropParams.initCropParams();

不裁剪
mCropParams = CropParams.initCropParams();
mCropParams.crop = "false";

3、implements CropHandler
@Override
public void onPhotoCropped(Uri uri) {
    //croped
    mImageView.setImageURI(uri);
    cropUris.add(uri);
}

@Override
public void onCropCancel() {
    Toast.makeText(this, "crop cancel", Toast.LENGTH_LONG).show();
}

@Override
public void onCropFailed(String message) {
    Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}

@Override
public CropParams getCropParams() {
    return mCropParams;
}

@Override
public Activity getContext() {
    return this;
}
4、onActivityForResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK) {
        return;
    }
    switch (requestCode) {
        case CropHelper.REQUEST_CAMERA:
        case CropHelper.REQUEST_GALLERY:
        case CropHelper.REQUEST_CROP:
            CropHelper.handleResult(this, requestCode, resultCode, data);
            break;
    }
}
5、clean croped file

CropHelper.cleanAllCropCache(this);

crop's People

Contributors

zongbintu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kevin343738465

crop's Issues

为什么找不到classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

急需解决啊,求指教
我在root build.gradle添加
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
在library添加
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.1990MyLove
sync之后,为什么报错,在我的D:\software\Android Studio\gradle\m2repository\com\github......
找不到android-maven-gradle-plugin:1.3.pom和android-maven-gradle-plugin:1.3.jar

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.