fix #18 by update ImageSelector’s version
@@ -104,7 +104,7 @@ dependencies {
|
||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||
compile 'jp.wasabeef:glide-transformations:2.0.1'
|
||||
compile 'com.android.support:support-v13:24.1.0'
|
||||
compile project(':img-selector')
|
||||
compile 'com.yuyh.imgsel:library:1.3.2'
|
||||
compile 'com.facebook.stetho:stetho:1.4.1'
|
||||
compile 'com.github.houxg:FlexLayout:1.2'
|
||||
|
||||
|
||||
@@ -170,7 +170,9 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
|
||||
|
||||
@OnClick(R.id.btn_img)
|
||||
void handleInsertImage() {
|
||||
//TODO: request camera permission
|
||||
ImgSelConfig config = new ImgSelConfig.Builder(
|
||||
getActivity(),
|
||||
new com.yuyh.library.imgsel.ImageLoader() {
|
||||
@Override
|
||||
public void displayImage(Context context, String path, ImageView imageView) {
|
||||
|
||||
1
img-selector/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,35 +0,0 @@
|
||||
apply plugin: 'com.android.library'
|
||||
version = "1.2.0" // 版本号
|
||||
|
||||
android {
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion '25.0.1'
|
||||
resourcePrefix "imgsel"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 23
|
||||
versionCode 7
|
||||
versionName "1.2.0"
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:23.4.0'
|
||||
compile 'com.android.support:support-v4:23.4.0'
|
||||
compile 'com.android.support:recyclerview-v7:23.4.0'
|
||||
|
||||
compile 'com.yuyh.easyadapter:library:1.0.0'
|
||||
}
|
||||
17
img-selector/proguard-rules.pro
vendored
@@ -1,17 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in D:\AndroidDev\sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.yuyh.library.imgsel">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true">
|
||||
<activity
|
||||
android:name=".ImgSelActivity"
|
||||
android:theme="@style/SelTheme" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.yuyh.library.imgsel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/8/5.
|
||||
*/
|
||||
public interface ImageLoader extends Serializable {
|
||||
void displayImage(Context context, String path, ImageView imageView);
|
||||
}
|
||||
@@ -1,240 +0,0 @@
|
||||
package com.yuyh.library.imgsel;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.yuyh.library.imgsel.common.Callback;
|
||||
import com.yuyh.library.imgsel.common.Constant;
|
||||
import com.yuyh.library.imgsel.utils.FileUtils;
|
||||
import com.yuyh.library.imgsel.utils.StatusBarCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ImgSelActivity extends FragmentActivity implements View.OnClickListener, Callback {
|
||||
|
||||
public static final String INTENT_RESULT = "result";
|
||||
private static final int IMAGE_CROP_CODE = 1;
|
||||
private static final int STORAGE_REQUEST_CODE = 1;
|
||||
|
||||
private ImgSelConfig config;
|
||||
|
||||
private RelativeLayout rlTitleBar;
|
||||
private TextView tvTitle;
|
||||
private Button btnConfirm;
|
||||
private ImageView ivBack;
|
||||
private String cropImagePath;
|
||||
|
||||
private ImgSelFragment fragment;
|
||||
|
||||
private ArrayList<String> result = new ArrayList<>();
|
||||
|
||||
public static void startActivity(Activity activity, ImgSelConfig config, int RequestCode) {
|
||||
Intent intent = new Intent(activity, ImgSelActivity.class);
|
||||
Constant.config = config;
|
||||
activity.startActivityForResult(intent, RequestCode);
|
||||
}
|
||||
|
||||
public static void startActivity(Fragment fragment, ImgSelConfig config, int RequestCode) {
|
||||
Intent intent = new Intent(fragment.getActivity(), ImgSelActivity.class);
|
||||
Constant.config = config;
|
||||
fragment.startActivityForResult(intent, RequestCode);
|
||||
}
|
||||
|
||||
public static void startActivity(android.app.Fragment fragment, ImgSelConfig config, int RequestCode) {
|
||||
Intent intent = new Intent(fragment.getActivity(), ImgSelActivity.class);
|
||||
Constant.config = config;
|
||||
fragment.startActivityForResult(intent, RequestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_img_sel);
|
||||
Constant.imageList.clear();
|
||||
config = Constant.config;
|
||||
|
||||
// Android 6.0 checkSelfPermission
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
fragment = ImgSelFragment.instance();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.fmImageList, fragment, null)
|
||||
.commit();
|
||||
}
|
||||
|
||||
initView();
|
||||
if (!FileUtils.isSdCardAvailable()) {
|
||||
Toast.makeText(this, getString(R.string.sd_disable), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
rlTitleBar = (RelativeLayout) findViewById(R.id.rlTitleBar);
|
||||
tvTitle = (TextView) findViewById(R.id.tvTitle);
|
||||
|
||||
btnConfirm = (Button) findViewById(R.id.btnConfirm);
|
||||
btnConfirm.setOnClickListener(this);
|
||||
|
||||
ivBack = (ImageView) findViewById(R.id.ivBack);
|
||||
ivBack.setOnClickListener(this);
|
||||
|
||||
if (config != null) {
|
||||
if (config.backResId != -1) {
|
||||
ivBack.setImageResource(config.backResId);
|
||||
}
|
||||
|
||||
if (config.statusBarColor != -1) {
|
||||
StatusBarCompat.compat(this, config.statusBarColor);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
|
||||
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
}
|
||||
rlTitleBar.setBackgroundColor(config.titleBgColor);
|
||||
tvTitle.setTextColor(config.titleColor);
|
||||
tvTitle.setText(config.title);
|
||||
btnConfirm.setBackgroundColor(config.btnBgColor);
|
||||
btnConfirm.setTextColor(config.btnTextColor);
|
||||
if (config.multiSelect) {
|
||||
btnConfirm.setText(String.format(getString(R.string.confirm), Constant.imageList.size(), config.maxNum));
|
||||
} else {
|
||||
btnConfirm.setText(getString(R.string.confirm_single));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.btnConfirm) {
|
||||
if (Constant.imageList != null && !Constant.imageList.isEmpty()) {
|
||||
exit();
|
||||
}
|
||||
} else if (id == R.id.ivBack) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSingleImageSelected(String path) {
|
||||
if (config.needCrop) {
|
||||
crop(path);
|
||||
} else {
|
||||
Constant.imageList.add(path);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onImageSelected(String path) {
|
||||
btnConfirm.setText(String.format(getString(R.string.confirm), Constant.imageList.size(), config.maxNum));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onImageUnselected(String path) {
|
||||
btnConfirm.setText(String.format(getString(R.string.confirm), Constant.imageList.size(), config.maxNum));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraShot(File imageFile) {
|
||||
if (imageFile != null) {
|
||||
if (config.needCrop) {
|
||||
crop(imageFile.getAbsolutePath());
|
||||
} else {
|
||||
Constant.imageList.add(imageFile.getAbsolutePath());
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreviewChanged(int select, int sum, boolean visible) {
|
||||
if (visible) {
|
||||
tvTitle.setText(select + "/" + sum);
|
||||
} else {
|
||||
tvTitle.setText(config.title);
|
||||
}
|
||||
}
|
||||
|
||||
private void crop(String imagePath) {
|
||||
File file = new File(FileUtils.createRootPath(this) + "/" + System.currentTimeMillis() + ".jpg");
|
||||
|
||||
cropImagePath = file.getAbsolutePath();
|
||||
Intent intent = new Intent("com.android.camera.action.CROP");
|
||||
intent.setDataAndType(Uri.fromFile(new File(imagePath)), "image/*");
|
||||
intent.putExtra("crop", "true");
|
||||
intent.putExtra("aspectX", config.aspectX);
|
||||
intent.putExtra("aspectY", config.aspectY);
|
||||
intent.putExtra("outputX", config.outputX);
|
||||
intent.putExtra("outputY", config.outputY);
|
||||
intent.putExtra("return-data", false);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
|
||||
startActivityForResult(intent, IMAGE_CROP_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == IMAGE_CROP_CODE && resultCode == RESULT_OK) {
|
||||
Constant.imageList.add(cropImagePath);
|
||||
exit();
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
Intent intent = new Intent();
|
||||
result.clear();
|
||||
result.addAll(Constant.imageList);
|
||||
intent.putStringArrayListExtra(INTENT_RESULT, result);
|
||||
setResult(RESULT_OK, intent);
|
||||
Constant.imageList.clear();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
switch (requestCode) {
|
||||
case STORAGE_REQUEST_CODE:
|
||||
if (grantResults.length >= 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.fmImageList, ImgSelFragment.instance(), null)
|
||||
.commitAllowingStateLoss();
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.permission_denied), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!fragment.hidePreview())
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
package com.yuyh.library.imgsel;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.yuyh.library.imgsel.utils.FileUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/8/5.
|
||||
*/
|
||||
public class ImgSelConfig {
|
||||
|
||||
/**
|
||||
* 是否需要裁剪
|
||||
*/
|
||||
public boolean needCrop;
|
||||
|
||||
/**
|
||||
* 是否多选
|
||||
*/
|
||||
public boolean multiSelect;
|
||||
|
||||
/**
|
||||
* 最多选择图片数
|
||||
*/
|
||||
public int maxNum = 9;
|
||||
|
||||
/**
|
||||
* 第一个item是否显示相机
|
||||
*/
|
||||
public boolean needCamera;
|
||||
|
||||
public int statusBarColor = -1;
|
||||
|
||||
/**
|
||||
* 返回图标资源
|
||||
*/
|
||||
public int backResId = -1;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
public String title;
|
||||
|
||||
/**
|
||||
* 标题颜色
|
||||
*/
|
||||
public int titleColor;
|
||||
|
||||
/**
|
||||
* titlebar背景色
|
||||
*/
|
||||
public int titleBgColor;
|
||||
|
||||
/**
|
||||
* 确定按钮文字颜色
|
||||
*/
|
||||
public int btnTextColor;
|
||||
|
||||
/**
|
||||
* 确定按钮背景色
|
||||
*/
|
||||
public int btnBgColor;
|
||||
|
||||
/**
|
||||
* 拍照存储路径
|
||||
*/
|
||||
public String filePath;
|
||||
|
||||
/**
|
||||
* 自定义图片加载器
|
||||
*/
|
||||
public ImageLoader loader;
|
||||
|
||||
/**
|
||||
* 裁剪输出大小
|
||||
*/
|
||||
public int aspectX = 1;
|
||||
public int aspectY = 1;
|
||||
public int outputX = 500;
|
||||
public int outputY = 500;
|
||||
|
||||
public ImgSelConfig(Builder builder) {
|
||||
this.needCrop = builder.needCrop;
|
||||
this.multiSelect = builder.multiSelect;
|
||||
this.maxNum = builder.maxNum;
|
||||
this.needCamera = builder.needCamera;
|
||||
this.statusBarColor = builder.statusBarColor;
|
||||
this.backResId = builder.backResId;
|
||||
this.title = builder.title;
|
||||
this.titleBgColor = builder.titleBgColor;
|
||||
this.titleColor = builder.titleColor;
|
||||
this.btnBgColor = builder.btnBgColor;
|
||||
this.btnTextColor = builder.btnTextColor;
|
||||
this.filePath = builder.filePath;
|
||||
this.loader = builder.loader;
|
||||
this.aspectX = builder.aspectX;
|
||||
this.aspectY = builder.aspectY;
|
||||
this.outputX = builder.outputX;
|
||||
this.outputY = builder.outputY;
|
||||
}
|
||||
|
||||
public static class Builder implements Serializable {
|
||||
|
||||
private boolean needCrop = false;
|
||||
private boolean multiSelect = true;
|
||||
private int maxNum = 9;
|
||||
private boolean needCamera = true;
|
||||
public int statusBarColor = -1;
|
||||
private int backResId = -1;
|
||||
private String title;
|
||||
private int titleColor;
|
||||
private int titleBgColor;
|
||||
private int btnTextColor;
|
||||
private int btnBgColor;
|
||||
private String filePath;
|
||||
private ImageLoader loader;
|
||||
|
||||
private int aspectX = 1;
|
||||
private int aspectY = 1;
|
||||
private int outputX = 400;
|
||||
private int outputY = 400;
|
||||
|
||||
public Builder(ImageLoader loader) {
|
||||
this.loader = loader;
|
||||
|
||||
if (FileUtils.isSdCardAvailable())
|
||||
filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Camera";
|
||||
else
|
||||
filePath = Environment.getRootDirectory().getAbsolutePath() + "/Camera";
|
||||
|
||||
title = "图片";
|
||||
titleBgColor = Color.parseColor("#3F51B5");
|
||||
titleColor = Color.WHITE;
|
||||
|
||||
btnBgColor = Color.TRANSPARENT;
|
||||
btnTextColor = Color.WHITE;
|
||||
|
||||
FileUtils.createDir(filePath);
|
||||
}
|
||||
|
||||
public Builder needCrop(boolean needCrop) {
|
||||
this.needCrop = needCrop;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder multiSelect(boolean multiSelect) {
|
||||
this.multiSelect = multiSelect;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder maxNum(int maxNum) {
|
||||
this.maxNum = maxNum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder needCamera(boolean needCamera) {
|
||||
this.needCamera = needCamera;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder statusBarColor(int statusBarColor) {
|
||||
this.statusBarColor = statusBarColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder backResId(int backResId) {
|
||||
this.backResId = backResId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder titleColor(int titleColor) {
|
||||
this.titleColor = titleColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder titleBgColor(int titleBgColor) {
|
||||
this.titleBgColor = titleBgColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder btnTextColor(int btnTextColor) {
|
||||
this.btnTextColor = btnTextColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder btnBgColor(int btnBgColor) {
|
||||
this.btnBgColor = btnBgColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
private Builder filePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder cropSize(int aspectX, int aspectY, int outputX, int outputY) {
|
||||
this.aspectX = aspectX;
|
||||
this.aspectY = aspectY;
|
||||
this.outputX = outputX;
|
||||
this.outputY = outputY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ImgSelConfig build() {
|
||||
return new ImgSelConfig(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,373 +0,0 @@
|
||||
package com.yuyh.library.imgsel;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.ListPopupWindow;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.yuyh.library.imgsel.adapter.FolderListAdapter;
|
||||
import com.yuyh.library.imgsel.adapter.ImageListAdapter;
|
||||
import com.yuyh.library.imgsel.adapter.PreviewAdapter;
|
||||
import com.yuyh.library.imgsel.bean.Folder;
|
||||
import com.yuyh.library.imgsel.bean.Image;
|
||||
import com.yuyh.library.imgsel.common.Callback;
|
||||
import com.yuyh.library.imgsel.common.Constant;
|
||||
import com.yuyh.library.imgsel.common.OnFolderChangeListener;
|
||||
import com.yuyh.library.imgsel.common.OnItemClickListener;
|
||||
import com.yuyh.library.imgsel.utils.FileUtils;
|
||||
import com.yuyh.library.imgsel.utils.LogUtils;
|
||||
import com.yuyh.library.imgsel.widget.CustomViewPager;
|
||||
import com.yuyh.library.imgsel.widget.DividerGridItemDecoration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ImgSelFragment extends Fragment implements View.OnClickListener, ViewPager.OnPageChangeListener {
|
||||
|
||||
private RecyclerView rvImageList;
|
||||
private Button btnAlbumSelected;
|
||||
private View rlBottom;
|
||||
private CustomViewPager viewPager;
|
||||
|
||||
private ImgSelConfig config;
|
||||
private Callback callback;
|
||||
private List<Folder> folderList = new ArrayList<>();
|
||||
private List<Image> imageList = new ArrayList<>();
|
||||
|
||||
private ListPopupWindow folderPopupWindow;
|
||||
private ImageListAdapter imageListAdapter;
|
||||
private FolderListAdapter folderListAdapter;
|
||||
private PreviewAdapter previewAdapter;
|
||||
|
||||
private boolean hasFolderGened = false;
|
||||
private static final int LOADER_ALL = 0;
|
||||
private static final int LOADER_CATEGORY = 1;
|
||||
private static final int REQUEST_CAMERA = 5;
|
||||
|
||||
private File tempFile;
|
||||
|
||||
public static ImgSelFragment instance() {
|
||||
ImgSelFragment fragment = new ImgSelFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_img_sel, container, false);
|
||||
rvImageList = (RecyclerView) view.findViewById(R.id.rvImageList);
|
||||
btnAlbumSelected = (Button) view.findViewById(R.id.btnAlbumSelected);
|
||||
btnAlbumSelected.setOnClickListener(this);
|
||||
rlBottom = view.findViewById(R.id.rlBottom);
|
||||
viewPager = (CustomViewPager) view.findViewById(R.id.viewPager);
|
||||
viewPager.addOnPageChangeListener(this);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
config = Constant.config;
|
||||
try {
|
||||
callback = (Callback) getActivity();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
rvImageList.setLayoutManager(new GridLayoutManager(rvImageList.getContext(), 3));
|
||||
rvImageList.addItemDecoration(new DividerGridItemDecoration(rvImageList.getContext()));
|
||||
if (config.needCamera)
|
||||
imageList.add(new Image());
|
||||
|
||||
imageListAdapter = new ImageListAdapter(getActivity(), imageList, config);
|
||||
imageListAdapter.setShowCamera(config.needCamera);
|
||||
imageListAdapter.setMutiSelect(config.multiSelect);
|
||||
rvImageList.setAdapter(imageListAdapter);
|
||||
imageListAdapter.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public int onCheckedClick(int position, Image image) {
|
||||
return checkedImage(position, image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onImageClick(int position, Image image) {
|
||||
if (config.needCamera && position == 0) {
|
||||
showCameraAction();
|
||||
} else {
|
||||
if (config.multiSelect) {
|
||||
viewPager.setAdapter((previewAdapter = new PreviewAdapter(getActivity(), imageList, config)));
|
||||
previewAdapter.setListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public int onCheckedClick(int position, Image image) {
|
||||
return checkedImage(position, image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onImageClick(int position, Image image) {
|
||||
hidePreview();
|
||||
}
|
||||
});
|
||||
if (config.needCamera) {
|
||||
callback.onPreviewChanged(position, imageList.size() - 1, true);
|
||||
} else {
|
||||
callback.onPreviewChanged(position + 1, imageList.size(), true);
|
||||
}
|
||||
viewPager.setCurrentItem(config.needCamera ? position - 1 : position);
|
||||
viewPager.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (callback != null) {
|
||||
callback.onSingleImageSelected(image.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
folderListAdapter = new FolderListAdapter(getActivity(), folderList, config);
|
||||
|
||||
getActivity().getSupportLoaderManager().initLoader(LOADER_ALL, null, mLoaderCallback);
|
||||
}
|
||||
|
||||
private int checkedImage(int position, Image image) {
|
||||
if (image != null) {
|
||||
if (Constant.imageList.contains(image.path)) {
|
||||
Constant.imageList.remove(image.path);
|
||||
if (callback != null) {
|
||||
callback.onImageUnselected(image.path);
|
||||
}
|
||||
} else {
|
||||
if (config.maxNum <= Constant.imageList.size()) {
|
||||
Toast.makeText(getActivity(), String.format(getString(R.string.maxnum), config.maxNum), Toast.LENGTH_SHORT).show();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Constant.imageList.add(image.path);
|
||||
if (callback != null) {
|
||||
callback.onImageSelected(image.path);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private LoaderManager.LoaderCallbacks<Cursor> mLoaderCallback = new LoaderManager.LoaderCallbacks<Cursor>() {
|
||||
|
||||
private final String[] IMAGE_PROJECTION = {
|
||||
MediaStore.Images.Media.DATA,
|
||||
MediaStore.Images.Media.DISPLAY_NAME,
|
||||
MediaStore.Images.Media.DATE_ADDED,
|
||||
MediaStore.Images.Media._ID};
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
if (id == LOADER_ALL) {
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(),
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_PROJECTION,
|
||||
null, null, IMAGE_PROJECTION[2] + " DESC");
|
||||
return cursorLoader;
|
||||
} else if (id == LOADER_CATEGORY) {
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(),
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_PROJECTION,
|
||||
IMAGE_PROJECTION[0] + " like '%" + args.getString("path") + "%'", null, IMAGE_PROJECTION[2] + " DESC");
|
||||
return cursorLoader;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
if (data != null) {
|
||||
int count = data.getCount();
|
||||
if (count > 0) {
|
||||
List<Image> tempImageList = new ArrayList<>();
|
||||
data.moveToFirst();
|
||||
do {
|
||||
String path = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[0]));
|
||||
String name = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[1]));
|
||||
long dateTime = data.getLong(data.getColumnIndexOrThrow(IMAGE_PROJECTION[2]));
|
||||
Image image = new Image(path, name, dateTime);
|
||||
if (!image.path.endsWith("gif"))
|
||||
tempImageList.add(image);
|
||||
if (!hasFolderGened) {
|
||||
File imageFile = new File(path);
|
||||
File folderFile = imageFile.getParentFile();
|
||||
Folder folder = new Folder();
|
||||
folder.name = folderFile.getName();
|
||||
folder.path = folderFile.getAbsolutePath();
|
||||
folder.cover = image;
|
||||
if (!folderList.contains(folder)) {
|
||||
List<Image> imageList = new ArrayList<>();
|
||||
imageList.add(image);
|
||||
folder.images = imageList;
|
||||
folderList.add(folder);
|
||||
} else {
|
||||
Folder f = folderList.get(folderList.indexOf(folder));
|
||||
f.images.add(image);
|
||||
}
|
||||
}
|
||||
|
||||
} while (data.moveToNext());
|
||||
|
||||
imageList.clear();
|
||||
if (config.needCamera)
|
||||
imageList.add(new Image());
|
||||
imageList.addAll(tempImageList);
|
||||
|
||||
|
||||
imageListAdapter.notifyDataSetChanged();
|
||||
|
||||
if (Constant.imageList != null && Constant.imageList.size() > 0) {
|
||||
//adapter.setDefaultSelected(resultList);
|
||||
}
|
||||
|
||||
folderListAdapter.notifyDataSetChanged();
|
||||
|
||||
hasFolderGened = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private void createPopupFolderList(int width, int height) {
|
||||
folderPopupWindow = new ListPopupWindow(getActivity());
|
||||
folderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
folderPopupWindow.setAdapter(folderListAdapter);
|
||||
folderPopupWindow.setContentWidth(width);
|
||||
folderPopupWindow.setWidth(width);
|
||||
folderPopupWindow.setHeight(height);
|
||||
folderPopupWindow.setAnchorView(rlBottom);
|
||||
folderPopupWindow.setModal(true);
|
||||
folderListAdapter.setOnFloderChangeListener(new OnFolderChangeListener() {
|
||||
@Override
|
||||
public void onChange(int position, Folder folder) {
|
||||
folderPopupWindow.dismiss();
|
||||
if (position == 0) {
|
||||
getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
|
||||
btnAlbumSelected.setText(getString(R.string.all_images));
|
||||
} else {
|
||||
imageList.clear();
|
||||
if (config.needCamera)
|
||||
imageList.add(new Image());
|
||||
imageList.addAll(folder.images);
|
||||
imageListAdapter.notifyDataSetChanged();
|
||||
|
||||
btnAlbumSelected.setText(folder.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == btnAlbumSelected.getId()) {
|
||||
if (folderPopupWindow == null) {
|
||||
WindowManager wm = getActivity().getWindowManager();
|
||||
int width = wm.getDefaultDisplay().getWidth();
|
||||
createPopupFolderList(width / 3 * 2, width / 3 * 2);
|
||||
}
|
||||
|
||||
if (folderPopupWindow.isShowing()) {
|
||||
folderPopupWindow.dismiss();
|
||||
} else {
|
||||
folderPopupWindow.show();
|
||||
int index = folderListAdapter.getSelectIndex();
|
||||
index = index == 0 ? index : index - 1;
|
||||
folderPopupWindow.getListView().setSelection(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showCameraAction() {
|
||||
if (config.maxNum <= Constant.imageList.size()) {
|
||||
Toast.makeText(getActivity(), String.format(getString(R.string.maxnum), config.maxNum), Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
if (cameraIntent.resolveActivity(getActivity().getPackageManager()) != null) {
|
||||
tempFile = new File(FileUtils.createRootPath(getActivity()) + "/" + System.currentTimeMillis() + ".jpg");
|
||||
LogUtils.e(tempFile.getAbsolutePath());
|
||||
FileUtils.createFile(tempFile);
|
||||
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
|
||||
startActivityForResult(cameraIntent, REQUEST_CAMERA);
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getString(R.string.open_camera_failure), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_CAMERA) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (tempFile != null) {
|
||||
if (callback != null) {
|
||||
callback.onCameraShot(tempFile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (tempFile != null && tempFile.exists()) {
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
if (config.needCamera) {
|
||||
callback.onPreviewChanged(position + 1, imageList.size() - 1, true);
|
||||
} else {
|
||||
callback.onPreviewChanged(position + 1, imageList.size(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
|
||||
public boolean hidePreview() {
|
||||
if (viewPager.getVisibility() == View.VISIBLE) {
|
||||
viewPager.setVisibility(View.GONE);
|
||||
callback.onPreviewChanged(0, 0, false);
|
||||
imageListAdapter.notifyDataSetChanged();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package com.yuyh.library.imgsel.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.yuyh.easyadapter.abslistview.EasyLVAdapter;
|
||||
import com.yuyh.easyadapter.abslistview.EasyLVHolder;
|
||||
import com.yuyh.library.imgsel.ImgSelConfig;
|
||||
import com.yuyh.library.imgsel.R;
|
||||
import com.yuyh.library.imgsel.bean.Folder;
|
||||
import com.yuyh.library.imgsel.common.OnFolderChangeListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/8/5.
|
||||
*/
|
||||
public class FolderListAdapter extends EasyLVAdapter<Folder> {
|
||||
|
||||
private Context context;
|
||||
private List<Folder> folderList;
|
||||
private ImgSelConfig config;
|
||||
|
||||
private int selected = 0;
|
||||
private OnFolderChangeListener listener;
|
||||
|
||||
public FolderListAdapter(Context context, List<Folder> folderList, ImgSelConfig config) {
|
||||
super(context, folderList, R.layout.item_img_sel_folder);
|
||||
this.context = context;
|
||||
this.folderList = folderList;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(EasyLVHolder holder, final int position, Folder folder) {
|
||||
if (position == 0) {
|
||||
holder.setText(R.id.tvFolderName, "所有图片")
|
||||
.setText(R.id.tvImageNum, "共" + getTotalImageSize() + "张");
|
||||
ImageView ivFolder = holder.getView(R.id.ivFolder);
|
||||
if (folderList.size() > 0) {
|
||||
config.loader.displayImage(context, folder.cover.path, ivFolder);
|
||||
}
|
||||
} else {
|
||||
holder.setText(R.id.tvFolderName, folder.name)
|
||||
.setText(R.id.tvImageNum, "共" + folder.images.size() + "张");
|
||||
ImageView ivFolder = holder.getView(R.id.ivFolder);
|
||||
if (folderList.size() > 0) {
|
||||
config.loader.displayImage(context, folder.cover.path, ivFolder);
|
||||
}
|
||||
}
|
||||
|
||||
if (selected == position) {
|
||||
holder.setVisible(R.id.indicator, true);
|
||||
} else {
|
||||
holder.setVisible(R.id.indicator, false);
|
||||
}
|
||||
|
||||
holder.getConvertView().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setSelectIndex(position);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setData(List<Folder> folders) {
|
||||
folderList.clear();
|
||||
if (folders != null && folders.size() > 0) {
|
||||
folderList.addAll(folders);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private int getTotalImageSize() {
|
||||
int result = 0;
|
||||
if (folderList != null && folderList.size() > 0) {
|
||||
for (Folder folder : folderList) {
|
||||
result += folder.images.size();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setSelectIndex(int position) {
|
||||
if (selected == position)
|
||||
return;
|
||||
if(listener != null)
|
||||
listener.onChange(position, folderList.get(position));
|
||||
selected = position;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int getSelectIndex() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setOnFloderChangeListener(OnFolderChangeListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package com.yuyh.library.imgsel.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.yuyh.easyadapter.recyclerview.EasyRVAdapter;
|
||||
import com.yuyh.easyadapter.recyclerview.EasyRVHolder;
|
||||
import com.yuyh.library.imgsel.ImgSelConfig;
|
||||
import com.yuyh.library.imgsel.R;
|
||||
import com.yuyh.library.imgsel.bean.Image;
|
||||
import com.yuyh.library.imgsel.common.Constant;
|
||||
import com.yuyh.library.imgsel.common.OnItemClickListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/8/5.
|
||||
*/
|
||||
public class ImageListAdapter extends EasyRVAdapter<Image> {
|
||||
|
||||
private boolean showCamera;
|
||||
private boolean mutiSelect;
|
||||
|
||||
private ImgSelConfig config;
|
||||
private Context context;
|
||||
private OnItemClickListener listener;
|
||||
|
||||
public ImageListAdapter(Context context, List<Image> list, ImgSelConfig config) {
|
||||
super(context, list, R.layout.item_img_sel, R.layout.item_img_sel_take_photo);
|
||||
this.context = context;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindData(final EasyRVHolder viewHolder, final int position, final Image item) {
|
||||
|
||||
if (position == 0 && showCamera) {
|
||||
ImageView iv = viewHolder.getView(R.id.ivTakePhoto);
|
||||
iv.setImageResource(R.drawable.ic_take_photo);
|
||||
iv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null)
|
||||
listener.onImageClick(position, item);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (mutiSelect) {
|
||||
viewHolder.getView(R.id.ivPhotoCheaked).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
int ret = listener.onCheckedClick(position, item);
|
||||
if (ret == 1) { // 局部刷新
|
||||
if (Constant.imageList.contains(item.path)) {
|
||||
viewHolder.setImageResource(R.id.ivPhotoCheaked, R.drawable.ic_checked);
|
||||
} else {
|
||||
viewHolder.setImageResource(R.id.ivPhotoCheaked, R.drawable.ic_uncheck);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
viewHolder.setOnItemViewClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null)
|
||||
listener.onImageClick(position, item);
|
||||
}
|
||||
});
|
||||
|
||||
final ImageView iv = viewHolder.getView(R.id.ivImage);
|
||||
config.loader.displayImage(context, item.path, iv);
|
||||
|
||||
if (mutiSelect) {
|
||||
viewHolder.setVisible(R.id.ivPhotoCheaked, true);
|
||||
if (Constant.imageList.contains(item.path)) {
|
||||
viewHolder.setImageResource(R.id.ivPhotoCheaked, R.drawable.ic_checked);
|
||||
} else {
|
||||
viewHolder.setImageResource(R.id.ivPhotoCheaked, R.drawable.ic_uncheck);
|
||||
}
|
||||
} else {
|
||||
viewHolder.setVisible(R.id.ivPhotoCheaked, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setShowCamera(boolean showCamera) {
|
||||
this.showCamera = showCamera;
|
||||
}
|
||||
|
||||
public void setMutiSelect(boolean mutiSelect) {
|
||||
this.mutiSelect = mutiSelect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0 && showCamera) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.yuyh.library.imgsel.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.yuyh.library.imgsel.ImgSelConfig;
|
||||
import com.yuyh.library.imgsel.R;
|
||||
import com.yuyh.library.imgsel.bean.Image;
|
||||
import com.yuyh.library.imgsel.common.Constant;
|
||||
import com.yuyh.library.imgsel.common.OnItemClickListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/9/28.
|
||||
*/
|
||||
public class PreviewAdapter extends PagerAdapter {
|
||||
|
||||
private Activity activity;
|
||||
private List<Image> images;
|
||||
private ImgSelConfig config;
|
||||
private OnItemClickListener listener;
|
||||
|
||||
public PreviewAdapter(Activity activity, List<Image> images, ImgSelConfig config) {
|
||||
this.activity = activity;
|
||||
this.images = images;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (config.needCamera)
|
||||
return images.size() - 1;
|
||||
else
|
||||
return images.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View instantiateItem(ViewGroup container, final int position) {
|
||||
View root = View.inflate(activity, R.layout.item_pager_img_sel, null);
|
||||
final ImageView photoView = (ImageView) root.findViewById(R.id.ivImage);
|
||||
final ImageView ivChecked = (ImageView) root.findViewById(R.id.ivPhotoCheaked);
|
||||
|
||||
displayImage(photoView, images.get(config.needCamera ? position + 1 : position).path);
|
||||
if (config.multiSelect) {
|
||||
|
||||
ivChecked.setVisibility(View.VISIBLE);
|
||||
final Image image = images.get(config.needCamera ? position + 1 : position);
|
||||
if (Constant.imageList.contains(image.path)) {
|
||||
ivChecked.setImageResource(R.drawable.ic_checked);
|
||||
} else {
|
||||
ivChecked.setImageResource(R.drawable.ic_uncheck);
|
||||
}
|
||||
|
||||
ivChecked.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
int ret = listener.onCheckedClick(position, image);
|
||||
if (ret == 1) { // 局部刷新
|
||||
if (Constant.imageList.contains(image.path)) {
|
||||
ivChecked.setImageResource(R.drawable.ic_checked);
|
||||
} else {
|
||||
ivChecked.setImageResource(R.drawable.ic_uncheck);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
photoView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.onImageClick(position, images.get(position));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ivChecked.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
container.addView(root, ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
return root;
|
||||
}
|
||||
|
||||
private void displayImage(ImageView photoView, String path) {
|
||||
config.loader.displayImage(activity, path, photoView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
container.removeView((View) object);
|
||||
}
|
||||
|
||||
public void setListener(OnItemClickListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.yuyh.library.imgsel.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Folder bean
|
||||
* Created by Yancy on 2015/12/2.
|
||||
*/
|
||||
public class Folder {
|
||||
|
||||
public String name;
|
||||
public String path;
|
||||
public Image cover;
|
||||
public List<Image> images;
|
||||
|
||||
public boolean isAll = false;
|
||||
|
||||
public Folder(){
|
||||
|
||||
}
|
||||
|
||||
public Folder(boolean isAll){
|
||||
this.isAll = isAll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
try {
|
||||
Folder other = (Folder) o;
|
||||
return this.path.equalsIgnoreCase(other.path);
|
||||
} catch (ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return super.equals(o);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.yuyh.library.imgsel.bean;
|
||||
|
||||
/**
|
||||
* Image bean
|
||||
* Created by Yancy on 2015/12/2.
|
||||
*/
|
||||
public class Image {
|
||||
|
||||
public String path;
|
||||
public String name;
|
||||
public long time;
|
||||
|
||||
public boolean isCamera = false;
|
||||
|
||||
public Image(String path, String name, long time) {
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public Image(){
|
||||
isCamera = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
try {
|
||||
Image other = (Image) o;
|
||||
return this.path.equalsIgnoreCase(other.path);
|
||||
} catch (ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return super.equals(o);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.yuyh.library.imgsel.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/8/5.
|
||||
*/
|
||||
public interface Callback extends Serializable {
|
||||
|
||||
void onSingleImageSelected(String path);
|
||||
|
||||
void onImageSelected(String path);
|
||||
|
||||
void onImageUnselected(String path);
|
||||
|
||||
void onCameraShot(File imageFile);
|
||||
|
||||
void onPreviewChanged(int select, int sum, boolean visible);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.yuyh.library.imgsel.common;
|
||||
|
||||
import com.yuyh.library.imgsel.ImgSelConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/8/5.
|
||||
*/
|
||||
public class Constant {
|
||||
|
||||
public static ImgSelConfig config;
|
||||
|
||||
public static int screenWidth = 0;
|
||||
|
||||
public static ArrayList<String> imageList = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.yuyh.library.imgsel.common;
|
||||
|
||||
import com.yuyh.library.imgsel.bean.Folder;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/8/5.
|
||||
*/
|
||||
public interface OnFolderChangeListener {
|
||||
|
||||
void onChange(int position, Folder folder);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.yuyh.library.imgsel.common;
|
||||
|
||||
import com.yuyh.library.imgsel.bean.Image;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 2016/8/5.
|
||||
*/
|
||||
public interface OnItemClickListener {
|
||||
|
||||
int onCheckedClick(int position, Image image);
|
||||
|
||||
void onImageClick(int position, Image image);
|
||||
}
|
||||
@@ -1,306 +0,0 @@
|
||||
package com.yuyh.library.imgsel.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.os.Environment;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* @author yuyh.
|
||||
* @date 16/4/9.
|
||||
*/
|
||||
public class FileUtils {
|
||||
|
||||
private static final String TAG = FileUtils.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 创建根缓存目录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String createRootPath(Context context) {
|
||||
String cacheRootPath = "";
|
||||
if (isSdCardAvailable()) {
|
||||
// /sdcard/Android/data/<application package>/cache
|
||||
cacheRootPath = context.getExternalCacheDir().getPath();
|
||||
} else {
|
||||
// /data/data/<application package>/cache
|
||||
cacheRootPath = context.getCacheDir().getPath();
|
||||
}
|
||||
return cacheRootPath;
|
||||
}
|
||||
|
||||
public static boolean isSdCardAvailable() {
|
||||
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归创建文件夹
|
||||
*
|
||||
* @param dirPath
|
||||
* @return 创建失败返回""
|
||||
*/
|
||||
public static String createDir(String dirPath) {
|
||||
try {
|
||||
File file = new File(dirPath);
|
||||
if (file.getParentFile().exists()) {
|
||||
LogUtils.i("----- 创建文件夹" + file.getAbsolutePath());
|
||||
file.mkdir();
|
||||
return file.getAbsolutePath();
|
||||
} else {
|
||||
createDir(file.getParentFile().getAbsolutePath());
|
||||
LogUtils.i("----- 创建文件夹" + file.getAbsolutePath());
|
||||
file.mkdir();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归创建文件夹
|
||||
*
|
||||
* @param file
|
||||
* @return 创建失败返回""
|
||||
*/
|
||||
public static String createFile(File file) {
|
||||
try {
|
||||
if (file.getParentFile().exists()) {
|
||||
LogUtils.i("----- 创建文件" + file.getAbsolutePath());
|
||||
file.createNewFile();
|
||||
return file.getAbsolutePath();
|
||||
} else {
|
||||
createDir(file.getParentFile().getAbsolutePath());
|
||||
file.createNewFile();
|
||||
LogUtils.i("----- 创建文件" + file.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getImageCachePath(String path){
|
||||
return createDir(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片缓存目录
|
||||
*
|
||||
* @return 创建失败, 返回""
|
||||
*/
|
||||
public static String getImageCachePath(Context context) {
|
||||
String path = createDir(createRootPath(context) + File.separator + "img" + File.separator);
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片裁剪缓存目录
|
||||
*
|
||||
* @return 创建失败, 返回""
|
||||
*/
|
||||
public static String getImageCropCachePath(Context context) {
|
||||
String path = createDir(createRootPath(context) + File.separator + "imgCrop" + File.separator);
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将内容写入文件
|
||||
*
|
||||
* @param filePath eg:/mnt/sdcard/demo.txt
|
||||
* @param content 内容
|
||||
*/
|
||||
public static void writeFileSdcard(String filePath, String content, boolean isAppend) {
|
||||
try {
|
||||
FileOutputStream fout = new FileOutputStream(filePath, isAppend);
|
||||
byte[] bytes = content.getBytes();
|
||||
fout.write(bytes);
|
||||
fout.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开Asset下的文件
|
||||
*
|
||||
* @param context
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
public static InputStream openAssetFile(Context context, String fileName) {
|
||||
AssetManager am = context.getAssets();
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = am.open(fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Raw下的文件内容
|
||||
*
|
||||
* @param context
|
||||
* @param resId
|
||||
* @return 文件内容
|
||||
*/
|
||||
public static String getFileFromRaw(Context context, int resId) {
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
try {
|
||||
InputStreamReader in = new InputStreamReader(context.getResources().openRawResource(resId));
|
||||
BufferedReader br = new BufferedReader(in);
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
s.append(line);
|
||||
}
|
||||
return s.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件拷贝
|
||||
*
|
||||
* @param src 源文件
|
||||
* @param desc 目的文件
|
||||
*/
|
||||
public static void fileChannelCopy(File src, File desc) {
|
||||
FileInputStream fi = null;
|
||||
FileOutputStream fo = null;
|
||||
try {
|
||||
fi = new FileInputStream(src);
|
||||
fo = new FileOutputStream(desc);
|
||||
FileChannel in = fi.getChannel();//得到对应的文件通道
|
||||
FileChannel out = fo.getChannel();//得到对应的文件通道
|
||||
in.transferTo(0, in.size(), out);//连接两个通道,并且从in通道读取,然后写入out通道
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (fo != null) fo.close();
|
||||
if (fi != null) fi.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换文件大小
|
||||
*
|
||||
* @param fileLen 单位B
|
||||
* @return
|
||||
*/
|
||||
public static String formatFileSizeToString(long fileLen) {
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
String fileSizeString = "";
|
||||
if (fileLen < 1024) {
|
||||
fileSizeString = df.format((double) fileLen) + "B";
|
||||
} else if (fileLen < 1048576) {
|
||||
fileSizeString = df.format((double) fileLen / 1024) + "K";
|
||||
} else if (fileLen < 1073741824) {
|
||||
fileSizeString = df.format((double) fileLen / 1048576) + "M";
|
||||
} else {
|
||||
fileSizeString = df.format((double) fileLen / 1073741824) + "G";
|
||||
}
|
||||
return fileSizeString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定文件
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static boolean deleteFile(File file) throws IOException {
|
||||
return deleteFileOrDirectory(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定文件,如果是文件夹,则递归删除
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static boolean deleteFileOrDirectory(File file) throws IOException {
|
||||
try {
|
||||
if (file != null && file.isFile()) {
|
||||
return file.delete();
|
||||
}
|
||||
if (file != null && file.isDirectory()) {
|
||||
File[] childFiles = file.listFiles();
|
||||
// 删除空文件夹
|
||||
if (childFiles == null || childFiles.length == 0) {
|
||||
return file.delete();
|
||||
}
|
||||
// 递归删除文件夹下的子文件
|
||||
for (int i = 0; i < childFiles.length; i++) {
|
||||
deleteFileOrDirectory(childFiles[i]);
|
||||
}
|
||||
return file.delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取文件扩展名
|
||||
*
|
||||
* @param filename 文件名
|
||||
* @return
|
||||
*/
|
||||
public static String getExtensionName(String filename) {
|
||||
if ((filename != null) && (filename.length() > 0)) {
|
||||
int dot = filename.lastIndexOf('.');
|
||||
if ((dot > -1) && (dot < (filename.length() - 1))) {
|
||||
return filename.substring(dot + 1);
|
||||
}
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件内容
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static String getFileOutputString(String path) {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(path), 8192);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line = null;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
sb.append("\n").append(line);
|
||||
}
|
||||
bufferedReader.close();
|
||||
return sb.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package com.yuyh.library.imgsel.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Log工具类,可控制Log输出开关、保存Log到文件、过滤输出等级
|
||||
*
|
||||
* @author yuyh.
|
||||
* @date 16/4/9.
|
||||
*/
|
||||
public class LogUtils {
|
||||
private static Boolean LOG_SWITCH = true; // 日志文件总开关
|
||||
private static Boolean LOG_TO_FILE = false; // 日志写入文件开关
|
||||
private static String LOG_TAG = "TAG"; // 默认的tag
|
||||
private static char LOG_TYPE = 'v';// 输入日志类型,v代表输出所有信息,w则只输出警告...
|
||||
private static int LOG_SAVE_DAYS = 7;// sd卡中日志文件的最多保存天数
|
||||
|
||||
private final static SimpleDateFormat LOG_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 日志的输出格式
|
||||
private final static SimpleDateFormat FILE_SUFFIX = new SimpleDateFormat("yyyy-MM-dd");// 日志文件格式
|
||||
private static String LOG_FILE_PATH; // 日志文件保存路径
|
||||
private static String LOG_FILE_NAME;// 日志文件保存名称
|
||||
|
||||
public static void init(Context context) { // 在Application中初始化
|
||||
LOG_FILE_PATH = FileUtils.createRootPath(context);
|
||||
LOG_FILE_NAME = "Log";
|
||||
}
|
||||
|
||||
/**************************** Warn *********************************/
|
||||
public static void w(Object msg) {
|
||||
w(LOG_TAG, msg);
|
||||
}
|
||||
|
||||
public static void w(String tag, Object msg) {
|
||||
w(tag, msg, null);
|
||||
}
|
||||
|
||||
public static void w(String tag, Object msg, Throwable tr) {
|
||||
log(tag, msg.toString(), tr, 'w');
|
||||
}
|
||||
|
||||
/*************************** Error ********************************/
|
||||
public static void e(Object msg) {
|
||||
e(LOG_TAG, msg);
|
||||
}
|
||||
|
||||
public static void e(String tag, Object msg) {
|
||||
e(tag, msg, null);
|
||||
}
|
||||
|
||||
public static void e(String tag, Object msg, Throwable tr) {
|
||||
log(tag, msg.toString(), tr, 'e');
|
||||
}
|
||||
|
||||
/*************************** Debug ********************************/
|
||||
public static void d(Object msg) {
|
||||
d(LOG_TAG, msg);
|
||||
}
|
||||
|
||||
public static void d(String tag, Object msg) {// 调试信息
|
||||
d(tag, msg, null);
|
||||
}
|
||||
|
||||
public static void d(String tag, Object msg, Throwable tr) {
|
||||
log(tag, msg.toString(), tr, 'd');
|
||||
}
|
||||
|
||||
/**************************** Info *********************************/
|
||||
public static void i(Object msg) {
|
||||
i(LOG_TAG, msg);
|
||||
}
|
||||
|
||||
public static void i(String tag, Object msg) {
|
||||
i(tag, msg, null);
|
||||
}
|
||||
|
||||
public static void i(String tag, Object msg, Throwable tr) {
|
||||
log(tag, msg.toString(), tr, 'i');
|
||||
}
|
||||
|
||||
/************************** Verbose ********************************/
|
||||
public static void v(Object msg) {
|
||||
v(LOG_TAG, msg);
|
||||
}
|
||||
|
||||
public static void v(String tag, Object msg) {
|
||||
v(tag, msg, null);
|
||||
}
|
||||
|
||||
public static void v(String tag, Object msg, Throwable tr) {
|
||||
log(tag, msg.toString(), tr, 'v');
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据tag, msg和等级,输出日志
|
||||
*
|
||||
* @param tag
|
||||
* @param msg
|
||||
* @param level
|
||||
*/
|
||||
private static void log(String tag, String msg, Throwable tr, char level) {
|
||||
if (LOG_SWITCH) {
|
||||
if ('e' == level && ('e' == LOG_TYPE || 'v' == LOG_TYPE)) { // 输出错误信息
|
||||
Log.e(tag, msg, tr);
|
||||
} else if ('w' == level && ('w' == LOG_TYPE || 'v' == LOG_TYPE)) {
|
||||
Log.w(tag, msg, tr);
|
||||
} else if ('d' == level && ('d' == LOG_TYPE || 'v' == LOG_TYPE)) {
|
||||
Log.d(tag, msg, tr);
|
||||
} else if ('i' == level && ('d' == LOG_TYPE || 'v' == LOG_TYPE)) {
|
||||
Log.i(tag, msg, tr);
|
||||
} else {
|
||||
Log.v(tag, msg, tr);
|
||||
}
|
||||
if (LOG_TO_FILE)
|
||||
log2File(String.valueOf(level), tag, msg + tr == null ? "" : "\n" + Log.getStackTraceString(tr));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开日志文件并写入日志
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
private synchronized static void log2File(String mylogtype, String tag, String text) {
|
||||
Date nowtime = new Date();
|
||||
String date = FILE_SUFFIX.format(nowtime);
|
||||
String dateLogContent = LOG_FORMAT.format(nowtime) + ":" + mylogtype + ":" + tag + ":" + text; // 日志输出格式
|
||||
File destDir = new File(LOG_FILE_PATH);
|
||||
if (!destDir.exists()) {
|
||||
destDir.mkdirs();
|
||||
}
|
||||
File file = new File(LOG_FILE_PATH, LOG_FILE_NAME + date);
|
||||
try {
|
||||
FileWriter filerWriter = new FileWriter(file, true);
|
||||
BufferedWriter bufWriter = new BufferedWriter(filerWriter);
|
||||
bufWriter.write(dateLogContent);
|
||||
bufWriter.newLine();
|
||||
bufWriter.close();
|
||||
filerWriter.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的日志文件
|
||||
*/
|
||||
public static void delFile() {// 删除日志文件
|
||||
String needDelFiel = FILE_SUFFIX.format(getDateBefore());
|
||||
File file = new File(LOG_FILE_PATH, needDelFiel + LOG_FILE_NAME);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到LOG_SAVE_DAYS天前的日期
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static Date getDateBefore() {
|
||||
Date nowtime = new Date();
|
||||
Calendar now = Calendar.getInstance();
|
||||
now.setTime(nowtime);
|
||||
now.set(Calendar.DATE, now.get(Calendar.DATE) - LOG_SAVE_DAYS);
|
||||
return now.getTime();
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.yuyh.library.imgsel.utils;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public class StatusBarCompat {
|
||||
private static final int INVALID_VAL = -1;
|
||||
private static final int COLOR_DEFAULT = Color.parseColor("#20000000");
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public static void compat(Activity activity, int statusColor) {
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (statusColor != INVALID_VAL) {
|
||||
activity.getWindow().setStatusBarColor(statusColor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
int color = COLOR_DEFAULT;
|
||||
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
|
||||
if (statusColor != INVALID_VAL) {
|
||||
color = statusColor;
|
||||
}
|
||||
View statusBarView = contentView.getChildAt(0);
|
||||
//改变颜色时避免重复添加statusBarView
|
||||
if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity)) {
|
||||
statusBarView.setBackgroundColor(color);
|
||||
return;
|
||||
}
|
||||
statusBarView = new View(activity);
|
||||
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
getStatusBarHeight(activity));
|
||||
statusBarView.setBackgroundColor(color);
|
||||
contentView.addView(statusBarView, lp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void compat(Activity activity) {
|
||||
compat(activity, INVALID_VAL);
|
||||
}
|
||||
|
||||
|
||||
public static int getStatusBarHeight(Context context) {
|
||||
int result = 0;
|
||||
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = context.getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.yuyh.library.imgsel.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
public class CustomViewPager extends ViewPager {
|
||||
|
||||
private boolean isLocked;
|
||||
|
||||
public CustomViewPager(Context context) {
|
||||
super(context);
|
||||
isLocked = false;
|
||||
}
|
||||
|
||||
public CustomViewPager(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
isLocked = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (!isLocked) {
|
||||
try {
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return !isLocked && super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
public void toggleLock() {
|
||||
isLocked = !isLocked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean isLocked) {
|
||||
this.isLocked = isLocked;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
package com.yuyh.library.imgsel.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.LayoutManager;
|
||||
import android.support.v7.widget.RecyclerView.State;
|
||||
import android.support.v7.widget.StaggeredGridLayoutManager;
|
||||
import android.view.View;
|
||||
|
||||
public class DividerGridItemDecoration extends RecyclerView.ItemDecoration
|
||||
{
|
||||
|
||||
private static final int[] ATTRS = new int[] { android.R.attr.listDivider };
|
||||
private Drawable mDivider;
|
||||
|
||||
public DividerGridItemDecoration(Context context)
|
||||
{
|
||||
final TypedArray a = context.obtainStyledAttributes(ATTRS);
|
||||
mDivider = a.getDrawable(0);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, State state)
|
||||
{
|
||||
|
||||
drawHorizontal(c, parent);
|
||||
drawVertical(c, parent);
|
||||
|
||||
}
|
||||
|
||||
private int getSpanCount(RecyclerView parent)
|
||||
{
|
||||
// 列数
|
||||
int spanCount = -1;
|
||||
LayoutManager layoutManager = parent.getLayoutManager();
|
||||
if (layoutManager instanceof GridLayoutManager)
|
||||
{
|
||||
|
||||
spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
|
||||
} else if (layoutManager instanceof StaggeredGridLayoutManager)
|
||||
{
|
||||
spanCount = ((StaggeredGridLayoutManager) layoutManager)
|
||||
.getSpanCount();
|
||||
}
|
||||
return spanCount;
|
||||
}
|
||||
|
||||
public void drawHorizontal(Canvas c, RecyclerView parent)
|
||||
{
|
||||
int childCount = parent.getChildCount();
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
final View child = parent.getChildAt(i);
|
||||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
final int left = child.getLeft() - params.leftMargin;
|
||||
final int right = child.getRight() + params.rightMargin
|
||||
+ mDivider.getIntrinsicWidth();
|
||||
final int top = child.getBottom() + params.bottomMargin;
|
||||
final int bottom = top + mDivider.getIntrinsicHeight();
|
||||
mDivider.setBounds(left, top, right, bottom);
|
||||
mDivider.draw(c);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawVertical(Canvas c, RecyclerView parent)
|
||||
{
|
||||
final int childCount = parent.getChildCount();
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
final View child = parent.getChildAt(i);
|
||||
|
||||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
final int top = child.getTop() - params.topMargin;
|
||||
final int bottom = child.getBottom() + params.bottomMargin;
|
||||
final int left = child.getRight() + params.rightMargin;
|
||||
final int right = left + mDivider.getIntrinsicWidth();
|
||||
|
||||
mDivider.setBounds(left, top, right, bottom);
|
||||
mDivider.draw(c);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLastColum(RecyclerView parent, int pos, int spanCount,
|
||||
int childCount)
|
||||
{
|
||||
LayoutManager layoutManager = parent.getLayoutManager();
|
||||
if (layoutManager instanceof GridLayoutManager)
|
||||
{
|
||||
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} else if (layoutManager instanceof StaggeredGridLayoutManager)
|
||||
{
|
||||
int orientation = ((StaggeredGridLayoutManager) layoutManager)
|
||||
.getOrientation();
|
||||
if (orientation == StaggeredGridLayoutManager.VERTICAL)
|
||||
{
|
||||
if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
childCount = childCount - childCount % spanCount;
|
||||
if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isLastRaw(RecyclerView parent, int pos, int spanCount,
|
||||
int childCount)
|
||||
{
|
||||
LayoutManager layoutManager = parent.getLayoutManager();
|
||||
if (layoutManager instanceof GridLayoutManager)
|
||||
{
|
||||
childCount = childCount - childCount % spanCount;
|
||||
if (pos >= childCount)// 如果是最后一行,则不需要绘制底部
|
||||
return true;
|
||||
} else if (layoutManager instanceof StaggeredGridLayoutManager)
|
||||
{
|
||||
int orientation = ((StaggeredGridLayoutManager) layoutManager)
|
||||
.getOrientation();
|
||||
// StaggeredGridLayoutManager 且纵向滚动
|
||||
if (orientation == StaggeredGridLayoutManager.VERTICAL)
|
||||
{
|
||||
childCount = childCount - childCount % spanCount;
|
||||
// 如果是最后一行,则不需要绘制底部
|
||||
if (pos >= childCount)
|
||||
return true;
|
||||
} else
|
||||
// StaggeredGridLayoutManager 且横向滚动
|
||||
{
|
||||
// 如果是最后一行,则不需要绘制底部
|
||||
if ((pos + 1) % spanCount == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, int itemPosition,
|
||||
RecyclerView parent)
|
||||
{
|
||||
int spanCount = getSpanCount(parent);
|
||||
int childCount = parent.getAdapter().getItemCount();
|
||||
if (isLastRaw(parent, itemPosition, spanCount, childCount))// 如果是最后一行,则不需要绘制底部
|
||||
{
|
||||
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
|
||||
} else if (isLastColum(parent, itemPosition, spanCount, childCount))// 如果是最后一列,则不需要绘制右边
|
||||
{
|
||||
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
|
||||
} else
|
||||
{
|
||||
outRect.set(0, 0, mDivider.getIntrinsicWidth(),
|
||||
mDivider.getIntrinsicHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.yuyh.library.imgsel.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
public class SquareRelativeLayout extends RelativeLayout {
|
||||
|
||||
public SquareRelativeLayout(Context context, AttributeSet attrs,
|
||||
int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public SquareRelativeLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SquareRelativeLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(getDefaultSize(0, widthMeasureSpec),
|
||||
getDefaultSize(0, heightMeasureSpec));
|
||||
|
||||
int childWidthSize = getMeasuredWidth();
|
||||
// 高度和宽度一样
|
||||
heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||
childWidthSize, MeasureSpec.EXACTLY);
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 965 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 956 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 976 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 993 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="true" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rlTitleBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:background="@color/colorPrimary">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivBack"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/ic_back" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="图片"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnConfirm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="5dp"
|
||||
android:text="确定"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fmImageList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,49 +0,0 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/rvImageList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rlBottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#56000000"
|
||||
android:clickable="true">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAlbumSelected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@null"
|
||||
android:drawablePadding="5dp"
|
||||
android:drawableRight="@drawable/ic_album"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:singleLine="true"
|
||||
android:text="所有图片"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.yuyh.library.imgsel.widget.CustomViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/black"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.yuyh.library.imgsel.widget.SquareRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_default_image" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivPhotoCheaked"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:contentDescription="@null"
|
||||
android:paddingBottom="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:src="@drawable/ic_uncheck" />
|
||||
|
||||
</com.yuyh.library.imgsel.widget.SquareRelativeLayout>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFolder"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="55dp"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_default_image" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFolderName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvImageNum"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_folder_selected" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dip"
|
||||
android:background="#CCCCCC" />
|
||||
</LinearLayout>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.yuyh.library.imgsel.widget.SquareRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivTakePhoto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@+id/ivTakePhoto"
|
||||
android:text="拍照"/>
|
||||
|
||||
</com.yuyh.library.imgsel.widget.SquareRelativeLayout>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivImage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_default_image" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivPhotoCheaked"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:contentDescription="@null"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:src="@drawable/ic_uncheck" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,9 +0,0 @@
|
||||
<resources>
|
||||
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="SelTheme" parent="@style/BaseAppTheme">
|
||||
|
||||
</style>
|
||||
<!-- <item name="android:windowTranslucentNavigation">true</item>-->
|
||||
</resources>
|
||||
@@ -1,8 +0,0 @@
|
||||
<resources>
|
||||
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="SelTheme" parent="@style/BaseAppTheme">
|
||||
|
||||
</style>
|
||||
</resources>
|
||||
@@ -1,6 +0,0 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
@@ -1,5 +0,0 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item type="id" name="tag_first"></item>
|
||||
</resources>
|
||||
@@ -1,14 +0,0 @@
|
||||
<resources>
|
||||
<string name="app_name">library</string>
|
||||
|
||||
<string name="maxnum">最多选择%1$d张图片</string>
|
||||
<string name="all_images">所有图片</string>
|
||||
<string name="sd_disable">SD卡不可用</string>
|
||||
|
||||
<string name="confirm">确定(%1$d/%2$d)</string>
|
||||
<string name="confirm_single">确定</string>
|
||||
|
||||
<string name="open_camera_failure">打开相机失败</string>
|
||||
|
||||
<string name="permission_denied">请打开相机权限</string>
|
||||
</resources>
|
||||
@@ -1,17 +0,0 @@
|
||||
<resources>
|
||||
|
||||
|
||||
<style name="BaseAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">#FF4081</item>
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="SelTheme" parent="@style/BaseAppTheme">
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -1,2 +1 @@
|
||||
include ':app', ':img-selector'
|
||||
project(':img-selector').projectDir = new File('img-selector')
|
||||
include ':app'
|
||||