88 | Copyright 2015 Loopeer
89 |
90 | Licensed under the Apache License, Version 2.0 (the "License");
91 | you may not use this file except in compliance with the License.
92 | You may obtain a copy of the License at
93 |
94 | http://www.apache.org/licenses/LICENSE-2.0
95 |
96 | Unless required by applicable law or agreed to in writing, software
97 | distributed under the License is distributed on an "AS IS" BASIS,
98 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99 | See the License for the specific language governing permissions and
100 | limitations under the License.
101 |
102 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion Integer.parseInt(compile_sdk_version)
6 | buildToolsVersion build_tools_version
7 |
8 | defaultConfig {
9 | minSdkVersion min_sdk_version
10 | targetSdkVersion target_sdk_version
11 | versionCode Integer.parseInt(version_code)
12 | versionName version_name
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | lintOptions {
22 | abortOnError false
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | compile project(':imagegroupview')
30 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31 | }
32 | repositories {
33 | mavenCentral()
34 | google()
35 | }
36 |
--------------------------------------------------------------------------------
/app/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Sep 18 11:10:32 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/todou/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/loopeer/android/apps/imagegroupview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.apps.imagegroupview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/apps/imagegroupview/ImageGroupApp.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.apps.imagegroupview;
2 |
3 | import android.app.Application;
4 |
5 | import com.facebook.drawee.backends.pipeline.Fresco;
6 | import com.facebook.imagepipeline.core.ImagePipelineConfig;
7 |
8 | public class ImageGroupApp extends Application {
9 | @Override
10 | public void onCreate() {
11 | super.onCreate();
12 |
13 | ImagePipelineConfig config = ImagePipelineConfig.newBuilder(getApplicationContext())
14 | .setDownsampleEnabled(true)
15 | .build();
16 |
17 | Fresco.initialize(this, config);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/apps/imagegroupview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.apps.imagegroupview;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.view.WindowManager;
8 |
9 | import com.loopeer.android.librarys.imagegroupview.OnImageClickListener;
10 | import com.loopeer.android.librarys.imagegroupview.model.SquareImage;
11 | import com.loopeer.android.librarys.imagegroupview.view.ImageGridView;
12 | import com.loopeer.android.librarys.imagegroupview.view.SingleImageView;
13 |
14 | import java.util.ArrayList;
15 |
16 | public class MainActivity extends AppCompatActivity implements OnImageClickListener {
17 |
18 | private ImageGridView mGridView;
19 | private ImageGridView mGridView2;
20 | private ImageGridView mGridView3;
21 | private SingleImageView mSingleImageView;
22 | private int gtype = 0;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
28 | WindowManager.LayoutParams.FLAG_FULLSCREEN);
29 | setContentView(R.layout.activity_main);
30 | initGridView();
31 | }
32 |
33 |
34 | private void initGridView() {
35 | mGridView = (ImageGridView) findViewById(R.id.grid_test_group);
36 | mGridView2 = (ImageGridView) findViewById(R.id.grid_test_group2);
37 | mGridView2.setGRID_TYPE(2);
38 | mGridView3 = (ImageGridView) findViewById(R.id.grid_test_group3);
39 | mGridView3.setGRID_TYPE(3);
40 | mSingleImageView = (SingleImageView) findViewById(R.id.avatar);
41 | mGridView.updateNetPhotos(createTestData());
42 | }
43 |
44 | private ArrayList createTestData() {
45 | ArrayList result = new ArrayList<>();
46 | result.add("http://img2.imgtn.bdimg.com/it/u=2042486160,1330339958&fm=200&gp=0.jpg");
47 | result.add("http://img1.3lian.com/img13/c3/82/d/64.jpg");
48 | result.add("http://img3.duitang.com/uploads/item/201601/23/20160123202447_kYyjz.jpeg");
49 | result.add("http://img.ycwb.com/news/attachement/jpg/site2/20130328/90fba601558912bdd7bd4d.jpg");
50 | result.add("http://h.hiphotos.baidu.com/zhidao/pic/item/5fdf8db1cb1349549e1cd9df534e9258d1094a0e.jpg");
51 | result.add("http://duwanjuancn.qiniudn.com/wp-content/uploads/20141018/20141018185310259.jpg");
52 | result.add("http://img.7160.com/uploads/allimg/160513/12-160513155949.jpg");
53 | result.add("http://img2.imgtn.bdimg.com/it/u=1724555645,204198543&fm=27&gp=0.jpg");
54 | return result;
55 | }
56 |
57 | @Override
58 | public void onImageClick(View clickImage, SquareImage squareImage) {
59 |
60 | }
61 |
62 | @Override
63 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
64 | super.onActivityResult(requestCode, resultCode, data);
65 | if (resultCode == RESULT_OK) {
66 | mGridView.onParentResult(requestCode, data);
67 | mGridView2.onParentResult(requestCode, data);
68 | mSingleImageView.onParentResult(requestCode, data);
69 | }else if (resultCode==3){
70 | mGridView.onParentResult(requestCode, data);
71 | mGridView3.onParentResult(requestCode, data);
72 | mSingleImageView.onParentResult(requestCode, data);
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/apps/imagegroupview/TestIntentActivity.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.apps.imagegroupview;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | public class TestIntentActivity extends AppCompatActivity {
7 |
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | setContentView(R.layout.activity_test_intent);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sample_0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/drawable-xxhdpi/sample_0.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sample_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/drawable-xxhdpi/sample_1.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sample_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/drawable-xxhdpi/sample_2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sample_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/drawable-xxhdpi/sample_3.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sample_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/drawable-xxhdpi/sample_4.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sample_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/drawable-xxhdpi/sample_5.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sample_6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/drawable-xxhdpi/sample_6.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sample_7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/drawable-xxhdpi/sample_7.jpg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
23 |
24 |
28 |
29 |
37 |
38 |
39 |
40 |
50 |
51 |
65 |
66 |
67 |
76 |
77 |
94 |
95 |
104 |
105 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test_intent.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #ab5510
5 | #44ab5510
6 | @color/color_D80C18
7 |
8 | #D80C18
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 250dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ImageGroupView
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.0'
5 | repositories {
6 | jcenter()
7 | google()
8 | mavenCentral()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.0.1'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 |
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | plugins {
21 | id "com.jfrog.bintray" version "1.7.3"
22 | }
23 |
24 | allprojects {
25 | repositories {
26 | jcenter()
27 | google()
28 | mavenCentral()
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | target_sdk_version=26
2 | min_sdk_version=16
3 | build_tools_version=26.0.2
4 | compile_sdk_version=26
5 | version_code=1
6 | version_name=1.0.0
7 |
8 | support_version=26.0.2
9 | fresco_version=1.5.0
10 | #fresco_version=0.14.1
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/ImageGroupView/9cc91b8688c093931ac1acebe8debdc4eb3c4a02/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Sep 18 11:19:07 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/imagegroupview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/imagegroupview/bintray.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 |
4 | version = '1.0.41'
5 |
6 | uploadArchives {
7 | repositories {
8 | mavenDeployer {
9 | repository(url: "file:///Users/todou/.m2/repository")
10 | }
11 | }
12 | }
13 |
14 | def siteUrl = 'https://github.com/loopeer/ImageGroupView' // 项目的主页
15 | def gitUrl = 'https://github.com/loopeer/ImageGroupView.git' // Git仓库的url
16 | group = "com.loopeer.lib"
17 | install {
18 | repositories.mavenInstaller {
19 | // This generates POM.xml with proper parameters
20 | pom {
21 | project {
22 | packaging 'aar'
23 | // Add your description here
24 | name 'ImageGroupView, you can show ic_image_default and add images by it. You can click the ' +
25 | 'ic_image_default to see the images by viewpager and it can also be scale. Last you can add photo easily' //项目描述
26 | url siteUrl
27 | // Set your license
28 | licenses {
29 | license {
30 | name 'The Apache Software License, Version 2.0'
31 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
32 | }
33 | }
34 | developers {
35 | developer {
36 | id 'loopeer'
37 | name 'loopeer'
38 | email 'loopeerteam@gmail.com'
39 | }
40 | }
41 | scm {
42 | connection gitUrl
43 | developerConnection gitUrl
44 | url siteUrl
45 | }
46 | }
47 | }
48 | }
49 | }
50 |
51 | task sourcesJar(type: Jar) {
52 | from android.sourceSets.main.java.srcDirs
53 | classifier = 'sources'
54 | }
55 | artifacts {
56 | archives sourcesJar
57 | }
58 | Properties properties = new Properties()
59 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
60 | bintray {
61 | user = properties.getProperty("bintray.user")
62 | key = properties.getProperty("bintray.apikey")
63 | configurations = ['archives']
64 | pkg {
65 | repo = "maven" //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库
66 | name = "imagegroupview" //发布到Bintray上的项目名字
67 | websiteUrl = siteUrl
68 | vcsUrl = gitUrl
69 | licenses = ["Apache-2.0"]
70 | publish = true
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/imagegroupview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion Integer.parseInt(compile_sdk_version)
6 | buildToolsVersion build_tools_version
7 |
8 | defaultConfig {
9 | minSdkVersion min_sdk_version
10 | targetSdkVersion target_sdk_version
11 | versionCode Integer.parseInt(version_code)
12 | versionName version_name
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | lintOptions {
22 | abortOnError false
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | compile 'com.android.support:appcompat-v7:' + support_version
29 | compile 'com.android.support:recyclerview-v7:' + support_version
30 | compile 'com.facebook.fresco:fresco:' + fresco_version
31 | compile 'com.facebook.fresco:imagepipeline-okhttp:' + fresco_version
32 | compile 'com.android.support:support-core-utils:' + support_version
33 | compile 'com.yalantis:ucrop:2.2.0'
34 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
35 | }
36 |
37 | apply from: 'bintray.gradle'
38 | repositories {
39 | mavenCentral()
40 | google()
41 | }
42 |
--------------------------------------------------------------------------------
/imagegroupview/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/todou/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/imagegroupview/src/androidTest/java/com/loopeer/android/apps/imagegroupview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.apps.imagegroupview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/imagegroupview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 |
12 |
13 |
17 |
18 |
22 |
23 |
27 |
28 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/imagegroupview/src/main/java/com/loopeer/android/librarys/imagegroupview/OnImageClickListener.kt:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.imagegroupview
2 |
3 | import android.view.View
4 | import com.loopeer.android.librarys.imagegroupview.model.SquareImage
5 |
6 |
7 | interface OnImageClickListener {
8 | fun onImageClick(clickImage: View, squareImage: SquareImage)
9 | }
--------------------------------------------------------------------------------
/imagegroupview/src/main/java/com/loopeer/android/librarys/imagegroupview/OnTabOneClickListener.kt:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.imagegroupview
2 |
3 |
4 | interface OnTabOneClickListener {
5 | fun onTabOneClick()
6 | }
--------------------------------------------------------------------------------
/imagegroupview/src/main/java/com/loopeer/android/librarys/imagegroupview/activity/AlbumActivity.kt:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.imagegroupview.activity
2 |
3 | import android.annotation.SuppressLint
4 | import android.app.Activity
5 | import android.content.Intent
6 | import android.database.Cursor
7 | import android.os.AsyncTask
8 | import android.os.Bundle
9 | import android.provider.MediaStore
10 | import android.support.v4.app.ActivityCompat
11 | import android.support.v4.content.CursorLoader
12 | import android.support.v4.content.Loader
13 | import android.view.View
14 | import com.loopeer.android.librarys.imagegroupview.NavigatorImage
15 | import com.loopeer.android.librarys.imagegroupview.adapter.ImageAdapter
16 | import com.loopeer.android.librarys.imagegroupview.adapter.RecyclerViewAdapter
17 | import com.loopeer.android.librarys.imagegroupview.model.Image
18 | import com.loopeer.android.librarys.imagegroupview.model.ImageFolder
19 | import com.loopeer.android.librarys.imagegroupview.uimanager.IGRecycler
20 | import java.io.File
21 | import java.util.*
22 |
23 |
24 | class AlbumActivity : UIPatternActivity(), IGRecycler {
25 | private val DRAG_PHOTO = 3
26 | private var gtype: Int = 0
27 |
28 | override fun onCreate(savedInstanceState: Bundle?) {
29 | super.onCreate(savedInstanceState)
30 | var intent = intent
31 | gtype = intent.getIntExtra("gtype", 0)
32 | }
33 |
34 | override fun adapterUpdateContentView(recyclerViewAdapter: RecyclerViewAdapter<*>, folder: ImageFolder?) {
35 | var mImageAdapter = (recyclerViewAdapter as ImageAdapter)
36 | mImageAdapter.setAlbumType(mAlbumType)
37 | mImageAdapter.setIsAvatarType(mIsAvatarType)
38 | mImageAdapter.updateFolderImageData(folder)
39 | }
40 |
41 | override fun adapterUpdateSelect(recyclerViewAdapter: RecyclerViewAdapter<*>, mSelectedImages: MutableList, position: Int) {
42 | (recyclerViewAdapter as ImageAdapter).updateSelectImages(mSelectedImages, position)
43 | }
44 |
45 |
46 | override fun createRecyclerViewAdapter(): RecyclerViewAdapter {
47 | val madapter = ImageAdapter(this)
48 | madapter.setOnImageClickListener(this)
49 | return madapter
50 | }
51 |
52 | @SuppressLint("StaticFieldLeak")
53 | override fun doParseData(data: Cursor) {
54 |
55 | object : AsyncTask>() {
56 |
57 | override fun doInBackground(vararg params: Cursor): MutableList {
58 | val data = params[0]
59 | if (data != null) {
60 | val folders = mutableListOf()
61 | val count = data.count
62 | if (count > 0) {
63 | data.moveToFirst()
64 | do {
65 | val path = data.getString(data.getColumnIndexOrThrow(NavigatorImage.IMAGE_PROJECTION[0]))
66 | val name = data.getString(data.getColumnIndexOrThrow(NavigatorImage.IMAGE_PROJECTION[1]))
67 | val dateTime = data.getLong(data.getColumnIndexOrThrow(NavigatorImage.IMAGE_PROJECTION[2]))
68 | val image = Image(path, name, dateTime)
69 |
70 | val imageFile = File(path)
71 | val folderFile = imageFile.parentFile
72 | val folder = ImageFolder()
73 | folder.name = folderFile.name
74 | folder.dir = folderFile.absolutePath
75 | folder.firstImagePath = path
76 | if (!folders.contains(folder)) {
77 | val imageList = ArrayList()
78 | imageList.add(image)
79 | folder.count++
80 | folder.images = imageList
81 | folders.add(folder)
82 | } else {
83 | val f = folders.get(folders.indexOf(folder))
84 | f.images.add(image)
85 | f.count++
86 | }
87 | } while (data.moveToNext())
88 |
89 | return folders
90 | }
91 | }
92 |
93 | return mutableListOf()
94 | }
95 |
96 | override fun onPostExecute(list: MutableList) {
97 | super.onPostExecute(list)
98 | getCustomPopupWindowView()?.updateFolderData(createFoldersWithAllImageFolder(list))
99 | }
100 | }.execute(data)
101 | }
102 |
103 | override fun finishWithResult() {
104 | val intent = intent
105 | intent.putExtra(NavigatorImage.EXTRA_PHOTOS_URL, createUrls(mSelectedImages))
106 | intent.putExtra(NavigatorImage.EXTRA_IMAGE_GROUP_ID, mImageGroupId)
107 | if (gtype == 3) setResult(3, intent)
108 | else setResult(Activity.RESULT_OK, intent)
109 | finish()
110 | }
111 |
112 | override fun onClick(v: View?) {
113 | if (gtype == 3)
114 | pickSelectImages()
115 | else {
116 | super.onClick(v)
117 | }
118 | }
119 |
120 |
121 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
122 | super.onActivityResult(requestCode, resultCode, data)
123 | if (data == null || resultCode != Activity.RESULT_OK && mAlbumType == TAKE_PHOTO) {
124 | this.finish()
125 | }
126 | if (data == null || resultCode != Activity.RESULT_OK) return
127 |
128 | when (requestCode) {
129 | DRAG_PHOTO ->
130 | finishWithResult()
131 | }
132 | }
133 |
134 | private fun pickSelectImages() {
135 | val intent = Intent(this, ImagePickerActivity::class.java)
136 | intent.putExtra(NavigatorImage.EXTRA_PHOTOS_URL, createUrls(mSelectedImages))
137 | intent.putExtra(NavigatorImage.EXTRA_IMAGE_GROUP_ID, mImageGroupId)
138 | ActivityCompat.startActivityForResult(this@AlbumActivity,
139 | intent, NavigatorImage.RESULT_SELECT_PHOTO,
140 | null)
141 | }
142 |
143 | override fun onCreateLoader(id: Int, args: Bundle?): Loader {
144 | val cursorLoader = CursorLoader(this,
145 | MediaStore.Images.Media.EXTERNAL_CONTENT_URI, NavigatorImage.IMAGE_PROJECTION, null, null, NavigatorImage.IMAGE_PROJECTION[2] + " DESC")
146 | return cursorLoader
147 | }
148 |
149 |
150 | }
151 |
--------------------------------------------------------------------------------
/imagegroupview/src/main/java/com/loopeer/android/librarys/imagegroupview/activity/ImagePickerActivity.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.imagegroupview.activity;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.GridLayoutManager;
10 | import android.support.v7.widget.helper.ItemTouchHelper;
11 | import android.util.Log;
12 | import android.view.Menu;
13 | import android.view.MenuItem;
14 | import android.view.View;
15 | import android.widget.TextView;
16 |
17 | import com.loopeer.android.librarys.imagegroupview.NavigatorImage;
18 | import com.loopeer.android.librarys.imagegroupview.R;
19 | import com.loopeer.android.librarys.imagegroupview.model.Image;
20 | import com.loopeer.android.librarys.imagegroupview.model.SquareImage;
21 | import com.loopeer.android.librarys.imagegroupview.view.DragRecycleAdapter;
22 | import com.loopeer.android.librarys.imagegroupview.view.DragRecycleView;
23 | import com.loopeer.android.librarys.imagegroupview.view.SimpleItemTouchHelperCallback;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | public class ImagePickerActivity extends AppCompatActivity implements View.OnClickListener {
29 |
30 |
31 | List images;
32 | List preImages;
33 | public TextView tv;
34 | private MenuItem mSubmitMenu;
35 | private TextView mTextSubmit;
36 | private int mImageGroupId;
37 | DragRecycleAdapter adapter;
38 |
39 | @Override
40 | public void onCreate(@Nullable Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_image_picker);
43 | pareIntent();
44 | initData();
45 | initView();
46 | }
47 |
48 | public void initData() {
49 | preImages = new ArrayList<>();
50 | }
51 |
52 | private void initView() {
53 | DragRecycleView dragRecycleView = (DragRecycleView) findViewById(R.id.drag_view);
54 | tv = (TextView) findViewById(R.id.delete);
55 | dragRecycleView.setLayoutManager(new GridLayoutManager(ImagePickerActivity.this, 4));
56 | dragRecycleView.setHasFixedSize(true);
57 | dragRecycleView.tv = tv;
58 |
59 | for (Image image : images) {
60 | SquareImage squareImage = new SquareImage(image.url, null, getPhotoKey(image.time), SquareImage.PhotoType.LOCAL);
61 | preImages.add(squareImage);
62 | }
63 | adapter = new DragRecycleAdapter(this, preImages);
64 | dragRecycleView.setAdapter(adapter);
65 | //创建SimpleItemTouchHelperCallback
66 | ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter);
67 | //用Callback构造ItemtouchHelper
68 | ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
69 | //调用ItemTouchHelper的attachToRecyclerView方法建立联系
70 | touchHelper.attachToRecyclerView(dragRecycleView);
71 | }
72 |
73 | private void pareIntent() {
74 | Intent intent = this.getIntent();
75 | images = (List) intent.getSerializableExtra(NavigatorImage.EXTRA_PHOTOS_URL);
76 | mImageGroupId = intent.getIntExtra(NavigatorImage.EXTRA_IMAGE_GROUP_ID, 0);
77 | }
78 |
79 | @NonNull
80 | private String getPhotoKey(long time) {
81 | return "image_" + time;
82 | }
83 |
84 | @Override
85 | public boolean onCreateOptionsMenu(Menu menu) {
86 | getMenuInflater().inflate(R.menu.menu_image_group_submit, menu);
87 | updateSubmitMenu(menu);
88 | return true;
89 | }
90 |
91 | private void updateSubmitMenu(Menu menuItem) {
92 | mSubmitMenu = menuItem.findItem(R.id.action_submit);
93 | View view = mSubmitMenu.getActionView();
94 | mTextSubmit = (TextView) view.findViewById(R.id.text_image_submit);
95 | mTextSubmit.setOnClickListener(this);
96 | }
97 |
98 | @Override
99 | public boolean onOptionsItemSelected(MenuItem item) {
100 | int id = item.getItemId();
101 | if (id == android.R.id.home) {
102 | finish();
103 | return true;
104 | }
105 | return super.onOptionsItemSelected(item);
106 | }
107 |
108 | @Override
109 | public void onClick(View v) {
110 | Log.d("activityLog", "submit");
111 | finishWithResult();
112 | }
113 |
114 | private void finishWithResult() {
115 | ArrayList pics = new ArrayList<>();
116 | for (SquareImage s : adapter.mData
117 | ) {
118 | Log.d("log ", "mdata " + s.localUrl);
119 | pics.add(s.localUrl);
120 | }
121 | Intent intent = getIntent();
122 | intent.putExtra(NavigatorImage.EXTRA_PHOTOS_URL, pics);
123 | intent.putExtra(NavigatorImage.EXTRA_IMAGE_GROUP_ID, mImageGroupId);
124 | setResult(RESULT_OK, intent);
125 | finish();
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/imagegroupview/src/main/java/com/loopeer/android/librarys/imagegroupview/activity/ImageScaleActivity.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.imagegroupview.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentTransaction;
7 | import android.support.v7.app.AppCompatActivity;
8 |
9 | import com.loopeer.android.librarys.imagegroupview.NavigatorImage;
10 | import com.loopeer.android.librarys.imagegroupview.OnTabOneClickListener;
11 | import com.loopeer.android.librarys.imagegroupview.R;
12 | import com.loopeer.android.librarys.imagegroupview.fragment.ScaleImageFragment;
13 | import com.loopeer.android.librarys.imagegroupview.model.SquareImage;
14 |
15 | public class ImageScaleActivity extends AppCompatActivity implements OnTabOneClickListener {
16 |
17 | private String url;
18 | private int placeholderDrawable;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_scale_image);
24 |
25 | pareIntent();
26 | setFragment();
27 | }
28 |
29 | private void pareIntent() {
30 | Intent intent = getIntent();
31 | url = intent.getStringExtra(NavigatorImage.EXTRA_IMAGE_URL);
32 | placeholderDrawable = intent.getIntExtra(NavigatorImage.EXTRA_IMAGE_PLACE_DRAWABLE_ID, R.drawable.ic_image_default);
33 | }
34 |
35 | private void setFragment() {
36 | FragmentManager fragmentManager = getSupportFragmentManager();
37 | FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
38 | ScaleImageFragment scaleImageFragment = ScaleImageFragment.newInstance(new SquareImage(null, url, null, SquareImage.PhotoType.NETWORK), placeholderDrawable);
39 | scaleImageFragment.setOneTabListener(this);
40 | fragmentTransaction.add(R.id.container, scaleImageFragment).commit();
41 | }
42 |
43 | @Override
44 | public void onTabOneClick() {
45 | this.finish();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/imagegroupview/src/main/java/com/loopeer/android/librarys/imagegroupview/activity/UserCameraActivity.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.imagegroupview.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.ContentValues;
5 | import android.content.Intent;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.provider.MediaStore;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.text.TextUtils;
11 | import android.util.Log;
12 |
13 | import com.loopeer.android.librarys.imagegroupview.NavigatorImage;
14 | import com.loopeer.android.librarys.imagegroupview.utils.FileUtils;
15 | import com.loopeer.android.librarys.imagegroupview.utils.ImageGroupUtils;
16 |
17 | import java.io.File;
18 |
19 | public class UserCameraActivity extends AppCompatActivity {
20 |
21 | private String photoUrl;
22 | private final String EXTRA_PHOTO_URL = NavigatorImage.EXTRA_PHOTO_URL;
23 |
24 |
25 | private final int RSULT_IMAGE_CAPTURE = 2002;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | if (savedInstanceState != null) {
31 | photoUrl = savedInstanceState.getString(EXTRA_PHOTO_URL);
32 | if (!TextUtils.isEmpty(photoUrl))
33 | recoverFile(photoUrl);
34 | }
35 |
36 | if (savedInstanceState == null) {
37 | showCamera();
38 | }
39 | }
40 |
41 | private void recoverFile(String url) {
42 | String path = ImageGroupUtils.getPathOfPhotoByUri(this, Uri.parse(url));
43 | try {
44 | if (!TextUtils.isEmpty(path) && FileUtils.fileIsAvaliableImage(new File(path))) {
45 | finishWithResult(url);
46 | } else {
47 | finishAfterDelete(url);
48 | }
49 | } catch (Exception e) {
50 | e.printStackTrace();
51 | }
52 | }
53 |
54 | protected void onSaveInstanceState(Bundle outState) {
55 | super.onSaveInstanceState(outState);
56 | outState.putString(EXTRA_PHOTO_URL, photoUrl);
57 | }
58 |
59 | @Override
60 | public void onActivityResult(int requestCode, int resultCode, Intent intent) {
61 | if (RSULT_IMAGE_CAPTURE == requestCode && resultCode == Activity.RESULT_OK) {
62 | finishWithResult(photoUrl);
63 | } else {
64 | finishAfterDelete(photoUrl);
65 | }
66 | }
67 |
68 | private void finishAfterDelete(String url) {
69 | String path = ImageGroupUtils.getPathOfPhotoByUri(this, Uri.parse(url));
70 | if (!TextUtils.isEmpty(path))
71 | FileUtils.deleteFile(new File(path));
72 | finish();
73 | }
74 |
75 | private void finishWithResult(String url) {
76 | Intent rsl = new Intent();
77 | rsl.putExtra(EXTRA_PHOTO_URL, ImageGroupUtils.getPathOfPhotoByUri(this, Uri.parse(url)));
78 | setResult(Activity.RESULT_OK, rsl);
79 | finish();
80 | }
81 |
82 | private void showCamera() {
83 | Intent intent1 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
84 | ContentValues values = new ContentValues();
85 | Uri photoUri = getContentResolver()
86 | .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
87 | photoUrl = photoUri.toString();
88 | intent1.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
89 | startActivityForResult(intent1, RSULT_IMAGE_CAPTURE);
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/imagegroupview/src/main/java/com/loopeer/android/librarys/imagegroupview/adapter/AlbumRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.imagegroupview.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v4.content.ContextCompat;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.facebook.drawee.view.SimpleDraweeView;
12 | import com.loopeer.android.librarys.imagegroupview.R;
13 | import com.loopeer.android.librarys.imagegroupview.model.ImageFolder;
14 | import com.loopeer.android.librarys.imagegroupview.utils.ImageDisplayHelper;
15 |
16 | import java.util.List;
17 |
18 | public class AlbumRecyclerAdapter extends RecyclerViewAdapter {
19 |
20 | private ImageFolder mSelectFolder;
21 |
22 | public interface OnItemClickListener {
23 | void onItemClick(ImageFolder imageFolder);
24 | }
25 |
26 | private OnItemClickListener mOnItemClickListener;
27 |
28 | public AlbumRecyclerAdapter(Context context) {
29 | super(context);
30 | }
31 |
32 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
33 | mOnItemClickListener = onItemClickListener;
34 | }
35 |
36 | @Override
37 | public void updateData(List data) {
38 | mSelectFolder = data.get(0);
39 | super.updateData(data);
40 | }
41 |
42 | @Override
43 | public void bindView(final ImageFolder var1, int var2, RecyclerView.ViewHolder var3, List