Skip to content

Commit

Permalink
update atrrs name
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven committed Dec 19, 2016
1 parent 1b635b3 commit 403e5d1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +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 project(':library')
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void run() {
mLoadingBtn.loadingSuccessful();
}else{
mLoadingBtn.loadingFailed();
Toast.makeText(getApplicationContext(),"login failad,please check username and password",Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),"login failed,please check username and password",Toast.LENGTH_SHORT).show();
}
}
},3000);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
android:id="@+id/loading_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginTop="48dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
app:text="@string/button_text" />
app:lb_btnText ="@string/button_text" />


</LinearLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
android:layout_gravity="center"
android:layout_width="228dp"
android:layout_height="wrap_content"
app:resetAfterFailed="true"
app:rippleColor="#000000"
app:text="@string/button_text"
app:lb_resetAfterFailed="true"
app:lb_btnRippleColor="#000000"
app:lb_btnText="@string/button_text"
/>

</FrameLayout>
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public enum AnimationType {
private int mColorPrimary;
private int mTextColor;
private int mRippleColor;
private float mRippleAlpha;
private boolean resetAfterFailed; //when loading data failed, whether reset view
private String mText;

Expand Down Expand Up @@ -107,12 +108,13 @@ private void init(Context context,AttributeSet attrs){
if(attrs != null){
int defaultColor = Color.BLUE;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.LoadingButton, 0, 0);
mColorPrimary = ta.getInt(R.styleable.LoadingButton_btnColor,defaultColor);
String text = ta.getString(R.styleable.LoadingButton_text);
mColorPrimary = ta.getInt(R.styleable.LoadingButton_lb_btnColor,defaultColor);
String text = ta.getString(R.styleable.LoadingButton_lb_btnText);
mText = text == null ? "" : text;
mTextColor = ta.getColor(R.styleable.LoadingButton_textColor,Color.WHITE);
resetAfterFailed = ta.getBoolean(R.styleable.LoadingButton_resetAfterFailed,true);
mRippleColor = ta.getColor(R.styleable.LoadingButton_rippleColor,Color.BLACK);
mTextColor = ta.getColor(R.styleable.LoadingButton_lb_textColor,Color.WHITE);
resetAfterFailed = ta.getBoolean(R.styleable.LoadingButton_lb_resetAfterFailed,true);
mRippleColor = ta.getColor(R.styleable.LoadingButton_lb_btnRippleColor,Color.BLACK);
mRippleAlpha = ta.getFloat(R.styleable.LoadingButton_lb_btnRippleAlpha,0.3f);
ta.recycle();
}

Expand All @@ -135,7 +137,7 @@ private void init(Context context,AttributeSet attrs){
ripplePaint = new Paint();
ripplePaint.setAntiAlias(true);
ripplePaint.setColor(mRippleColor);
ripplePaint.setAlpha((int)(0.3*255));
ripplePaint.setAlpha((int)(mRippleAlpha*255));
ripplePaint.setStyle(Paint.Style.FILL);

mStrokePaint = new Paint();
Expand Down Expand Up @@ -174,7 +176,7 @@ private void init(Context context,AttributeSet attrs){
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = measureDimension((int)(88*mDensity),widthMeasureSpec);
int height = measureDimension((int)(48*mDensity),heightMeasureSpec);
int height = measureDimension((int)(56*mDensity),heightMeasureSpec);
setMeasuredDimension(width,height);
}

Expand Down
11 changes: 6 additions & 5 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="LoadingButton">
<attr name="btnColor" format="reference|color" />
<attr name="text" format="reference|string" />
<attr name="textColor" format="reference|string" />
<attr name="resetAfterFailed" format="boolean" />
<attr name="rippleColor" format="reference|color" />
<attr name="lb_btnColor" format="reference|color" />
<attr name="lb_btnText" format="reference|string" />
<attr name="lb_textColor" format="reference|string" />
<attr name="lb_resetAfterFailed" format="boolean" />
<attr name="lb_btnRippleColor" format="reference|color" />
<attr name="lb_btnRippleAlpha" format="float" />
</declare-styleable>
</resources>

0 comments on commit 403e5d1

Please sign in to comment.