Skip to content

Commit

Permalink
重新组织了代码,加上了可爱的注释
Browse files Browse the repository at this point in the history
  • Loading branch information
fengt committed Dec 26, 2016
1 parent b84bd3f commit eb8cba4
Show file tree
Hide file tree
Showing 35 changed files with 187 additions and 139 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.DS_Store
/build
/captures
.externalNativeBuild
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

4 changes: 2 additions & 2 deletions .idea/gradle.xml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

4 changes: 2 additions & 2 deletions .idea/modules.xml

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

2 changes: 1 addition & 1 deletion .idea/vcs.xml

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

This file was deleted.

13 changes: 0 additions & 13 deletions AnFQNumEditTextLib/src/main/AndroidManifest.xml

This file was deleted.

3 changes: 0 additions & 3 deletions AnFQNumEditTextLib/src/main/res/values/strings.xml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 25
buildToolsVersion "25.0.0"

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
Expand All @@ -20,6 +23,9 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package fj.edittextcount.lib;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("fj.edittextcount.lib.test", appContext.getPackageName());
}
}
8 changes: 8 additions & 0 deletions FJEditTextCountLib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="fj.edittextcount.lib">

<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package anfq.numedittext.lib;
package fj.edittextcount.lib;

import android.content.Context;
import android.graphics.Color;
Expand All @@ -13,11 +13,21 @@
import android.widget.TextView;

/**
* AnFQ
* @time 2016-10-09 14:50
* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
* ┃ ╭﹉﹊﹉╮ ╔═════╗╔═════╗╔═════╗┃
* ┃╭╯老斯基㊣╠╣淡漠de人生╠╣2016-10-09╠╣ 欢迎关注 ╣┃
* ┃╰⊙┈┈┈⊙╯╚◎═══◎╝╚◎═══◎╝╚◎═══◎╝┃
* ┣━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┫
* ┃GitHub┃https://github.com/FJ917 ┃
* ┃简 书┃http://www.jianshu.com/users/3d2770e6e489 ┃
* ┃Q Q┃511334686 ┃
* ┗━━━┻━━━━━━━━━━━━━━━━━━━━━━━━┛
*/

public class AnFQNumEditText extends RelativeLayout{

// JUMP
public class FJEditTextCount extends RelativeLayout {

//类型1(单数类型):TextView显示总字数,然后根据输入递减.例:100,99,98
//类型2(百分比类型):TextView显示总字数和当前输入的字数,例:0/100,1/100,2/100
public static final String SINGULAR = "Singular";//类型1(单数类型)
Expand All @@ -28,13 +38,13 @@ public class AnFQNumEditText extends RelativeLayout{
private String TYPES = SINGULAR;//类型
private int MaxNum = 100;//最大字符

public AnFQNumEditText(Context context) {
public FJEditTextCount(Context context) {
this(context, null);
}

public AnFQNumEditText(Context context, AttributeSet attrs) {
public FJEditTextCount(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.anfq_num_edittext, this, true);
LayoutInflater.from(context).inflate(R.layout.fj_edittext_count, this, true);
etContent = (EditText) findViewById(R.id.etContent);
tvNum = (TextView) findViewById(R.id.tvNum);
vLine = findViewById(R.id.vLine);
Expand All @@ -44,7 +54,7 @@ public AnFQNumEditText(Context context, AttributeSet attrs) {
* 设置显示
* @return
*/
public AnFQNumEditText show(){
public FJEditTextCount show(){
if(TYPES.equals(SINGULAR)){//类型1
tvNum.setText(String.valueOf(MaxNum));
}else if(TYPES.equals(PERCENTAGE)){//类型2
Expand All @@ -62,7 +72,7 @@ public AnFQNumEditText show(){
* @param color --颜色值
* @return
*/
public AnFQNumEditText setLineColor(String color){
public FJEditTextCount setLineColor(String color){
vLine.setBackgroundColor(Color.parseColor(color));
return this;
}
Expand All @@ -72,7 +82,7 @@ public AnFQNumEditText setLineColor(String color){
* @param type --类型
* @return
*/
public AnFQNumEditText setType(String type){
public FJEditTextCount setType(String type){
TYPES = type;
return this;
}
Expand All @@ -82,7 +92,7 @@ public AnFQNumEditText setType(String type){
* @param num --字数
* @return
*/
public AnFQNumEditText setLength(int num){
public FJEditTextCount setLength(int num){
this.MaxNum = num;
return this;
}
Expand All @@ -92,7 +102,7 @@ public AnFQNumEditText setLength(int num){
* @param str --设置内容
* @return
*/
public AnFQNumEditText setEtHint(String str){
public FJEditTextCount setEtHint(String str){
etContent.setHint(str);
return this;
}
Expand All @@ -102,7 +112,7 @@ public AnFQNumEditText setEtHint(String str){
* @param px --最小高度(单位px)
* @return
*/
public AnFQNumEditText setEtMinHeight(int px){
public FJEditTextCount setEtMinHeight(int px){
etContent.setMinHeight(px);
return this;
}
Expand Down
3 changes: 3 additions & 0 deletions FJEditTextCountLib/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">FJEditTextCountLib</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package anfq.numedittext.lib;
package fj.edittextcount.lib;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
Expand Down
15 changes: 7 additions & 8 deletions README-En.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@

> ### Preview
![example.gif](http://upload-images.jianshu.io/upload_images/2071764-b45df6bf1d00205e.gif)


![example.gif](http://upload-images.jianshu.io/upload_images/2071764-7be37be47251b7d4.gif)
| PERCENTAGE | SINGULAR |
|:-------------:|:-------------:|
| ![PERCENTAGE.gif](http://upload-images.jianshu.io/upload_images/2071764-b45df6bf1d00205e.gif) | ![SINGULAR.gif](http://upload-images.jianshu.io/upload_images/2071764-7be37be47251b7d4.gif) |

> ### usage:
1. xml Add to

<anfq.numedittext.lib.AnFQNumEditText
android:id="@+id/anetDemo"
<fj.edittextcount.lib.FJEditTextCount
android:id="@+id/fjEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

2. java Set up

anetDemo = (AnFQNumEditText) findViewById(R.id.anetDemo);
anetDemo.setEtHint("content")//Set prompt text
fjEdit = (FJEditTextCount) findViewById(R.id.fjEdit);
fjEdit.setEtHint("content")//Set prompt text
.setEtMinHeight(200)//Set minimum height in px
.setLength(50)//Set the total number of words
//type(SINGULAR)(PERCENTAGE)
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
---

> ### 栗子惯例,先上GIF
![栗子1.gif](http://upload-images.jianshu.io/upload_images/2071764-b45df6bf1d00205e.gif)

> ### 栗子惯例,先上GIF
![栗子2.gif](http://upload-images.jianshu.io/upload_images/2071764-7be37be47251b7d4.gif)
| PERCENTAGE效果 | SINGULAR效果 |
|:-------------:|:-------------:|
| ![百分比类型.gif](http://upload-images.jianshu.io/upload_images/2071764-b45df6bf1d00205e.gif) | ![单数类型.gif](http://upload-images.jianshu.io/upload_images/2071764-7be37be47251b7d4.gif) |

> ### 用法:
1. xml添加

<anfq.numedittext.lib.AnFQNumEditText
android:id="@+id/anetDemo"
<fj.edittextcount.lib.FJEditTextCount
android:id="@+id/fjEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

2. java设置

anetDemo = (AnFQNumEditText) findViewById(R.id.anetDemo);
anetDemo.setEtHint("内容")//设置提示文字
fjEdit = (FJEditTextCount) findViewById(R.id.fjEdit);
fjEdit.setEtHint("内容")//设置提示文字
.setEtMinHeight(200)//设置最小高度,单位px
.setLength(50)//设置总字数
//TextView显示类型(SINGULAR单数类型)(PERCENTAGE百分比类型)
.setType(AnFQNumEditText.SINGULAR)
.setType(FJEditTextCount.SINGULAR)
.setLineColor("#3F51B5")//设置横线颜色
.show();
Expand Down
19 changes: 11 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "anfq.numedittext.demo"
applicationId "fj.edittextcount.test"
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -20,8 +20,11 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(':AnFQNumEditTextLib')
compile project(':FJEditTextCountLib')
}
Loading

0 comments on commit eb8cba4

Please sign in to comment.