Giter Site home page Giter Site logo

croputils's Introduction

CropUtils

对ucrop的封装工具类,让其使用更加快捷.

在ucrop 2.1.2(compile 'com.yalantis:ucrop:2.1.2')基础上封装,

如果以后ucrop以后升级,那么本工具类只需要改CropConfig里字段就可以.其他透明.

甚至,切换其他图片裁剪框架,也是改方法内部实现即可,不用更换各处已调用的api.

uCrop主项目地址

效果图(标题栏和状态栏颜色均可自定义)

通用裁剪界面

normalCrop

头像裁剪框

avatarcrop

封装的api

public static void pickFromGallery(Activity context)//

public static void pickFromCamera(Activity context)

public static void pickAvatarFromGallery(Activity context)//从图库中选头像

public static void pickAvatarFromCamera(Activity context)

public static void pickFromGallery(Activity context,CropConfig config,int type)
//需要自定义设置时使用

public static void handleResult(Activity context, CropHandler cropHandler, int requestCode, int resultCode, Intent data)

public interface CropHandler {
        void handleCropResult(Uri uri,int tag);
        void handleCropError(Intent data);
    }

使用

点击选择图片或拍照的地方调用pickxxx

实现CropHandler接口

在activity的onActivityResult里调用CropUtils.handleResult(this,cropHandler,requestCode,resultCode,data);.注意无需预先对intent做为空的判断.

tag字段用于同一个页面多个地方接收裁剪图片的区分,如无需要,不必设置.

相关

本工具类介绍blog地址

图片加载框架Fresco的封装工具类FrescoUtils

croputils's People

Contributors

hss01248 avatar

Watchers

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