Skip to content

Commit

Permalink
1、代码优化
Browse files Browse the repository at this point in the history
2、新增getSwitch()、setSwitchClickable()、setCbClickable()三个方法
  • Loading branch information
lygttpod committed Apr 27, 2019
1 parent 9c5e8f8 commit 46acbca
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 38 deletions.
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 222
versionName "2.2.2"
versionCode 223
versionName "2.2.3"

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

Expand Down
96 changes: 60 additions & 36 deletions library/src/main/java/com/allen/library/SuperTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1849,6 +1849,18 @@ public SuperTextView setCbChecked(boolean checked) {
return this;
}

/**
* @param clickable 是否允许点击
* @return 返回值
*/
public SuperTextView setCbClickable(boolean clickable) {
if (rightCheckBox != null) {
rightCheckBox.setClickable(clickable);
}
return this;
}


/**
* 设置checkbox的背景图
*
Expand Down Expand Up @@ -1888,6 +1900,17 @@ public SuperTextView setSwitchIsChecked(boolean checked) {
return this;
}

/**
* @param clickable Switch是否允许点击
* @return 返回值
*/
public SuperTextView setSwitchClickable(boolean clickable) {
if (mSwitch != null) {
mSwitch.setClickable(clickable);
}
return this;
}

/**
* 获取switch状态
*
Expand All @@ -1901,6 +1924,15 @@ public boolean getSwitchIsChecked() {
return isChecked;
}

/**
* 获取switchView
*
* @return Switch
*/
public Switch getSwitch() {
return mSwitch;
}

/**
* 设置左边tv的左侧图片
*
Expand Down Expand Up @@ -2039,11 +2071,10 @@ public SuperTextView setSBackground(Drawable drawable) {
* @return textView
*/
public AppCompatTextView getLeftTopTextView() {
AppCompatTextView textView = null;
if (leftView != null) {
textView = leftView.getTopTextView();
if (leftView == null) {
initLeftTextView();
}
return textView;
return leftView.getTopTextView();
}

/**
Expand All @@ -2052,11 +2083,10 @@ public AppCompatTextView getLeftTopTextView() {
* @return textView
*/
public AppCompatTextView getLeftTextView() {
AppCompatTextView textView = null;
if (leftView != null) {
textView = leftView.getCenterTextView();
if (leftView == null) {
initLeftTextView();
}
return textView;
return leftView.getCenterTextView();
}

/**
Expand All @@ -2065,11 +2095,10 @@ public AppCompatTextView getLeftTextView() {
* @return textView
*/
public AppCompatTextView getLeftBottomTextView() {
AppCompatTextView textView = null;
if (leftView != null) {
textView = leftView.getBottomTextView();
if (leftView == null) {
initLeftTextView();
}
return textView;
return leftView.getBottomTextView();
}

/**
Expand All @@ -2078,11 +2107,10 @@ public AppCompatTextView getLeftBottomTextView() {
* @return textView
*/
public AppCompatTextView getCenterTopTextView() {
AppCompatTextView textView = null;
if (centerView != null) {
textView = centerView.getTopTextView();
if (centerView == null) {
initCenterTextView();
}
return textView;
return centerView.getTopTextView();
}

/**
Expand All @@ -2091,11 +2119,10 @@ public AppCompatTextView getCenterTopTextView() {
* @return textView
*/
public AppCompatTextView getCenterTextView() {
AppCompatTextView textView = null;
if (centerView != null) {
textView = centerView.getCenterTextView();
if (centerView == null) {
initCenterTextView();
}
return textView;
return centerView.getCenterTextView();
}

/**
Expand All @@ -2104,11 +2131,10 @@ public AppCompatTextView getCenterTextView() {
* @return textView
*/
public AppCompatTextView getCenterBottomTextView() {
AppCompatTextView textView = null;
if (centerView != null) {
textView = centerView.getBottomTextView();
if (centerView == null) {
initCenterTextView();
}
return textView;
return centerView.getBottomTextView();
}

/**
Expand All @@ -2117,11 +2143,10 @@ public AppCompatTextView getCenterBottomTextView() {
* @return textView
*/
public AppCompatTextView getRightTopTextView() {
AppCompatTextView textView = null;
if (rightView != null) {
textView = rightView.getTopTextView();
if (rightView == null) {
initRightTextView();
}
return textView;
return rightView.getTopTextView();
}

/**
Expand All @@ -2130,11 +2155,10 @@ public AppCompatTextView getRightTopTextView() {
* @return textView
*/
public AppCompatTextView getRightTextView() {
AppCompatTextView textView = null;
if (rightView != null) {
textView = rightView.getCenterTextView();
if (rightView == null) {
initRightTextView();
}
return textView;
return rightView.getCenterTextView();
}

/**
Expand All @@ -2143,11 +2167,10 @@ public AppCompatTextView getRightTextView() {
* @return textView
*/
public AppCompatTextView getRightBottomTextView() {
AppCompatTextView textView = null;
if (rightView != null) {
textView = rightView.getBottomTextView();
if (rightView == null) {
initRightTextView();
}
return textView;
return rightView.getBottomTextView();
}

/**
Expand Down Expand Up @@ -2199,6 +2222,7 @@ private void setTextGravity(BaseTextView baseTextView, int gravity) {

/**
* 代码动态设置分割线显示类型
*
* @param dividerType TOP、BOTTOM、BOTH、NONE
* @return this
*/
Expand Down

0 comments on commit 46acbca

Please sign in to comment.