├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── identityimageview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── identityimageview
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ ├── biaoshi.gif
│ │ ├── guojia.jpg
│ │ ├── ic_launcher.png
│ │ ├── red.jpg
│ │ ├── testimage.jpg
│ │ ├── text.jpg
│ │ ├── v.jpg
│ │ └── v2.jpg
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── identityimageview
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── imagelib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── exampleenen
│ │ └── ruedy
│ │ └── imagelib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── exampleenen
│ │ │ └── ruedy
│ │ │ └── imagelib
│ │ │ └── widget
│ │ │ ├── CircleImageView.java
│ │ │ └── IdentityImageView.java
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── exampleenen
│ └── ruedy
│ └── imagelib
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # IdentityImageView
3 | 一个能带进度条的图片框架,同时有身份标识动能,简单易用
4 |
5 | ## 效果图:
6 | 
7 |
8 |
9 | # 博客介绍
10 |
11 | CSDN:[http://blog.csdn.net/iamdingruihaha/article/details/69895266](http://blog.csdn.net/iamdingruihaha/article/details/69895266)
12 |
13 |
14 |
15 | ## Download
16 |
17 | 简单的两个类:IdentityImageView,CircleImageView,下载下来 放到项目里面
18 |
19 | #### OR
20 | >> 1.先在 build.gradle(Project:XXXX) 的 repositories 添加:
21 | ```
22 | allprojects {
23 | repositories {
24 | ...
25 | maven { url 'https://jitpack.io' }
26 | }
27 | }
28 | ```
29 |
30 | >> 2.然后在 build.gradle(Module:app) 的 dependencies 添加:
31 |
32 | ```
33 | dependencies {
34 |
35 |
36 | compile 'com.github.385841539:IdentityImageView:1.5.0'
37 | }
38 | ```
39 | # Usage
40 |
41 | ### 基本使用:
42 |
43 |
44 | ```xml
45 |
52 | ```
53 |
54 |
55 | ### 自定义(均设有默认值,可不使用):
56 |
57 |
58 | | 属性 | 参数类型 | 说明 |
59 | | ------------------------- |------------------ | --------------------- |
60 | | iciv_bigimage | reference |大图片|
61 | | iciv_smallimage | reference | 小图片(标识)|
62 | | iciv_angle | float | 标识的角度,默认为45度|
63 | | iciv_radiusscale | float |大小图片比例,默认为0.2|
64 | | iciv_isprogress|boolean flag | 是否有进度条,默认为false,如果要用,必须设置为true|
65 | |iciv_progress_collor|Color Or reference| 进度条颜色|
66 | | iciv_border_color |Color Or reference| 边框颜色 |
67 | | iciv_border_width |integer | 边框和进度条宽度 |
68 | |iciv_hint_smallimageview | boolean| 是否隐藏小图片|
69 |
70 |
71 |
72 | ### 动态 设置属性值:
73 | ```java
74 |
75 | identityImageView = ((IdentityImageView) findViewById(R.id.iiv));
76 |
77 | //填充大图片
78 | identityImageView.getBigCircleImageView().setImageResource(R.mipmap.guojia);
79 |
80 | //改变图片比例大小,
81 | identityImageView.setRadiusScale(0.1f);
82 |
83 |
84 | //增加边框
85 | identityImageView.setBorderWidth(100);
86 | identityImageView.setBorderColor(R.color.colorTest);
87 |
88 | //增加进度条,以及改变的角度
89 | identityImageView.setIsprogress(true);
90 | identityImageView.setProgressColor(R.color.colorAccent);
91 | identityImageView.setProgress(120);
92 |
93 |
94 | ```
95 |
96 | ## Tips:
97 | 原理很简单,献丑了,方便大家调用,为了节省大家时间。
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.example.identityimageview"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.2.0'
28 | testCompile 'junit:junit:4.12'
29 | compile project(':imagelib')
30 | }
31 |
--------------------------------------------------------------------------------
/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 D:\studio\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/example/identityimageview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.identityimageview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.identityimageview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/identityimageview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.identityimageview;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | import com.exampleenen.ruedy.imagelib.widget.IdentityImageView;
10 |
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | private IdentityImageView identityImageView;
15 | private Button bt1;
16 | private Button bt2;
17 | private Button bt4;
18 | private Button bt3;
19 | private Button bt5;
20 | private int i = 10;
21 | private int angle = 30;
22 | private boolean flag;//文字是否出现
23 |
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_main);
29 | initViews();
30 | }
31 |
32 | private void initViews() {
33 | identityImageView = ((IdentityImageView) findViewById(R.id.iiv));
34 | bt1 = ((Button) findViewById(R.id.bt1));
35 | bt2 = ((Button) findViewById(R.id.bt2));
36 | bt3 = ((Button) findViewById(R.id.bt3));
37 | bt4 = ((Button) findViewById(R.id.bt4));
38 | bt5 = ((Button) findViewById(R.id.bt5));
39 | }
40 |
41 | public void click(View view) {
42 | switch (view.getId()) {
43 | case R.id.bt1://填充头像
44 | identityImageView.getBigCircleImageView().setImageResource(R.mipmap.guojia);
45 |
46 | break;
47 | case R.id.bt2:
48 | //改变图片比例大小,
49 | identityImageView.setRadiusScale(0.1f);
50 | break;
51 | case R.id.bt3:
52 | //增加边框
53 | identityImageView.setBorderWidth(50);
54 | identityImageView.setBorderColor(R.color.colorTest);
55 |
56 | break;
57 | case R.id.bt4:
58 | //增加进度条,没按一次加10,以及改变的角度
59 | identityImageView.setIsprogress(true);
60 | identityImageView.setProgressColor(R.color.colorAccent);
61 |
62 | identityImageView.setProgress(i += 10);
63 |
64 | break;
65 | case R.id.bt5:
66 | identityImageView.getSmallCircleImageView().setImageResource(R.mipmap.v);
67 | break;
68 |
69 | case R.id.bt6:
70 | identityImageView.setAngle(angle += 7);
71 | break;
72 | default:
73 | break;
74 |
75 |
76 | }
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
13 |
14 |
21 |
22 |
23 |
30 |
31 |
38 |
39 |
46 |
47 |
54 |
55 |
62 |
63 |
64 |
65 |
66 |
67 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/biaoshi.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xhdpi/biaoshi.gif
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/guojia.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xhdpi/guojia.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/red.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xhdpi/red.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/testimage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xhdpi/testimage.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/text.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xhdpi/text.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/v.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xhdpi/v.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/v2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xhdpi/v2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #62403f3c
8 |
9 | #edf265
10 |
11 | #31312d
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | IdentityImageView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/identityimageview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.identityimageview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1024m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/385841539/IdentityImageView/898a9c5e984c5a6caf130c92c31e2c076de0ad9c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-2.14.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 | # 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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/imagelib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/imagelib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | compile 'com.android.support:appcompat-v7:25.3.1'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/imagelib/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 G:\studio\studio\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/imagelib/src/androidTest/java/com/exampleenen/ruedy/imagelib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.exampleenen.ruedy.imagelib;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.exampleenen.ruedy.imagelib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/imagelib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/imagelib/src/main/java/com/exampleenen/ruedy/imagelib/widget/CircleImageView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 - 2017 Henning Dodenhof
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.exampleenen.ruedy.imagelib.widget;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.graphics.Bitmap;
21 | import android.graphics.BitmapShader;
22 | import android.graphics.Canvas;
23 | import android.graphics.Color;
24 | import android.graphics.ColorFilter;
25 | import android.graphics.Matrix;
26 | import android.graphics.Paint;
27 | import android.graphics.RectF;
28 | import android.graphics.Shader;
29 | import android.graphics.drawable.BitmapDrawable;
30 | import android.graphics.drawable.ColorDrawable;
31 | import android.graphics.drawable.Drawable;
32 | import android.net.Uri;
33 | import android.support.annotation.ColorInt;
34 | import android.support.annotation.ColorRes;
35 | import android.support.annotation.DrawableRes;
36 | import android.util.AttributeSet;
37 | import android.widget.ImageView;
38 |
39 | import com.exampleenen.ruedy.imagelib.R;
40 |
41 |
42 | public class CircleImageView extends ImageView {
43 |
44 | private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;
45 |
46 | private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
47 | private static final int COLORDRAWABLE_DIMENSION = 2;
48 |
49 | private static final int DEFAULT_BORDER_WIDTH = 0;
50 | private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
51 | private static final int DEFAULT_FILL_COLOR = Color.TRANSPARENT;
52 | private static final boolean DEFAULT_BORDER_OVERLAY = false;
53 |
54 | private final RectF mDrawableRect = new RectF();
55 | private final RectF mBorderRect = new RectF();
56 |
57 | private final Matrix mShaderMatrix = new Matrix();
58 | private final Paint mBitmapPaint = new Paint();
59 | private final Paint mBorderPaint = new Paint();
60 | private final Paint mFillPaint = new Paint();
61 |
62 | private int mBorderColor = DEFAULT_BORDER_COLOR;
63 | private int mBorderWidth = DEFAULT_BORDER_WIDTH;
64 | private int mFillColor = DEFAULT_FILL_COLOR;
65 |
66 | private Bitmap mBitmap;
67 | private BitmapShader mBitmapShader;
68 | private int mBitmapWidth;
69 | private int mBitmapHeight;
70 |
71 | private float mDrawableRadius;
72 | private float mBorderRadius;
73 |
74 | private ColorFilter mColorFilter;
75 |
76 | private boolean mReady;
77 | private boolean mSetupPending;
78 | private boolean mBorderOverlay;
79 | private boolean mDisableCircularTransformation;
80 |
81 | public CircleImageView(Context context) {
82 | super(context);
83 |
84 | init();
85 | }
86 |
87 | public CircleImageView(Context context, AttributeSet attrs) {
88 | this(context, attrs, 0);
89 | }
90 |
91 | public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
92 | super(context, attrs, defStyle);
93 |
94 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
95 |
96 | mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
97 | mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
98 | mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
99 | mFillColor = a.getColor(R.styleable.CircleImageView_civ_fill_color, DEFAULT_FILL_COLOR);
100 |
101 | a.recycle();
102 |
103 | init();
104 | }
105 |
106 | private void init() {
107 | super.setScaleType(SCALE_TYPE);
108 | mReady = true;
109 |
110 | if (mSetupPending) {
111 | setup();
112 | mSetupPending = false;
113 | }
114 | }
115 |
116 | @Override
117 | public ScaleType getScaleType() {
118 | return SCALE_TYPE;
119 | }
120 |
121 | @Override
122 | public void setScaleType(ScaleType scaleType) {
123 | if (scaleType != SCALE_TYPE) {
124 | throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
125 | }
126 | }
127 |
128 | @Override
129 | public void setAdjustViewBounds(boolean adjustViewBounds) {
130 | if (adjustViewBounds) {
131 | throw new IllegalArgumentException("adjustViewBounds not supported.");
132 | }
133 | }
134 |
135 | @Override
136 | protected void onDraw(Canvas canvas) {
137 | if (mDisableCircularTransformation) {
138 | super.onDraw(canvas);
139 | return;
140 | }
141 |
142 | if (mBitmap == null) {
143 | return;
144 | }
145 |
146 | if (mFillColor != Color.TRANSPARENT) {
147 | canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mFillPaint);
148 | }
149 | canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mBitmapPaint);
150 | if (mBorderWidth > 0) {
151 | canvas.drawCircle(mBorderRect.centerX(), mBorderRect.centerY(), mBorderRadius, mBorderPaint);
152 | }
153 | }
154 |
155 | @Override
156 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
157 | super.onSizeChanged(w, h, oldw, oldh);
158 | setup();
159 | }
160 |
161 | @Override
162 | public void setPadding(int left, int top, int right, int bottom) {
163 | super.setPadding(left, top, right, bottom);
164 | setup();
165 | }
166 |
167 | @Override
168 | public void setPaddingRelative(int start, int top, int end, int bottom) {
169 | super.setPaddingRelative(start, top, end, bottom);
170 | setup();
171 | }
172 |
173 | public int getBorderColor() {
174 | return mBorderColor;
175 | }
176 |
177 | public void setBorderColor(@ColorInt int borderColor) {
178 | if (borderColor == mBorderColor) {
179 | return;
180 | }
181 |
182 | mBorderColor = borderColor;
183 | mBorderPaint.setColor(mBorderColor);
184 | invalidate();
185 | }
186 |
187 | /**
188 | * @deprecated Use {@link #setBorderColor(int)} instead
189 | */
190 | @Deprecated
191 | public void setBorderColorResource(@ColorRes int borderColorRes) {
192 | setBorderColor(getContext().getResources().getColor(borderColorRes));
193 | }
194 |
195 | /**
196 | * Return the color drawn behind the circle-shaped drawable.
197 | *
198 | * @return The color drawn behind the drawable
199 | *
200 | * @deprecated Fill color support is going to be removed in the future
201 | */
202 | @Deprecated
203 | public int getFillColor() {
204 | return mFillColor;
205 | }
206 |
207 | /**
208 | * Set a color to be drawn behind the circle-shaped drawable. Note that
209 | * this has no effect if the drawable is opaque or no drawable is set.
210 | *
211 | * @param fillColor The color to be drawn behind the drawable
212 | *
213 | * @deprecated Fill color support is going to be removed in the future
214 | */
215 | @Deprecated
216 | public void setFillColor(@ColorInt int fillColor) {
217 | if (fillColor == mFillColor) {
218 | return;
219 | }
220 |
221 | mFillColor = fillColor;
222 | mFillPaint.setColor(fillColor);
223 | invalidate();
224 | }
225 |
226 | /**
227 | * Set a color to be drawn behind the circle-shaped drawable. Note that
228 | * this has no effect if the drawable is opaque or no drawable is set.
229 | *
230 | * @param fillColorRes The color resource to be resolved to a color and
231 | * drawn behind the drawable
232 | *
233 | * @deprecated Fill color support is going to be removed in the future
234 | */
235 | @Deprecated
236 | public void setFillColorResource(@ColorRes int fillColorRes) {
237 | setFillColor(getContext().getResources().getColor(fillColorRes));
238 | }
239 |
240 | public int getBorderWidth() {
241 | return mBorderWidth;
242 | }
243 |
244 | public void setBorderWidth(int borderWidth) {
245 | if (borderWidth == mBorderWidth) {
246 | return;
247 | }
248 |
249 | mBorderWidth = borderWidth;
250 | setup();
251 | }
252 |
253 | public boolean isBorderOverlay() {
254 | return mBorderOverlay;
255 | }
256 |
257 | public void setBorderOverlay(boolean borderOverlay) {
258 | if (borderOverlay == mBorderOverlay) {
259 | return;
260 | }
261 |
262 | mBorderOverlay = borderOverlay;
263 | setup();
264 | }
265 |
266 | public boolean isDisableCircularTransformation() {
267 | return mDisableCircularTransformation;
268 | }
269 |
270 | public void setDisableCircularTransformation(boolean disableCircularTransformation) {
271 | if (mDisableCircularTransformation == disableCircularTransformation) {
272 | return;
273 | }
274 |
275 | mDisableCircularTransformation = disableCircularTransformation;
276 | initializeBitmap();
277 | }
278 |
279 | @Override
280 | public void setImageBitmap(Bitmap bm) {
281 | super.setImageBitmap(bm);
282 | initializeBitmap();
283 | }
284 |
285 | @Override
286 | public void setImageDrawable(Drawable drawable) {
287 | super.setImageDrawable(drawable);
288 | initializeBitmap();
289 | }
290 |
291 | @Override
292 | public void setImageResource(@DrawableRes int resId) {
293 | super.setImageResource(resId);
294 | initializeBitmap();
295 | }
296 |
297 | @Override
298 | public void setImageURI(Uri uri) {
299 | super.setImageURI(uri);
300 | initializeBitmap();
301 | }
302 |
303 | @Override
304 | public void setColorFilter(ColorFilter cf) {
305 | if (cf == mColorFilter) {
306 | return;
307 | }
308 |
309 | mColorFilter = cf;
310 | applyColorFilter();
311 | invalidate();
312 | }
313 |
314 | @Override
315 | public ColorFilter getColorFilter() {
316 | return mColorFilter;
317 | }
318 |
319 | private void applyColorFilter() {
320 | if (mBitmapPaint != null) {
321 | mBitmapPaint.setColorFilter(mColorFilter);
322 | }
323 | }
324 |
325 | private Bitmap getBitmapFromDrawable(Drawable drawable) {
326 | if (drawable == null) {
327 | return null;
328 | }
329 |
330 | if (drawable instanceof BitmapDrawable) {
331 | return ((BitmapDrawable) drawable).getBitmap();
332 | }
333 |
334 | try {
335 | Bitmap bitmap;
336 |
337 | if (drawable instanceof ColorDrawable) {
338 | bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
339 | } else {
340 | bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
341 | }
342 |
343 | Canvas canvas = new Canvas(bitmap);
344 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
345 | drawable.draw(canvas);
346 | return bitmap;
347 | } catch (Exception e) {
348 | e.printStackTrace();
349 | return null;
350 | }
351 | }
352 |
353 | private void initializeBitmap() {
354 | if (mDisableCircularTransformation) {
355 | mBitmap = null;
356 | } else {
357 | mBitmap = getBitmapFromDrawable(getDrawable());
358 | }
359 | setup();
360 | }
361 |
362 | private void setup() {
363 | if (!mReady) {
364 | mSetupPending = true;
365 | return;
366 | }
367 |
368 | if (getWidth() == 0 && getHeight() == 0) {
369 | return;
370 | }
371 |
372 | if (mBitmap == null) {
373 | invalidate();
374 | return;
375 | }
376 |
377 | mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
378 |
379 | mBitmapPaint.setAntiAlias(true);
380 | mBitmapPaint.setShader(mBitmapShader);
381 |
382 | mBorderPaint.setStyle(Paint.Style.STROKE);
383 | mBorderPaint.setAntiAlias(true);
384 | mBorderPaint.setColor(mBorderColor);
385 | mBorderPaint.setStrokeWidth(mBorderWidth);
386 |
387 | mFillPaint.setStyle(Paint.Style.FILL);
388 | mFillPaint.setAntiAlias(true);
389 | mFillPaint.setColor(mFillColor);
390 |
391 | mBitmapHeight = mBitmap.getHeight();
392 | mBitmapWidth = mBitmap.getWidth();
393 |
394 | mBorderRect.set(calculateBounds());
395 | mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2.0f, (mBorderRect.width() - mBorderWidth) / 2.0f);
396 |
397 | mDrawableRect.set(mBorderRect);
398 | if (!mBorderOverlay && mBorderWidth > 0) {
399 | mDrawableRect.inset(mBorderWidth - 1.0f, mBorderWidth - 1.0f);
400 | }
401 | mDrawableRadius = Math.min(mDrawableRect.height() / 2.0f, mDrawableRect.width() / 2.0f);
402 |
403 | applyColorFilter();
404 | updateShaderMatrix();
405 | invalidate();
406 | }
407 |
408 | private RectF calculateBounds() {
409 | int availableWidth = getWidth() - getPaddingLeft() - getPaddingRight();
410 | int availableHeight = getHeight() - getPaddingTop() - getPaddingBottom();
411 |
412 | int sideLength = Math.min(availableWidth, availableHeight);
413 |
414 | float left = getPaddingLeft() + (availableWidth - sideLength) / 2f;
415 | float top = getPaddingTop() + (availableHeight - sideLength) / 2f;
416 |
417 | return new RectF(left, top, left + sideLength, top + sideLength);
418 | }
419 |
420 | private void updateShaderMatrix() {
421 | float scale;
422 | float dx = 0;
423 | float dy = 0;
424 |
425 | mShaderMatrix.set(null);
426 |
427 | if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
428 | scale = mDrawableRect.height() / (float) mBitmapHeight;
429 | dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
430 | } else {
431 | scale = mDrawableRect.width() / (float) mBitmapWidth;
432 | dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
433 | }
434 |
435 | mShaderMatrix.setScale(scale, scale);
436 | mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
437 |
438 | mBitmapShader.setLocalMatrix(mShaderMatrix);
439 | }
440 |
441 | }
442 |
--------------------------------------------------------------------------------
/imagelib/src/main/java/com/exampleenen/ruedy/imagelib/widget/IdentityImageView.java:
--------------------------------------------------------------------------------
1 | package com.exampleenen.ruedy.imagelib.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 | import android.graphics.drawable.Drawable;
8 | import android.support.v7.widget.TintTypedArray;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.Gravity;
12 | import android.view.ViewGroup;
13 | import android.widget.TextView;
14 |
15 | import com.exampleenen.ruedy.imagelib.R;
16 |
17 |
18 | /**
19 | * Created by 丁瑞 on 2017/4/9.
20 | */
21 |
22 | public class IdentityImageView extends ViewGroup {
23 | private Context mContext;
24 | private CircleImageView bigImageView;//大圆
25 | private CircleImageView smallImageView;//小圆
26 | private float radiusScale;//小图片与大图片的比例,默认0.28,刚刚好,大了不好看
27 | int radius;//大图片半径
28 | private int smallRadius;//小图片半径
29 | private double angle = 45; //标识角度大小
30 | private boolean isprogress;//是否可以加载进度条,必须设置为true才能开启
31 | private int progressCollor;//进度条颜色
32 | private int borderColor = 0;//边框颜色
33 | private int borderWidth;//边框、进度条宽度
34 | private TextView textView;//标识符为文字,用的地方比较少
35 | private boolean hintSmallView;//标识符是否隐藏
36 | private Paint mBorderPaint;//边框画笔
37 | private Paint mProgressPaint;//进度条画笔
38 | private float progresss;
39 | private Drawable bigImage;//大图片
40 | private Drawable smallimage;//小图片
41 | private int setprogressColor = 0;//动态设置进度条颜色值
42 | private int setborderColor = 0;//动态设置边框颜色值
43 | private int totalwidth;
44 |
45 | public IdentityImageView(Context context) {
46 | this(context, null);
47 | }
48 |
49 | public IdentityImageView(Context context, AttributeSet attrs) {
50 | this(context, attrs, 0);
51 | }
52 |
53 | public IdentityImageView(Context context, AttributeSet attrs, int defStyleAttr) {
54 | super(context, attrs, defStyleAttr);
55 | mContext = context;
56 | setWillNotDraw(false);//是的ondraw方法被执行
57 |
58 | addThreeView();
59 |
60 | initAttrs(attrs);
61 | }
62 |
63 | @Override
64 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
65 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
66 | int viewWidthMode = MeasureSpec.getMode(widthMeasureSpec);
67 | int viewHeightMode = MeasureSpec.getMode(heightMeasureSpec);
68 | int viewWidht = MeasureSpec.getSize(widthMeasureSpec);
69 | int viewHeight = MeasureSpec.getSize(heightMeasureSpec);
70 | switch (viewWidthMode) {
71 | case MeasureSpec.EXACTLY: //说明在布局文件中使用的是具体值:100dp或者match_parent
72 | //为了方便,让半径等于宽高中小的那个,再设置宽高至半径大小
73 | totalwidth = viewWidht < viewHeight ? viewWidht : viewHeight;
74 | float scale = 1 + radiusScale;
75 | int radius2 = totalwidth / 2;
76 | radius = (int) (radius2 / scale);
77 | break;
78 | case MeasureSpec.AT_MOST: //说明在布局文件中使用的是wrap_content:
79 | //这时我们也写死宽高
80 | radius = 200;
81 | totalwidth = (int) ((radius + radius * radiusScale) * 2);
82 | break;
83 | default:
84 | radius = 200;
85 | totalwidth = (int) ((radius + radius * radiusScale) * 2);
86 | break;
87 | }
88 | setMeasuredDimension(totalwidth, totalwidth);
89 | adjustThreeView();
90 | }
91 |
92 | @Override
93 | protected void onDraw(Canvas canvas) {
94 | initPaint();
95 |
96 | if (borderWidth > 0) {
97 | drawBorder(canvas);
98 | }
99 | if (isprogress) {
100 | drawProgress(canvas);
101 | }
102 |
103 |
104 | }
105 |
106 | /**
107 | * 画边框
108 | *
109 | * @param canvas 画布
110 | */
111 | private void drawBorder(Canvas canvas) {
112 | canvas.drawCircle(totalwidth / 2, totalwidth / 2, radius - borderWidth / 2, mBorderPaint);
113 | }
114 |
115 | //画圆弧进度条
116 | private void drawProgress(Canvas canvas) {
117 | RectF rectf = new RectF(smallRadius + borderWidth / 2, smallRadius + borderWidth / 2, getWidth() - smallRadius - borderWidth / 2, getHeight() - smallRadius - borderWidth / 2);
118 | //定义的圆弧的形状和大小的范围,之所以减去圆弧的一半,是因为画圆环的高度时,
119 | // 原因就在于setStrokeWidth这个方法,并不是往圆内侧增加圆环宽度的,而是往外侧增加一半,往内侧增加一半。
120 | canvas.drawArc(rectf, (float) angle, progresss, false, mProgressPaint);
121 |
122 | }
123 |
124 | private void initPaint() {
125 | if (mBorderPaint == null) {
126 | mBorderPaint = new Paint();
127 | mBorderPaint.setStyle(Paint.Style.STROKE);
128 | mBorderPaint.setAntiAlias(true);
129 | }
130 | if (setborderColor != 0) {
131 | mBorderPaint.setColor(getResources().getColor(setborderColor));
132 | }else {
133 | mBorderPaint.setColor(borderColor);
134 | }
135 | mBorderPaint.setStrokeWidth(borderWidth);
136 |
137 | if (mProgressPaint == null) {
138 | mProgressPaint = new Paint();
139 | mProgressPaint.setStyle(Paint.Style.STROKE);
140 | mProgressPaint.setAntiAlias(true);
141 | }
142 | if (setprogressColor != 0) {
143 | mProgressPaint.setColor(getResources().getColor(setprogressColor));
144 | } else mProgressPaint.setColor(progressCollor);
145 |
146 | mProgressPaint.setStrokeWidth(borderWidth);
147 |
148 | }
149 |
150 | @Override
151 | protected void onLayout(boolean b, int i, int i1, int i2, int i3) {
152 | //重点在于smallImageView的位置确定,默认为放在右下角,可自行拓展至其他位置
153 |
154 |
155 | double cos = Math.cos(angle * Math.PI / 180);
156 | double sin = Math.sin(angle * Math.PI / 180);
157 | double left = totalwidth / 2 + (radius * cos - smallRadius);
158 | double top = totalwidth / 2 + (radius * sin - smallRadius);
159 | int right = (int) (left + 2 * smallRadius);
160 | int bottom = (int) (top + 2 * smallRadius);
161 | bigImageView.layout(smallRadius + borderWidth / 2, smallRadius + borderWidth / 2, totalwidth - smallRadius - borderWidth / 2, totalwidth - smallRadius - borderWidth / 2);
162 | textView.layout((int) left, (int) top, right, bottom);
163 | smallImageView.layout((int) left, (int) top, right, bottom);
164 |
165 | }
166 |
167 | private void adjustThreeView() {
168 | bigImageView.setLayoutParams(new LayoutParams(radius, radius));
169 | smallRadius = (int) (radius * radiusScale);
170 | smallImageView.setLayoutParams(new LayoutParams(smallRadius, smallRadius));
171 | textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
172 | }
173 |
174 | private void addThreeView() {
175 |
176 |
177 | bigImageView = new CircleImageView(mContext);//大圆
178 |
179 | smallImageView = new CircleImageView(mContext);//小圆
180 |
181 | textView = new TextView(mContext);//文本
182 | textView.setGravity(Gravity.CENTER);
183 |
184 | addView(bigImageView, 0, new LayoutParams(radius, radius));
185 |
186 |
187 | smallRadius = (int) (radius * radiusScale);
188 |
189 | addView(smallImageView, 1, new LayoutParams(smallRadius, smallRadius));
190 |
191 |
192 | addView(textView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
193 | smallImageView.bringToFront();//使小图片位于最上层
194 |
195 |
196 | }
197 |
198 |
199 | private void initAttrs(AttributeSet attrs) {
200 | TintTypedArray tta = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
201 |
202 | R.styleable.IdentityImageView);
203 | bigImage = tta.getDrawable(R.styleable.IdentityImageView_iciv_bigimage);
204 | smallimage = tta.getDrawable(R.styleable.IdentityImageView_iciv_smallimage);
205 | angle = tta.getFloat(R.styleable.IdentityImageView_iciv_angle, 45);//小图以及进度条起始角度
206 | radiusScale = tta.getFloat(R.styleable.IdentityImageView_iciv_radiusscale, 0.28f);//大图和小图的比例
207 | isprogress = tta.getBoolean(R.styleable.IdentityImageView_iciv_isprogress, false);
208 | //是否要进度条,不为true的话,设置,进度条颜色和宽度也没用
209 |
210 | progressCollor = tta.getColor(R.styleable.IdentityImageView_iciv_progress_collor, 0);//边框进度条颜色
211 | borderColor = tta.getColor(R.styleable.IdentityImageView_iciv_border_color, 0);//边框颜色
212 | borderWidth = tta.getInteger(R.styleable.IdentityImageView_iciv_border_width, 0);//边框宽(,同为进度条)
213 | hintSmallView = tta.getBoolean(R.styleable.IdentityImageView_iciv_hint_smallimageview, false);//隐藏小图片
214 | if (hintSmallView) {
215 | smallImageView.setVisibility(GONE);
216 | }
217 | if (bigImage != null) {
218 | bigImageView.setImageDrawable(bigImage);
219 | }
220 | if (smallimage != null) {
221 | smallImageView.setImageDrawable(smallimage);
222 | }
223 |
224 | }
225 |
226 | /**
227 | * 获得textview
228 | *
229 | * @return textView
230 | */
231 | public TextView getTextView() {
232 | if (textView != null) return textView;
233 | else return null;
234 | }
235 |
236 | /**
237 | * 获得大图片
238 | *
239 | * @return bigImageView
240 | */
241 | public CircleImageView getBigCircleImageView() {
242 | if (bigImageView != null) return bigImageView;
243 | else return null;
244 | }
245 |
246 | /**
247 | * 获得小图片
248 | *
249 | * @return smallImageView
250 | */
251 | public CircleImageView getSmallCircleImageView() {
252 | if (smallImageView != null)
253 | return smallImageView;
254 | else return null;
255 | }
256 |
257 | /**
258 | * 设置进度条进度,一共360
259 | *
260 | * @param angle 进度大小
261 | */
262 | public void setProgress(float angle) {
263 | if (progresss == angle) {
264 | return;
265 | }
266 | progresss = angle;
267 | requestLayout();
268 | invalidate();
269 | }
270 |
271 | /**
272 | * 设置标识的角度
273 | *
274 | * @param angles 角度
275 | */
276 | public void setAngle(int angles) {
277 | if (angles == angle) return;
278 | angle = angles;
279 | requestLayout();
280 | invalidate();
281 | }
282 |
283 | /**
284 | * 设置标识的大小
285 | *
286 | * @param v 比例
287 | */
288 | public void setRadiusScale(float v) {
289 | if (v == radiusScale) return;
290 | radiusScale = v;
291 | requestLayout();
292 | invalidate();
293 |
294 | }
295 |
296 | /**
297 | * 设置是否可以有进度条
298 | *
299 | * @param b 是否有进度条
300 | */
301 | public void setIsprogress(boolean b) {
302 |
303 | if (b == isprogress) return;
304 | isprogress = b;
305 | requestLayout();
306 | invalidate();
307 | }
308 |
309 | /**
310 | * 设置填充的颜色
311 | *
312 | * @param color 边框颜色
313 | */
314 | public void setBorderColor(int color) {
315 | if (color == borderColor) return;
316 | setborderColor = color;
317 | requestLayout();
318 | invalidate();
319 |
320 | }
321 |
322 | /**
323 | * 设置进度条颜色
324 | *
325 | * @param color 进度条颜色
326 | */
327 | public void setProgressColor(int color) {
328 | if (color == progressCollor) return;
329 | setprogressColor = color;
330 | requestLayout();
331 | invalidate();
332 | }
333 |
334 | /**
335 | * @param width 边框和进度条宽度
336 | */
337 | public void setBorderWidth(int width) {
338 | if (width == borderWidth) return;
339 | borderWidth = width;
340 | requestLayout();//重走onLayout方法
341 | invalidate();//重走onDraw方法
342 | }
343 | }
344 |
--------------------------------------------------------------------------------
/imagelib/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/imagelib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | imagelib
3 |
4 |
--------------------------------------------------------------------------------
/imagelib/src/test/java/com/exampleenen/ruedy/imagelib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.exampleenen.ruedy.imagelib;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':imagelib'
2 |
--------------------------------------------------------------------------------