Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
修改逻辑,在设置文字为null的时候隐藏TextView
Browse files Browse the repository at this point in the history
  • Loading branch information
ForgetAll committed May 8, 2019
1 parent 346c2f2 commit 57d6092
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions LoadingDialog/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
defaultConfig {
minSdkVersion MINSDKVERSION as int
targetSdkVersion TARGETSDKVERSION as int
versionCode VERSION_CODE as int
versionName VERSION_NAME as String
versionCode LIB_VERSION_CODE as int
versionName LIB_VERSION_NAME as String

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ public void close() {
* @return 这个对象
*/
public LoadingDialog setLoadingText(String msg) {
if (msg != null && msg.length() > 0)
if (msg != null) {
loadingText.setVisibility(View.VISIBLE);
loadingText.setText(msg);
} else loadingText.setVisibility(View.GONE);
return this;
}

Expand All @@ -246,8 +248,7 @@ public LoadingDialog setLoadingText(String msg) {
* @return 这个对象
*/
public LoadingDialog setSuccessText(String msg) {
if (msg != null && msg.length() > 0)
loadSuccessStr = msg;
loadSuccessStr = msg;
return this;
}

Expand All @@ -258,7 +259,7 @@ public LoadingDialog setSuccessText(String msg) {
* @return 这个对象
*/
public LoadingDialog setFailedText(String msg) {
if (msg != null && msg.length() > 0) loadFailedStr = msg;
loadFailedStr = msg;
return this;
}

Expand All @@ -272,7 +273,12 @@ public void loadSuccess() {
hideAll();
mSuccessView.setDrawDynamic(openSuccessAnim);
mSuccessView.setVisibility(View.VISIBLE);
loadingText.setText(loadSuccessStr);
if (loadSuccessStr == null) {
loadingText.setVisibility(View.GONE);
} else {
loadingText.setVisibility(View.VISIBLE);
loadingText.setText(loadSuccessStr);
}
}

/**
Expand All @@ -285,7 +291,12 @@ public void loadFailed() {
hideAll();
mFailedView.setDrawDynamic(openFailedAnim);
mFailedView.setVisibility(View.VISIBLE);
loadingText.setText(loadFailedStr);
if (loadFailedStr == null) {
loadingText.setVisibility(View.GONE);
} else {
loadingText.setVisibility(View.VISIBLE);
loadingText.setText(loadFailedStr);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private void drawStatic(Canvas canvas) {
int radius = mWidth / 2 - 8;
canvas.drawLine(center1, center,
center1 + radius / 3, center + radius / 3, mPaint);
canvas.drawLine(center1 + radius / 3 - 1, center + radius / 3,
canvas.drawLine(center1 + radius / 3 - 1, center + radius / 3 - 4,
center1 + radius, center - radius / 3, mPaint);
}

Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/xiasuhuei321/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected void handleMessage(Message msg) {
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn1:
ld.setLoadingText(null);
showLoading();
h.sendEmptyMessageDelayed(SAVE_YOU, 5000);
break;
Expand All @@ -99,6 +100,7 @@ public void onFinish() {
.setInterceptBack(intercept_back_event)
.setLoadSpeed(speed)
.setRepeatCount(repeatTime)
.setShowTime(1000)
// .setDrawColor(color)
.setLoadStyle(style)
.show();
Expand All @@ -109,12 +111,12 @@ public void onFinish() {
case R.id.btn3:
ld = new LoadingDialog(this);
ld.setLoadingText("加载中")
.setFailedText("加载失败")
.setFailedText(null)
.setInterceptBack(intercept_back_event)
.setLoadSpeed(speed)
.setRepeatCount(repeatTime)
// .setDrawColor(color)
.setShowTime(5000)//延时5秒自动关闭,默认1秒
.setShowTime(2000)//延时5秒自动关闭,默认1秒
.setLoadStyle(style)
.show();
h.sendEmptyMessageDelayed(LOAD_FAILED, delayedTime);
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ MINSDKVERSION=14
TARGETSDKVERSION=27
VERSION_CODE=1
SUPPORTVERSION=27.0.0
VERSION_NAME=1.0.0
VERSION_NAME=1.0.0

LIB_VERSION_CODE=112
LIB_VERSION_NAME=v1.1.2

0 comments on commit 57d6092

Please sign in to comment.