Skip to content

Commit

Permalink
UI 微调。
Browse files Browse the repository at this point in the history
  • Loading branch information
XunMengWinter committed Apr 14, 2018
1 parent ce441b1 commit dfe5f9f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "top.wefor.randompicker"
minSdkVersion 9
targetSdkVersion 24
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.1"
}
buildTypes {
release {
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/top/wefor/randompicker/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package top.wefor.randompicker;

import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import java.util.ArrayList;

Expand Down Expand Up @@ -65,6 +68,22 @@ public void onClick(View view) {
}
});

CheckBox checkBox = (CheckBox) findViewById(R.id.cutMode_checkBox);
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Snackbar snackbar = Snackbar.make(buttonView, (isChecked ? "Enter in" : "Exit from") + " Cut mode", 2_000);
View view = snackbar.getView();
view.setBackgroundResource(R.color.colorPrimary);
snackbar.show();

if (isChecked)
mRandomPicker.enterCutMode();
else
mRandomPicker.exitCutMode();
}
});

}

@Override
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
>

<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/cutMode_checkBox"
android:layout_gravity="center"
android:checked="false"
android:button="@drawable/selector_cut_checkbox"
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/top/wefor/randompicker/RandomPicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private int randomPick() {
allWeight += mCurrentWeightList.get(i);
}

if (allWeight < 0) {
if (allWeight <= 0) {
//TODO avoid this situation.
allWeight = Integer.MAX_VALUE;
//Log.e(TAG, "...");
Expand Down

0 comments on commit dfe5f9f

Please sign in to comment.