Skip to content

Commit fb47bac

Browse files
yazdipourleandroBorgesFerreira
authored andcommitted
Update README.md (leandroBorgesFerreira#127)
Cleaner Markdown
1 parent 82a8504 commit fb47bac

File tree

1 file changed

+58
-43
lines changed

1 file changed

+58
-43
lines changed

README.md

Lines changed: 58 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,60 +36,75 @@ You can check how this library was implemented here (Old version): https://mediu
3636

3737
Add the button in your layout file and customize it the way you like it.
3838

39-
<br.com.simplepass.loadingbutton.customViews.CircularProgressImageButton
40-
android:id="@+id/btn_id"
41-
android:layout_width="match_parent"
42-
android:layout_height="wrap_content"
43-
android:background="@drawable/circular_border_shape"
44-
app:spinning_bar_width="4dp" <!-- Optional -->
45-
app:spinning_bar_color="#FFF" <!-- Optional -->
46-
app:spinning_bar_padding="6dp" <!-- Optional -->
39+
```xml
40+
<br.com.simplepass.loadingbutton.customViews.CircularProgressImageButton
41+
android:id="@+id/btn_id"
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content"
44+
android:background="@drawable/circular_border_shape" />
45+
app:spinning_bar_width="4dp" <!-- Optional -->
46+
app:spinning_bar_color="#FFF" <!-- Optional -->
47+
app:spinning_bar_padding="6dp" <!-- Optional -->
48+
```
4749

4850
Then, instanciate the button
4951

50-
CircularProgressButton btn = (CircularProgressButton) findViewById(R.id.btn_id)
52+
```java
53+
CircularProgressButton btn = (CircularProgressButton) findViewById(R.id.btn_id)
54+
btn.startAnimation();
5155

52-
btn.startAnimation();
56+
//[do some async task. When it finishes]
57+
//You can choose the color and the image after the loading is finished
58+
btn.doneLoadingAnimation(fillColor, bitmap);
5359

54-
[do some async task. When it finishes]
55-
//You can choose the color and the image after the loading is finished
56-
btn.doneLoadingAnimation(fillColor, bitmap);
57-
[or just revert de animation]
58-
btn.revertAnimation();
60+
//[or just revert de animation]
61+
btn.revertAnimation();
62+
```
5963

6064
You can also add a callback to trigger an action after the startAnimation has finished resizing the button :
6165

62-
btn.startAnimation {
63-
<start async task>
64-
}
66+
```kotlin
67+
btn.startAnimation {
68+
<start async task>
69+
}
70+
```
6571

6672
### Switch to determinant progress
6773
You can switch between indeterminant and determinant progress:
6874

69-
circularProgressButton.setProgress(10)
70-
...
71-
circularProgressButton.setProgress(50)
72-
...
73-
circularProgressButton.setProgress(100)
74-
...
75+
```java
76+
circularProgressButton.setProgress(10)
77+
...
78+
circularProgressButton.setProgress(50)
79+
...
80+
circularProgressButton.setProgress(100)
81+
```
7582

7683
### - Show 'done' animation
7784

7885
When the loading animation is running, call:
7986

80-
//Choose the color and the image that will be show
81-
circularProgressButton.doneLoadingAnimation(fillColor, bitmap);
87+
```java
88+
//Choose the color and the image that will be show
89+
circularProgressButton.doneLoadingAnimation(fillColor, bitmap);
90+
```
8291

8392
### - Revert the loading animation with different text or image
8493

85-
progressButton.revertAnimation {
86-
progressButton.text = "Some new text"
87-
}
94+
```kotlin
95+
progressButton.revertAnimation {
96+
progressButton.text = "Some new text"
97+
}
98+
```
99+
88100
or
89101

90-
progressImageButton.revertAnimation {
91-
progressImageButton.setImageResource(R.drawable.image)
92-
}
102+
```kotlin
103+
progressImageButton.revertAnimation {
104+
progressImageButton.setImageResource(R.drawable.image)
105+
}
106+
```
107+
93108
### - Button State
94109

95110
This button is a state machine and it changes its state during the animation process. The states are:
@@ -126,11 +141,11 @@ The button enters this state after `stopAnimation()` when the button is not morp
126141

127142
## Configure XML
128143

129-
- app:spinning_bar_width : Changes the width of the spinning bar inside the button
130-
- app:spinning_bar_color: Changes the color of the spinning bar inside the button
131-
- app:spinning_bar_padding: Changes the padding of the spinning bar in relation of the button bounds.
132-
- app:initialCornerAngle: The initial corner angle of the animation. Insert 0 if you have a square button.
133-
- app:finalCornerAngle: The final corner angle of the animation.
144+
- `app:spinning_bar_width` : Changes the width of the spinning bar inside the button
145+
- `app:spinning_bar_color`: Changes the color of the spinning bar inside the button
146+
- `app:spinning_bar_padding`: Changes the padding of the spinning bar in relation of the button bounds.
147+
- `app:initialCornerAngle`: The initial corner angle of the animation. Insert 0 if you have a square button.
148+
- `app:finalCornerAngle`: The final corner angle of the animation.
134149

135150
## Problems and troubleshooting
136151

@@ -141,12 +156,12 @@ This library only supports androidx since prior the version 2.0.0. So don't try
141156
### Avoid Memory Leaks
142157
Prior to version 2.1.0, to avoid memory leaks is your code, you must dispose the buttons in the onDestroy method. Example:
143158

144-
override fun onDestroy() {
145-
super.onDestroy()
146-
147-
progressButton.dispose()
148-
}
149-
159+
```java
160+
override fun onDestroy() {
161+
super.onDestroy()
162+
progressButton.dispose()
163+
}
164+
```
150165

151166
In version 2.1.0, `ProgressButton` was updated to be a `LifecycleObserver` and will automatically
152167
call `dispose()` when an `onDestroy()` event is observed by the lifecycle owner.

0 commit comments

Comments
 (0)