Skip to content

Commit

Permalink
add progressbar
Browse files Browse the repository at this point in the history
Signed-off-by: wangdongdong <[email protected]>
  • Loading branch information
wangdongdong committed Apr 19, 2017
1 parent faf3d7a commit 3a13eb2
Show file tree
Hide file tree
Showing 5 changed files with 656 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class MainActivity extends AppCompatActivity {
StateButton stateButton13;
StateButton stateButton14;
StateButton stateButton15;
StateButton stateButton16;

private Timer mTimer;
private TimerTask mTimerTask;
Expand All @@ -54,6 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
stateButton13 = (StateButton) findViewById(R.id.state_button13);
stateButton14 = (StateButton) findViewById(R.id.state_button14);
stateButton15 = (StateButton) findViewById(R.id.state_button15);
stateButton16 = (StateButton) findViewById(R.id.state_button16);
setup();
}

Expand Down Expand Up @@ -149,6 +151,18 @@ public void onClick(View v) {
showDisableToast(stateButton15);
}
});
stateButton16.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
stateButton16.setState(StateButton.BUTTON_STATES.LOADING);
}
});
stateButton16.setCountdownProgressListener(new StateButton.OnCountdownListener() {
@Override
public void onProgress(int progress) {
stateButton16.setProgressText(progress + "");
}
});
}

private void changState(StateButton stateButton) {
Expand Down
65 changes: 65 additions & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,69 @@
app:selectedTextColor="#ffffff"
app:state="disabled"/>
</com.google.android.flexbox.FlexboxLayout>

<com.google.android.flexbox.FlexboxLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:justifyContent="space_around">

<mazouri.statebutton.StateButton
android:id="@+id/state_button16"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginTop="30dp"
app:enabledText="关闭"
app:enabledIcon="@drawable/ic_lock_open"
app:enabledTextColor="#ffffff"
app:disabledText="无效"
app:disabledIcon="@drawable/ic_lock_disable"
app:disabledTextColor="#33ffffff"
app:selectedText="打开"
app:selectedIcon="@drawable/ic_lock"
app:selectedTextColor="#ffffff"
app:drawablePadding="10dp"
app:iconTopMargin="18dp"
app:iconWidth="30dp"
app:iconHeight="30dp"
app:loadingText="打开"
app:loadingTextColor="#fff"
app:loadingBackground="@drawable/state_button_bg_enable"
app:barProgressChangeDuration="1000"
app:barMaxProgress="15"
app:barProgressLineColor="@color/colorPrimary"
app:barProgressLineWidth="3dp"
app:state="enabled"/>

<mazouri.statebutton.StateButton
android:id="@+id/state_button17"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginTop="30dp"
app:enabledText="关闭"
app:enabledIcon="@drawable/ic_lock_open"
app:enabledTextColor="#ffffff"
app:disabledText="无效"
app:disabledIcon="@drawable/ic_lock_disable"
app:disabledTextColor="#33ffffff"
app:selectedText="打开"
app:selectedIcon="@drawable/ic_lock"
app:selectedTextColor="#ffffff"
app:drawablePadding="10dp"
app:iconTopMargin="18dp"
app:iconWidth="30dp"
app:iconHeight="30dp"
app:loadingText="打开"
app:loadingTextColor="#fff"
app:loadingBackground="@drawable/state_button_bg_enable"
app:barProgressChangeDuration="1000"
app:barMaxProgress="15"
app:barProgressLineColor="@color/colorPrimary"
app:barProgressLineWidth="3dp"
app:barProgressTextColor="@color/colorPrimary"
app:state="enabled"/>
</com.google.android.flexbox.FlexboxLayout>



</LinearLayout>
Loading

0 comments on commit 3a13eb2

Please sign in to comment.