Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions MultiImageSelector.iml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="MultiImageSelector" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

</module>
18 changes: 10 additions & 8 deletions app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="MultiImageSelector" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="MultiImageSelector" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand All @@ -13,8 +13,11 @@
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand All @@ -23,7 +26,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<exclude-output />
Expand Down Expand Up @@ -85,11 +88,10 @@
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="picasso-2.5.2" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="picasso-2.4.0" level="project" />
<orderEntry type="module" module-name="multi-image-selector" exported="" />
</component>
</module>

</module>
8 changes: 5 additions & 3 deletions multi-image-selector/multi-image-selector.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand All @@ -25,7 +27,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<exclude-output />
Expand Down
64 changes: 39 additions & 25 deletions ...mage-selector/src/main/java/me/nereo/multi_image_selector/MultiImageSelectorActivity.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,36 @@
* 多图选择
* Created by Nereo on 2015/4/7.
*/
public class MultiImageSelectorActivity extends FragmentActivity implements MultiImageSelectorFragment.Callback{
public class MultiImageSelectorActivity extends FragmentActivity implements MultiImageSelectorFragment.Callback {

/** 最大图片选择次数,int类型,默认9 */
/**
* 最大图片选择次数,int类型,默认9
*/
public static final String EXTRA_SELECT_COUNT = "max_select_count";
/** 图片选择模式,默认多选 */
/**
* 图片选择模式,默认多选
*/
public static final String EXTRA_SELECT_MODE = "select_count_mode";
/** 是否显示相机,默认显示 */
/**
* 是否显示相机,默认显示
*/
public static final String EXTRA_SHOW_CAMERA = "show_camera";
/** 选择结果,返回为 ArrayList&lt;String&gt; 图片路径集合 */
/**
* 选择结果,返回为 ArrayList&lt;String&gt; 图片路径集合
*/
public static final String EXTRA_RESULT = "select_result";
/** 默认选择集 */
/**
* 默认选择集
*/
public static final String EXTRA_DEFAULT_SELECTED_LIST = "default_list";

/** 单选 */
/**
* 单选
*/
public static final int MODE_SINGLE = 0;
/** 多选 */
/**
* 多选
*/
public static final int MODE_MULTI = 1;

private ArrayList<String> resultList = new ArrayList<>();
Expand All @@ -45,7 +59,7 @@ protected void onCreate(Bundle savedInstanceState) {
mDefaultCount = intent.getIntExtra(EXTRA_SELECT_COUNT, 9);
int mode = intent.getIntExtra(EXTRA_SELECT_MODE, MODE_MULTI);
boolean isShow = intent.getBooleanExtra(EXTRA_SHOW_CAMERA, true);
if(mode == MODE_MULTI && intent.hasExtra(EXTRA_DEFAULT_SELECTED_LIST)) {
if (mode == MODE_MULTI && intent.hasExtra(EXTRA_DEFAULT_SELECTED_LIST)) {
resultList = intent.getStringArrayListExtra(EXTRA_DEFAULT_SELECTED_LIST);
}

Expand All @@ -70,17 +84,17 @@ public void onClick(View view) {

// 完成按钮
mSubmitButton = (Button) findViewById(R.id.commit);
if(resultList == null || resultList.size()<=0){
mSubmitButton.setText("完成");
if (resultList == null || resultList.size() <= 0) {
mSubmitButton.setText(getString(R.string.execute));
mSubmitButton.setEnabled(false);
}else{
mSubmitButton.setText("完成("+resultList.size()+"/"+mDefaultCount+")");
} else {
mSubmitButton.setText(getString(R.string.execute) + " (" + resultList.size() + "/" + mDefaultCount + ")");
mSubmitButton.setEnabled(true);
}
mSubmitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(resultList != null && resultList.size() >0){
if (resultList != null && resultList.size() > 0) {
// 返回已选择的图片数据
Intent data = new Intent();
data.putStringArrayListExtra(EXTRA_RESULT, resultList);
Expand All @@ -102,36 +116,36 @@ public void onSingleImageSelected(String path) {

@Override
public void onImageSelected(String path) {
if(!resultList.contains(path)) {
if (!resultList.contains(path)) {
resultList.add(path);
}
// 有图片之后,改变按钮状态
if(resultList.size() > 0){
mSubmitButton.setText("完成("+resultList.size()+"/"+mDefaultCount+")");
if(!mSubmitButton.isEnabled()){
if (resultList.size() > 0) {
mSubmitButton.setText(getString(R.string.execute) + " (" + resultList.size() + "/" + mDefaultCount + ")");
if (!mSubmitButton.isEnabled()) {
mSubmitButton.setEnabled(true);
}
}
}

@Override
public void onImageUnselected(String path) {
if(resultList.contains(path)){
if (resultList.contains(path)) {
resultList.remove(path);
mSubmitButton.setText("完成("+resultList.size()+"/"+mDefaultCount+")");
}else{
mSubmitButton.setText("完成("+resultList.size()+"/"+mDefaultCount+")");
mSubmitButton.setText(getString(R.string.execute) + " (" + resultList.size() + "/" + mDefaultCount + ")");
} else {
mSubmitButton.setText(getString(R.string.execute) + " (" + resultList.size() + "/" + mDefaultCount + ")");
}
// 当为选择图片时候的状态
if(resultList.size() == 0){
mSubmitButton.setText("完成");
if (resultList.size() == 0) {
mSubmitButton.setText(getString(R.string.execute));
mSubmitButton.setEnabled(false);
}
}

@Override
public void onCameraShot(File imageFile) {
if(imageFile != null) {
if (imageFile != null) {
Intent data = new Intent();
resultList.add(imageFile.getAbsolutePath());
data.putStringArrayListExtra(EXTRA_RESULT, resultList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
int index = firstVisibleItem + 1 == view.getAdapter().getCount() ? view.getAdapter().getCount() - 1 : firstVisibleItem + 1;
Image image = (Image) view.getAdapter().getItem(index);
if (image != null) {
mTimeLineText.setText(TimeUtils.formatPhotoDate(image.path));
mTimeLineText.setText(TimeUtils.formatPhotoDate(getActivity(), image.path));
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions multi-image-selector/src/main/java/me/nereo/multi_image_selector/adapter/FolderAdapter.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ public View getView(int i, View view, ViewGroup viewGroup) {
}else{
holder = (ViewHolder) view.getTag();
}

if (holder != null) {
if(i == 0){
holder.name.setText("所有图片");
holder.size.setText(getTotalImageSize()+"张");
holder.name.setText(R.string.folder_all);

int totalImages = getTotalImageSize();
holder.size.setText(totalImages + " " + ( (totalImages == 1)?(mContext.getString(R.string.s_photo)):(mContext.getString(R.string.s_photos)) ));

if(mFolders.size()>0){
Folder f = mFolders.get(0);
Picasso.with(mContext)
Expand Down Expand Up @@ -137,14 +141,19 @@ class ViewHolder{

void bindData(Folder data) {
name.setText(data.name);
size.setText(data.images.size()+"张");

int totalImages = data.images.size();

size.setText(totalImages + " " + ( (totalImages == 1)?(mContext.getString(R.string.s_photo)):(mContext.getString(R.string.s_photos)) ));

// 显示图片
Picasso.with(mContext)
.load(new File(data.cover.path))
.placeholder(R.drawable.default_error)
.resize(mImageSize, mImageSize)
.centerCrop()
.into(cover);

// TODO 选择标识
}
}
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
17 changes: 9 additions & 8 deletions multi-image-selector/src/main/java/me/nereo/multi_image_selector/utils/TimeUtils.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
package me.nereo.multi_image_selector.utils;

import android.media.ExifInterface;
import android.content.Context;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import me.nereo.multi_image_selector.R;

/**
* 时间处理工具
* Created by Nereo on 2015/4/8.
*/
public class TimeUtils {

public static String timeFormat(long timeMillis, String pattern){
public static String timeFormat(long timeMillis, String pattern) {
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.CHINA);
return format.format(new Date(timeMillis));
}

public static String formatPhotoDate(long time){
return timeFormat(time, "yyyy-MM-dd");
public static String formatPhotoDate(Context context, long time) {
return timeFormat(time, context.getString(R.string.time_format));
}

public static String formatPhotoDate(String path){
public static String formatPhotoDate(Context context, String path) {
File file = new File(path);
if(file.exists()){
if (file.exists()) {
long time = file.lastModified();
return formatPhotoDate(time);
return formatPhotoDate(context, time);
}
return "1970-01-01";
}
Expand Down
Empty file.
Empty file.
Empty file modified multi-image-selector/src/main/res/color/default_text_color.xml
100644 → 100755
Empty file.
Empty file modified multi-image-selector/src/main/res/color/folder_text_color.xml
100644 → 100755
Empty file.
Empty file modified multi-image-selector/src/main/res/drawable-xhdpi/btn_back.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified multi-image-selector/src/main/res/drawable-xxhdpi/asv.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified multi-image-selector/src/main/res/drawable-xxhdpi/asy.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified multi-image-selector/src/main/res/drawable/action_btn.xml
100644 → 100755
Empty file.
Empty file.
Empty file modified multi-image-selector/src/main/res/layout/activity_default.xml
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions multi-image-selector/src/main/res/layout/cmp_customer_actionbar.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:layout_height="wrap_content" />

<TextView
android:text="图片"
android:text="@string/btn_back"
android:layout_toRightOf="@+id/btn_back"
android:textColor="@android:color/white"
android:textSize="20sp"
Expand All @@ -27,7 +27,7 @@
android:background="@drawable/action_btn"
android:minHeight="1dp"
android:minWidth="1dp"
android:text="完成"
android:text="@string/execute"
android:layout_marginRight="16dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
Expand Down
Empty file.
Loading