Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
FaceAI committed Nov 4, 2019
1 parent 111e8e4 commit 1e7941a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 25 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@

# Gradle 集成使用
```
implementation 'anylife.scrolltextview:ScrollTextviewLib:1.3.7' [new]
implementation 'anylife.scrolltextview:ScrollTextviewLib:1.4.5'
```

# Maven 集成使用
```
<dependency>
<groupId>anylife.scrolltextview</groupId>
<artifactId>ScrollTextviewLib</artifactId>
<version>1.3.7</version>
<version>1.4.5</version>
<type>pom</type>
</dependency>
```
Expand Down
2 changes: 1 addition & 1 deletion ScrollTextviewLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
}

version = "1.4.4" //版本号,每次提交到Jcenter都要修改
version = "1.4.5" //版本号,每次提交到Jcenter都要修改
def siteUrl = "https://github.com/AnyLifeZLB/ScrollTextView" // project homepage
def gitUrl = "https://github.com/AnyLifeZLB/ScrollTextView.git" // project git
group = "anylife.scrolltextview"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
* NEWEST LOG :
* 1.setText() immediately take effect (v1.3.6)
* 2.support scroll forever (v1.3.7)
* <p>
* <p>
* <p>
* <p>
*
* Basic knowledge:https://www.jianshu.com/p/918fec73a24d
*
* @author [email protected] 2013/09/02
Expand Down Expand Up @@ -86,15 +83,15 @@ public ScrollTextView(Context context, AttributeSet attrs) {
surfaceHolder = this.getHolder(); //get The surface holder
surfaceHolder.addCallback(this);
paint = new Paint();
TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.ScrollText);
clickEnable = arr.getBoolean(R.styleable.ScrollText_clickEnable, clickEnable);
isHorizontal = arr.getBoolean(R.styleable.ScrollText_isHorizontal, isHorizontal);
speed = arr.getInteger(R.styleable.ScrollText_speed, speed);
text = arr.getString(R.styleable.ScrollText_text);
int textColor = arr.getColor(R.styleable.ScrollText_text_color, Color.BLACK);
textSize = arr.getDimension(R.styleable.ScrollText_text_size, textSize);
needScrollTimes = arr.getInteger(R.styleable.ScrollText_times, Integer.MAX_VALUE);
isScrollForever = arr.getBoolean(R.styleable.ScrollText_isScrollForever, true);
TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.ScrollTextView);
clickEnable = arr.getBoolean(R.styleable.ScrollTextView_clickEnable, clickEnable);
isHorizontal = arr.getBoolean(R.styleable.ScrollTextView_isHorizontal, isHorizontal);
speed = arr.getInteger(R.styleable.ScrollTextView_speed, speed);
text = arr.getString(R.styleable.ScrollTextView_text);
int textColor = arr.getColor(R.styleable.ScrollTextView_text_color, Color.BLACK);
textSize = arr.getDimension(R.styleable.ScrollTextView_text_size, textSize);
needScrollTimes = arr.getInteger(R.styleable.ScrollTextView_times, Integer.MAX_VALUE);
isScrollForever = arr.getBoolean(R.styleable.ScrollTextView_isScrollForever, true);

paint.setColor(textColor);
paint.setTextSize(textSize);
Expand Down Expand Up @@ -202,7 +199,6 @@ public void setTimes(int times) {
needScrollTimes = times;
isScrollForever = false;
}

}

/**
Expand Down Expand Up @@ -273,7 +269,6 @@ public boolean onTouchEvent(MotionEvent event) {
}



/**
* scroll text vertical
*/
Expand Down Expand Up @@ -334,7 +329,6 @@ private void drawVerticalScroll() {
}
}
}

}

/**
Expand Down Expand Up @@ -390,9 +384,7 @@ public void run() {
break;
}


if (isHorizontal) {

if (pauseScroll) {
try {
Thread.sleep(500);
Expand All @@ -409,11 +401,9 @@ public void run() {
--needScrollTimes;
}
} else {

drawVerticalScroll();
isSetNewText = false;
--needScrollTimes;

}

if (needScrollTimes <= 0 && isScrollForever) {
Expand Down
2 changes: 1 addition & 1 deletion ScrollTextviewLib/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ScrollText">
<declare-styleable name="ScrollTextView">
<attr name="clickEnable" format="boolean" />
<attr name="isHorizontal" format="boolean" />
<attr name="speed" format="integer" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe




@Override
public void onClick(View view) {
tempStr=tempStr+SystemClock.currentThreadTimeMillis();
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:3.4.1'

//添加一下两个classpath。

Expand Down

0 comments on commit 1e7941a

Please sign in to comment.