Code Monkey home page Code Monkey logo

galleryfinal's Introduction

GalleryFinal简介

Android自定义相册,实现了拍照、图片选择(单选/多选)、裁剪(单/多裁剪)、旋转、缩放、ImageLoader无绑定任由开发者选择

#GalleryFinal intro GalleryFinal is an Android custom gallery.It can take photo,choose and clip pictures(single/multiple),rotate,zoom,ImageLoader unbinding

##为什么要使用GalleryFinal?

  • 拍照/选择图片倒立问题
  • 市场上各种相机和图片浏览器泛滥导致各种异常问题
  • 各种手机兼容性问题引起crash
  • 系统Gallery App不能进行多选
  • 系统拍照/选择图片/裁剪视乎不太好用
  • 系统Gallery App不美观
  • ……

Why GalleryFinal?

  • GalleryFinal solved the "photos are upside down" problem
  • GalleryFinal solved some Exceptions cause of different camera and image explorer not compatible
  • GalleryFinal solved some crash due to different cellphone adapted
  • The System Gallery cannot do multiple choice
  • The System camera/gallery/slip didn't work well
  • The System Gallery is not smart

##V1.2.0更新内容

  • 提高图片清晰度
  • 支持图片手动缩放
  • 解决权限问题
  • 优化图片旋转
  • 解决二次裁剪问题
  • 解决多次旋转后图片不清晰问题
  • 添加图片选择过滤
  • 添加清理缓存
  • 提高体验效果和修改UI

##截图展示 Demo apk二维码地址: DEMO APK

#GalleryFinal使用方法

##下载GalleryFinal 通过Gradle抓取:

compile 'cn.finalteam:galleryfinal:1.2.0'

##具体使用 1、通过gradle把GalleryFinal添加到你的项目里

2、选择图片加载器

  • UIL
public class UILImageLoader implements cn.finalteam.galleryfinal.ImageLoader {

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        ImageSize size = new ImageSize(width, height);
        ImageLoader.getInstance().displayImage("file://" + path, imageView, size);
    }

    @Override
    public void clearMemoryCache() {
    }
}
  • Glide
public class GlideImageLoader implements cn.finalteam.galleryfinal.ImageLoader {

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        Glide.with(activity)
                .load("file://" + path)
                .placeholder(cn.finalteam.galleryfinal.R.drawable.ic_gf_default_photo)
                .error(cn.finalteam.galleryfinal.R.drawable.ic_gf_default_photo)
                .diskCacheStrategy(DiskCacheStrategy.NONE) //不缓存到SD卡
                .skipMemoryCache(true)
                //.centerCrop()
                .into(imageView);
    }

    @Override
    public void clearMemoryCache() {
    }
}
  • Picasso
public class PicassoImageLoader implements cn.finalteam.galleryfinal.ImageLoader {

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        Picasso.with(activity)
                .load(new File(path))
                .placeholder(cn.finalteam.galleryfinal.R.drawable.ic_gf_default_photo)
                .error(cn.finalteam.galleryfinal.R.drawable.ic_gf_default_photo)
                .resize(width, height)
                .centerInside()
                .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
                .into(imageView);
    }

    @Override
    public void clearMemoryCache() {
    }
}
  • xUtils3
public class XUtils3ImageLoader implements cn.finalteam.galleryfinal.ImageLoader {
    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        ImageOptions options = new ImageOptions.Builder()
                .setLoadingDrawableId(cn.finalteam.galleryfinal.R.drawable.ic_gf_default_photo)
                .setFailureDrawableId(cn.finalteam.galleryfinal.R.drawable.ic_gf_default_photo)
                .setConfig(Bitmap.Config.RGB_565)
                .setSize(width, height)
                .setCrop(true)
                .setUseMemCache(false)
                .build();
        x.image().bind(imageView, "file://" + path, options);
    }

    @Override
    public void clearMemoryCache() {
    }
}
  • xUitls
public class XUtilsImageLoader implements cn.finalteam.galleryfinal.ImageLoader {

    private BitmapUtils bitmapUtils;
    private Drawable defaultImage;

    public XUtilsImageLoader(Context context) {
        bitmapUtils = new BitmapUtils(context);
        defaultImage = context.getResources().getDrawable(cn.finalteam.galleryfinal.R.drawable.ic_gf_default_photo);
    }

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        BitmapDisplayConfig config = new BitmapDisplayConfig();
        config.setLoadFailedDrawable(defaultImage);
        config.setLoadingDrawable(defaultImage);
        config.setBitmapConfig(Bitmap.Config.RGB_565);
        config.setBitmapMaxSize(new BitmapSize(width, height));
        bitmapUtils.display(imageView, "file://" + path, config);
    }

    @Override
    public void clearMemoryCache() {
    }
}
  • ……

3、打开Gallery

GalleryConfig config = new GalleryConfig.Builder(MainActivity.this)
                        .mutiSelect()
                        .mutiSelectMaxSize(8)
                        .enableEdit()
                        .enableCrop()
                        .enableRotate()
                        .showCamera()
                        .imageloader(new UILImageLoader())
                        .cropSquare()
                        .cropWidth(50)
                        .cropHeight(50)
                        .filter(mPhotoList)
                        .build();
GalleryFinal.open(config);

4、配置GalleryFinal Activity样式

  • 在styles.xml中添加
    <style name="PhotoActivityTheme">
        <item name="colorTheme">@color/colorPrimary</item>
        <item name="colorThemeDark">@color/colorPrimaryDark</item>
    </style>

colorTheme为主题色,colorThemeDark为主题加深色

5、如果你还想更深度的定制页面效果可以把资源文件名字定义成Gallery资源名已达到覆盖效果。如有不理解可以联系我。

#混淆配置

-keep class cn.finalteam.galleryfinal.widget.*{*;}
-keep class cn.finalteam.galleryfinal.widget.crop.*{*;}

#更新日志

##V1.2.0

  • 提高图片清晰度
  • 支持图片手动缩放
  • fix权限问题
  • 优化图片旋转
  • fix二次裁剪问题
  • fix多次旋转后图片不清晰问题
  • 添加图片选择过滤
  • 添加清理缓存
  • 提高体验效果和修改UI

##V1.1.0

  • UI重改
  • 多选图片裁剪
  • 所有功能可配置
  • 优化图片裁剪
  • 解决OOM情况
  • 图片手动选择
  • 支持汉语和英语

#关于作者

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

galleryfinal's People

Contributors

pengjianbo avatar

Watchers

 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.