├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── codbking │ │ └── allitem │ │ └── exaple │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── codbking │ │ │ └── allitem │ │ │ └── exaple │ │ │ ├── AboutActivity.java │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_about.xml │ │ ├── activity_main.xml │ │ └── line.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── codbking │ └── allitem │ └── exaple │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── my.gif ├── mylibary ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── codbking │ │ └── view │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── iconfont_app.ttf │ ├── java │ │ └── com │ │ │ └── codbking │ │ │ └── view │ │ │ ├── BaseAdapterE.java │ │ │ ├── IconFontTextView.java │ │ │ ├── ItemView.java │ │ │ ├── ListDialog.java │ │ │ ├── Utils.java │ │ │ └── WebViewActivity.java │ └── res │ │ ├── drawable-xxhdpi │ │ ├── icon_swith_off.png │ │ └── icon_swith_on.png │ │ ├── drawable │ │ ├── list_selector_background.xml │ │ └── selector_switch.xml │ │ ├── layout │ │ ├── cbk_activity_web_view.xml │ │ ├── cbk_dialog_list.xml │ │ ├── cbk_item_icon_and_text.xml │ │ └── cbk_round_btn.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── iconfont_attr.xml │ │ ├── itemview_attr.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── codbking │ └── view │ └── 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/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 32 | 33 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AllItemView 2 | ## 万能的ItemView ## 3 | 4 | 考虑到每个APP都会用到一些常用的功能,比如,个人资料、关于、检测更新、设置以及各种列表 5 | 然而基本上这些功能的样式都是一个itemview,所以分装一个万能的itemview的必要性显得尤为重要 6 | 7 | **支持的样式** 8 | 9 | icon(本地或阿里巴巴iconfont位图)、标签、标签值、箭头、切换开关等任意组合,(后续考虑实现输入框的一些功能,和自定义样式) 10 | 11 | **功能** 12 | 13 | 0. 基本功能(icon、标签、标签值、箭头的任意组合) 14 | 1. 电话 15 | 2. 版本更新(目前点击更新需要自己实现,后续版本添加上去) 16 | 3. 跳转到网页 17 | 4. 选择弹框 18 | 5. 切换开关 19 | 6. 跳转到指定不带参数Activity 20 | 21 | **效果** 22 | 23 | ![Alt text](my.gif) 24 | 25 | 26 | 27 | **实现** 28 | 29 | 1. **Add it in your root build.gradle at the end of repositories** 30 | 31 | allprojects { 32 | repositories { 33 | ... 34 | maven { url 'https://jitpack.io' } 35 | } 36 | } 37 | 38 | 2. **Add the dependency** 39 | 40 | dependencies { 41 | compile 'com.github.codbking:AllItemView:v1.0.0' 42 | } 43 | 44 | 45 | 3. **xml** 46 | 47 | 53 | 54 | 55 | 4. **权限** 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.0" 6 | 7 | defaultConfig { 8 | applicationId "com.codbking.allitem.exaple" 9 | minSdkVersion 15 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(include: ['*.jar'], dir: 'libs') 27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | compile 'com.android.support:appcompat-v7:25.1.0' 31 | compile 'com.github.codbking:AllItemView:v1.0.0' 32 | testCompile 'junit:junit:4.12' 33 | } 34 | -------------------------------------------------------------------------------- /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 E:\Android\sdk1/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/codbking/allitem/exaple/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.codbking.allitem.exaple; 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.codbking.allitem.exaple", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/codbking/allitem/exaple/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.codbking.allitem.exaple; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class AboutActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_about); 12 | 13 | getSupportActionBar().setTitle("关于"); 14 | getSupportActionBar().setDisplayShowHomeEnabled(true); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/codbking/allitem/exaple/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.codbking.allitem.exaple; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class MainActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_main); 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 20 | 21 | 27 | 28 | 29 | 33 | 34 | 42 | 43 | 44 | 45 | 52 | 53 | 54 | 55 | 63 | 64 | 65 | 69 | 70 | 77 | 78 | 79 | 85 | 86 | 87 | 88 | 89 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /app/src/main/res/layout/line.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/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/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #e6e6e8 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | My Application 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/codbking/allitem/exaple/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.codbking.allitem.exaple; 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 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 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 | maven { url 'https://jitpack.io' } 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /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=-Xmx1536m 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/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/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 | -------------------------------------------------------------------------------- /my.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/my.gif -------------------------------------------------------------------------------- /mylibary/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /mylibary/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.codbking' 5 | 6 | android { 7 | compileSdkVersion 25 8 | buildToolsVersion "25.0.0" 9 | 10 | defaultConfig { 11 | minSdkVersion 15 12 | targetSdkVersion 25 13 | versionCode 1 14 | versionName "1.0.0" 15 | 16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 17 | 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | compile fileTree(dir: 'libs', include: ['*.jar']) 29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 30 | exclude group: 'com.android.support', module: 'support-annotations' 31 | }) 32 | compile 'com.android.support:appcompat-v7:25.0.1' 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /mylibary/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 E:\Android\sdk1/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 | -------------------------------------------------------------------------------- /mylibary/src/androidTest/java/com/codbking/view/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.codbking.view; 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.codbking.app", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mylibary/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mylibary/src/main/assets/iconfont_app.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/mylibary/src/main/assets/iconfont_app.ttf -------------------------------------------------------------------------------- /mylibary/src/main/java/com/codbking/view/BaseAdapterE.java: -------------------------------------------------------------------------------- 1 | package com.codbking.view; 2 | 3 | import android.widget.BaseAdapter; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by codbking on 2016/4/11. 9 | */ 10 | abstract class BaseAdapterE extends BaseAdapter { 11 | 12 | private List list; 13 | private T[]data; 14 | 15 | public void setData(List data) { 16 | this.list=data; 17 | notifyDataSetChanged(); 18 | } 19 | 20 | public void setData(T[] data) { 21 | this.data=data; 22 | notifyDataSetChanged(); 23 | } 24 | 25 | public void addData(List date) { 26 | if (date != null) { 27 | this.list.addAll(date); 28 | } 29 | notifyDataSetChanged(); 30 | } 31 | 32 | @Override 33 | public int getCount() { 34 | if(data!=null){ 35 | return data.length; 36 | } 37 | return list == null ? 0 : list.size(); 38 | } 39 | 40 | @Override 41 | public T getItem(int position) { 42 | if(data!=null){ 43 | return data[position]; 44 | } 45 | return list.get(position); 46 | } 47 | 48 | @Override 49 | public long getItemId(int i) { 50 | return i; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /mylibary/src/main/java/com/codbking/view/IconFontTextView.java: -------------------------------------------------------------------------------- 1 | package com.codbking.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Typeface; 6 | import android.text.Html; 7 | import android.text.TextUtils; 8 | import android.util.AttributeSet; 9 | import android.widget.TextView; 10 | 11 | /** 12 | * Created by codbking 13 | */ 14 | public class IconFontTextView extends TextView { 15 | 16 | 17 | 18 | 19 | private String iconfontString = ""; 20 | private String textImg = ""; 21 | 22 | private String icon = ""; 23 | private String selectIcon = ""; 24 | 25 | 26 | public IconFontTextView(Context context) { 27 | super(context); 28 | init(); 29 | } 30 | 31 | public IconFontTextView(Context context, AttributeSet attrs) { 32 | super(context, attrs); 33 | 34 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconFontTextView); 35 | iconfontString = a.getString(R.styleable.IconFontTextView_iconfont); 36 | textImg = a.getString(R.styleable.IconFontTextView_textImg); 37 | a.recycle(); 38 | init(); 39 | } 40 | 41 | public void setHtmlText(String text) { 42 | CharSequence charSequence = Html.fromHtml(text, null, null); 43 | setText(charSequence); 44 | } 45 | 46 | public void setTextImg(String text) { 47 | if (TextUtils.isEmpty(text)) { 48 | return; 49 | } 50 | CharSequence charSequence = Html.fromHtml("&#x" + text, null, null); 51 | setText(charSequence); 52 | } 53 | 54 | public void setTextImg2(String text) { 55 | if (TextUtils.isEmpty(text)) { 56 | return; 57 | } 58 | CharSequence charSequence = Html.fromHtml("&#x" + text + ";", null, null); 59 | setText(charSequence); 60 | } 61 | 62 | public void setIcon(String text) { 63 | CharSequence charSequence = Html.fromHtml(text, null, null); 64 | setText(charSequence); 65 | } 66 | 67 | private void init() { 68 | if (TextUtils.isEmpty(iconfontString)) { 69 | iconfontString = "icon.ttf"; 70 | } 71 | Typeface iconfont = Typeface.createFromAsset(getContext().getAssets(), iconfontString); 72 | setTypeface(iconfont); 73 | 74 | if (!TextUtils.isEmpty(textImg)) { 75 | if (textImg.contains("@")) { 76 | String[] arr = textImg.split("@"); 77 | icon = arr[0]; 78 | selectIcon = arr[1]; 79 | }else{ 80 | icon=textImg; 81 | } 82 | 83 | setTextImg2(icon); 84 | } 85 | } 86 | 87 | @Override 88 | public void setSelected(boolean selected) { 89 | super.setSelected(selected); 90 | if (TextUtils.isEmpty(selectIcon)) { 91 | return; 92 | } 93 | if (selected) { 94 | setTextImg2(selectIcon); 95 | } else { 96 | setTextImg2(icon); 97 | } 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /mylibary/src/main/java/com/codbking/view/ItemView.java: -------------------------------------------------------------------------------- 1 | package com.codbking.view; 2 | 3 | import android.Manifest; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.content.res.TypedArray; 8 | import android.graphics.drawable.Drawable; 9 | import android.net.Uri; 10 | import android.support.v4.app.ActivityCompat; 11 | import android.text.TextUtils; 12 | import android.util.AttributeSet; 13 | import android.view.LayoutInflater; 14 | import android.view.View; 15 | import android.widget.FrameLayout; 16 | import android.widget.ImageView; 17 | import android.widget.TextView; 18 | 19 | /** 20 | * Created by codbking 21 | * //万能itemview 22 | * 0 default 23 | * 1 可以打电话 24 | * 2 版本更新 25 | * 3 调转网页 26 | * 4 选择弹框 27 | * 5 切换开关 28 | * 6 调整到特定不带参数activity 29 | */ 30 | 31 | public class ItemView extends FrameLayout implements View.OnClickListener { 32 | 33 | private IconFontTextView iconTv; 34 | private TextView textTv; 35 | private TextView valueTv; 36 | 37 | private String icon; 38 | private String text; 39 | private Drawable mDrawable; 40 | private String value; 41 | private String activityName; 42 | private String url; 43 | private CharSequence[] selectValue; 44 | private Type type = Type.TEXT; 45 | 46 | private android.widget.ImageView image; 47 | private IconFontTextView arrorView; 48 | private ImageView switchView; 49 | 50 | private OnSwitchListener onSwitchListener; 51 | 52 | public interface OnSwitchListener { 53 | void onSwith(boolean isSelect); 54 | } 55 | 56 | private enum Type { 57 | TEXT(0), 58 | PHONE(1), 59 | VERSION(2), 60 | WEB(3), 61 | SELECT(4), 62 | SWITCHBTN(5), 63 | ACTIVITY(6); 64 | 65 | private int value; 66 | 67 | Type(int value) { 68 | this.value = value; 69 | } 70 | 71 | public static Type getType(int value) { 72 | switch (value) { 73 | case 0: 74 | return Type.TEXT; 75 | case 1: 76 | return Type.PHONE; 77 | case 2: 78 | return Type.VERSION; 79 | case 3: 80 | return Type.WEB; 81 | case 4: 82 | return Type.SELECT; 83 | case 5: 84 | return Type.SWITCHBTN; 85 | case 6: 86 | return Type.ACTIVITY; 87 | } 88 | return Type.TEXT; 89 | } 90 | 91 | } 92 | 93 | //listener 94 | public void setOnSwitchListener(OnSwitchListener onSwitchListener) { 95 | this.onSwitchListener = onSwitchListener; 96 | } 97 | 98 | public void setSwitchViewListenern(OnClickListener listener) { 99 | switchView.setOnClickListener(listener); 100 | } 101 | 102 | public ItemView(Context context) { 103 | super(context); 104 | } 105 | public ItemView(Context context, AttributeSet attrs) { 106 | super(context, attrs); 107 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ItemView); 108 | icon = a.getString(R.styleable.ItemView_ItemView_icon); 109 | text = a.getString(R.styleable.ItemView_ItemView_text); 110 | mDrawable = a.getDrawable(R.styleable.ItemView_ItemView_src); 111 | value = a.getString(R.styleable.ItemView_ItemView_value); 112 | type = Type.getType(a.getInt(R.styleable.ItemView_ItemView_type, 0)); 113 | selectValue = a.getTextArray(R.styleable.ItemView_ItemView_select_value); 114 | activityName=a.getString(R.styleable.ItemView_ItemView_acname); 115 | url=a.getString(R.styleable.ItemView_ItemView_url); 116 | a.recycle(); 117 | init(); 118 | } 119 | 120 | private void init() { 121 | 122 | View view = LayoutInflater.from(getContext()).inflate(R.layout.cbk_item_icon_and_text, this); 123 | this.switchView = (ImageView) view.findViewById(R.id.switchView); 124 | this.arrorView = (IconFontTextView) view.findViewById(R.id.arrorView); 125 | this.image = (ImageView) view.findViewById(R.id.image); 126 | this.valueTv = (TextView) view.findViewById(R.id.valueTv); 127 | this.textTv = (TextView) view.findViewById(R.id.text); 128 | this.iconTv = (IconFontTextView) view.findViewById(R.id.icon); 129 | //setvalue 130 | textTv.setText(text); 131 | valueTv.setText(value); 132 | 133 | if (TextUtils.isEmpty(icon)) { 134 | iconTv.setVisibility(View.GONE); 135 | } else { 136 | iconTv.setVisibility(View.VISIBLE); 137 | iconTv.setTextImg2(icon); 138 | } 139 | if (mDrawable == null) { 140 | image.setVisibility(View.GONE); 141 | } else { 142 | image.setVisibility(View.VISIBLE); 143 | image.setImageDrawable(mDrawable); 144 | } 145 | 146 | if (type == Type.SWITCHBTN) { 147 | arrorView.setVisibility(GONE); 148 | switchView.setVisibility(VISIBLE); 149 | } 150 | 151 | setTypeValue(); 152 | 153 | } 154 | 155 | private void setTypeValue() { 156 | switch(type){ 157 | case PHONE: 158 | valueTv.setTextColor(Utils.getColor(getContext(),R.color.text_bule)); 159 | setOnClickListener(this); 160 | break; 161 | case VERSION: 162 | valueTv.setText(Utils.getVersionName(getContext())); 163 | setOnClickListener(this); 164 | break; 165 | case SELECT: 166 | setOnClickListener(this); 167 | if (selectValue == null || selectValue.length == 0) { 168 | return; 169 | } 170 | setSelectValue(selectValue[0].toString()); 171 | break; 172 | case SWITCHBTN: 173 | switchView.setOnClickListener(new OnClickListener() { 174 | @Override 175 | public void onClick(View view) { 176 | 177 | view.setSelected(!view.isSelected()); 178 | 179 | if (onSwitchListener != null) { 180 | onSwitchListener.onSwith(view.isSelected()); 181 | } 182 | 183 | } 184 | }); 185 | break; 186 | case WEB: 187 | case ACTIVITY: 188 | setOnClickListener(this); 189 | break; 190 | 191 | } 192 | } 193 | 194 | 195 | @Override 196 | public void setSelected(boolean selected) { 197 | if(type==Type.SWITCHBTN){ 198 | switchView.setSelected(selected); 199 | }else{ 200 | super.setSelected(selected); 201 | } 202 | } 203 | 204 | @Override 205 | public boolean isSelected() { 206 | if(type==Type.SWITCHBTN){ 207 | return switchView.isSelected(); 208 | } 209 | return super.isSelected(); 210 | } 211 | 212 | 213 | public void setLabel(String label) { 214 | this.textTv.setText(label); 215 | } 216 | 217 | public void setText(String value) { 218 | this.value = value; 219 | this.valueTv.setText(value); 220 | } 221 | 222 | public String getSelectValue() { 223 | return valueTv.getTag() == null ? "" : valueTv.getTag().toString(); 224 | } 225 | private void setSelectValue(String s) { 226 | if (s.contains("@")) { 227 | String[] arr = s.split("@"); 228 | valueTv.setText(arr[0]); 229 | valueTv.setTag(arr[1]); 230 | } else { 231 | valueTv.setText(s); 232 | valueTv.setTag(s); 233 | } 234 | } 235 | 236 | 237 | @Override 238 | public void onClick(View view) { 239 | switch (type) { 240 | case PHONE: 241 | Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + value)); 242 | if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { 243 | return; 244 | } 245 | getContext().startActivity(intent); 246 | break; 247 | case VERSION: 248 | // CheckUtils.checkForUpdate(getContext()); 249 | break; 250 | case SELECT: 251 | if (selectValue == null || selectValue.length == 0) { 252 | return; 253 | } 254 | //判断有没有带值过来 255 | ListDialog dialog = new ListDialog(getContext()); 256 | dialog.setOnItemClickListener(new ListDialog.OnItemClickListener() { 257 | @Override 258 | public void onItemClick(CharSequence charSequence) { 259 | setSelectValue(charSequence.toString()); 260 | } 261 | }); 262 | dialog.setData(selectValue, "@"); 263 | dialog.show(); 264 | break; 265 | case WEB: 266 | WebViewActivity.start(getContext(), url); 267 | break; 268 | case ACTIVITY: 269 | try { 270 | intent=new Intent(getContext(),Class.forName(activityName)); 271 | getContext().startActivity(intent); 272 | } catch (ClassNotFoundException e) { 273 | e.printStackTrace(); 274 | } 275 | break; 276 | } 277 | } 278 | 279 | } 280 | -------------------------------------------------------------------------------- /mylibary/src/main/java/com/codbking/view/ListDialog.java: -------------------------------------------------------------------------------- 1 | package com.codbking.view; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | import android.view.Gravity; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.view.WindowManager; 11 | import android.widget.AbsListView; 12 | import android.widget.AdapterView; 13 | import android.widget.ListView; 14 | import android.widget.TextView; 15 | 16 | import java.lang.reflect.Method; 17 | import java.util.List; 18 | 19 | /** 20 | * Created by codbking 21 | */ 22 | public class ListDialog extends Dialog implements AdapterView.OnItemClickListener { 23 | 24 | private ListView list; 25 | private MyAdatepr adapter; 26 | 27 | private String methodName; 28 | private OnItemClickListener onItemClickListener; 29 | 30 | public ListDialog(Context context) { 31 | super(context,R.style.dialogStyle); 32 | } 33 | 34 | public void setData(T[] data, String methodName) { 35 | if (adapter == null) { 36 | adapter = new MyAdatepr(); 37 | } 38 | adapter.setData(data); 39 | this.methodName = methodName; 40 | } 41 | 42 | public void setData(List data, String methodName) { 43 | if (adapter == null) { 44 | adapter = new MyAdatepr(); 45 | } 46 | adapter.setData(data); 47 | this.methodName = methodName; 48 | } 49 | 50 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) { 51 | this.onItemClickListener = onItemClickListener; 52 | } 53 | 54 | protected void setFullScreenAndLayoutBottom() { 55 | WindowManager.LayoutParams params = getWindow().getAttributes(); 56 | params.gravity = Gravity.BOTTOM; 57 | params.width = (int) Utils.getScreenWidth(getContext()); 58 | getWindow().setAttributes(params); 59 | getWindow().setWindowAnimations(R.style.BottomPushAni); 60 | } 61 | 62 | protected void setLayoutCentre() { 63 | WindowManager.LayoutParams params = getWindow().getAttributes(); 64 | params.gravity = Gravity.CENTER; 65 | getWindow().setAttributes(params); 66 | } 67 | 68 | 69 | 70 | @Override 71 | protected void onCreate(Bundle savedInstanceState) { 72 | super.onCreate(savedInstanceState); 73 | setContentView(R.layout.cbk_dialog_list); 74 | setFullScreenAndLayoutBottom(); 75 | 76 | this.list = (ListView) findViewById(R.id.list); 77 | 78 | View footView = LayoutInflater.from(getContext()).inflate(R.layout.cbk_round_btn, null); 79 | TextView textView = (TextView) footView.findViewById(R.id.text); 80 | textView.setBackgroundDrawable( 81 | Utils.getRoundSelectorDrawable(0xcc, Utils.getColor(getContext(),R.color.white), 5)); 82 | 83 | list.addFooterView(footView, null, false); 84 | list.setFooterDividersEnabled(false); 85 | 86 | list.setOnItemClickListener(this); 87 | textView.setOnClickListener(new View.OnClickListener() { 88 | @Override 89 | public void onClick(View v) { 90 | dismiss(); 91 | } 92 | }); 93 | 94 | if (adapter == null) { 95 | adapter = new MyAdatepr(); 96 | } 97 | list.setAdapter(adapter); 98 | } 99 | 100 | //判断是不是基本类型 101 | private boolean isBasicTypes(E t) { 102 | return t instanceof String || t instanceof CharSequence || 103 | t instanceof Integer || t instanceof Double || 104 | t instanceof Float || t instanceof Long; 105 | } 106 | 107 | private class MyAdatepr extends BaseAdapterE { 108 | 109 | @Override 110 | public View getView(final int position, View convertView, ViewGroup parent) { 111 | 112 | if (convertView == null) { 113 | TextView textView=new TextView(parent.getContext()); 114 | textView.setBackgroundResource(R.drawable.list_selector_background); 115 | textView.setGravity(Gravity.CENTER); 116 | AbsListView.LayoutParams params = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 117 | getContext().getResources().getDimensionPixelSize(R.dimen.item_height)); 118 | textView.setLayoutParams(params); 119 | textView.setTextColor(getContext().getResources().getColor(R.color.text_body)); 120 | convertView=textView; 121 | } 122 | 123 | T object = getItem(position); 124 | TextView textView = (TextView) convertView; 125 | 126 | if (isBasicTypes(object)) { 127 | if(methodName.equals("@")){ 128 | textView.setText(object.toString().split("@")[0]); 129 | }else{ 130 | textView.setText(object.toString()); 131 | } 132 | } else { 133 | try { 134 | Method m = object.getClass().getDeclaredMethod(methodName); 135 | Object result = m.invoke(object); 136 | textView.setText(result.toString()); 137 | } catch (Exception e) { 138 | e.printStackTrace(); 139 | } 140 | } 141 | return convertView; 142 | } 143 | 144 | } 145 | 146 | 147 | @Override 148 | public void onItemClick(AdapterView parent, View view, int position, long id) { 149 | dismiss(); 150 | T t = (T) parent.getItemAtPosition(position); 151 | if (onItemClickListener != null) { 152 | onItemClickListener.onItemClick(t); 153 | } 154 | } 155 | 156 | 157 | public interface OnItemClickListener { 158 | void onItemClick(T t); 159 | } 160 | 161 | 162 | 163 | } 164 | -------------------------------------------------------------------------------- /mylibary/src/main/java/com/codbking/view/Utils.java: -------------------------------------------------------------------------------- 1 | package com.codbking.view; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageInfo; 5 | import android.content.pm.PackageManager; 6 | import android.content.res.Resources; 7 | import android.graphics.Color; 8 | import android.graphics.drawable.Drawable; 9 | import android.graphics.drawable.GradientDrawable; 10 | import android.graphics.drawable.StateListDrawable; 11 | import android.view.WindowManager; 12 | 13 | /** 14 | * Created by wulang on 2016/12/10. 15 | */ 16 | class Utils { 17 | 18 | public static int getColor(Context context,int res){ 19 | Resources r=context.getResources(); 20 | return r.getColor(res); 21 | } 22 | 23 | public static float getScreenWidth(Context context) { 24 | WindowManager wm = (WindowManager) context 25 | .getSystemService(Context.WINDOW_SERVICE); 26 | int width = wm.getDefaultDisplay().getWidth(); 27 | return width; 28 | } 29 | 30 | 31 | public static int px(float dipValue) { 32 | Resources r=Resources.getSystem(); 33 | final float scale =r.getDisplayMetrics().density; 34 | return (int) (dipValue * scale + 0.5f); 35 | } 36 | 37 | 38 | //获取显示版本 39 | public static String getVersionName(Context context) { 40 | try { 41 | PackageManager manager =context.getPackageManager(); 42 | PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0); 43 | String version = info.versionName; 44 | return version; 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | return ""; 48 | } 49 | } 50 | 51 | //获取版本信息 52 | public static int getVersion(Context context) { 53 | try { 54 | PackageManager manager = context.getPackageManager(); 55 | PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0); 56 | int version = info.versionCode; 57 | return version; 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | return -1; 61 | } 62 | } 63 | 64 | public static StateListDrawable getRoundSelectorDrawable(int alpha, int color, int radir) { 65 | Drawable pressDrawable = getRoundDrawalbe(alpha, color, radir); 66 | Drawable normalDrawable = getRoundDrawalbe(color, radir); 67 | return getStateListDrawable(pressDrawable, normalDrawable); 68 | } 69 | 70 | //获取带透明度的圆角矩形 71 | public static Drawable getRoundDrawalbe(int alpha, int color, int radir) { 72 | int normalColor = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)); 73 | Drawable normalDrawable = getRoundDrawalbe(normalColor, radir); 74 | return normalDrawable; 75 | } 76 | 77 | 78 | //根据颜色获取圆角矩形 79 | public static Drawable getRoundDrawalbe(int color, int radir) { 80 | radir = px(radir); 81 | GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{color, color}); 82 | drawable.setCornerRadius(radir); 83 | return drawable; 84 | } 85 | 86 | public static StateListDrawable getStateListDrawable(Drawable pressDrawable, Drawable normalDrawable) { 87 | int pressed = android.R.attr.state_pressed; 88 | int select = android.R.attr.state_selected; 89 | StateListDrawable drawable = new StateListDrawable(); 90 | drawable.addState(new int[]{pressed}, pressDrawable); 91 | drawable.addState(new int[]{select}, pressDrawable); 92 | drawable.addState(new int[]{}, normalDrawable); 93 | return drawable; 94 | } 95 | 96 | 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /mylibary/src/main/java/com/codbking/view/WebViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.codbking.view; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.webkit.WebView; 8 | import android.webkit.WebViewClient; 9 | 10 | public class WebViewActivity extends AppCompatActivity { 11 | 12 | private WebView mWebView; 13 | 14 | public static void start(Context context, String url) { 15 | Intent starter = new Intent(context, WebViewActivity.class); 16 | starter.putExtra("url", url); 17 | context.startActivity(starter); 18 | } 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.cbk_activity_web_view); 24 | this.mWebView = (WebView) findViewById(R.id.webView); 25 | 26 | mWebView.getSettings().setJavaScriptEnabled(true); 27 | mWebView.loadUrl(getIntent().getStringExtra("url")); 28 | mWebView.setWebViewClient(new WebViewClient(){ 29 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 30 | view.loadUrl(url); 31 | return true; 32 | } 33 | }); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /mylibary/src/main/res/drawable-xxhdpi/icon_swith_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/mylibary/src/main/res/drawable-xxhdpi/icon_swith_off.png -------------------------------------------------------------------------------- /mylibary/src/main/res/drawable-xxhdpi/icon_swith_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/mylibary/src/main/res/drawable-xxhdpi/icon_swith_on.png -------------------------------------------------------------------------------- /mylibary/src/main/res/drawable/list_selector_background.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /mylibary/src/main/res/drawable/selector_switch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /mylibary/src/main/res/layout/cbk_activity_web_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /mylibary/src/main/res/layout/cbk_dialog_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | -------------------------------------------------------------------------------- /mylibary/src/main/res/layout/cbk_item_icon_and_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 23 | 24 | 32 | 33 | 44 | 45 | 54 | 55 | 65 | 66 | 74 | 75 | -------------------------------------------------------------------------------- /mylibary/src/main/res/layout/cbk_round_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /mylibary/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/mylibary/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /mylibary/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/mylibary/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /mylibary/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/mylibary/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mylibary/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/mylibary/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mylibary/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codbking/AllItemView/12ac7b36e57f3a8bd5ca8d2af06e314c2f02984f/mylibary/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mylibary/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /mylibary/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #ffffff 8 | #e94f25 9 | 10 | #333333 11 | #676769 12 | #89898b 13 | #d6d6d9 14 | #00b0ec 15 | 16 | //line 17 | #d6d6d9 18 | #e6e6e8 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /mylibary/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 42.24dp 7 | 14.4dp 8 | 16dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /mylibary/src/main/res/values/iconfont_attr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /mylibary/src/main/res/values/itemview_attr.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 | -------------------------------------------------------------------------------- /mylibary/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 万能AllItemView 3 | 4 | 5 | 北京@1 6 | 上海@2 7 | 广州@3 8 | 深圳@4 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /mylibary/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 17 | 18 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /mylibary/src/test/java/com/codbking/view/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.codbking.view; 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 ':mylibary', ':app' 2 | --------------------------------------------------------------------------------