大于两个的if分支,使用switch

This commit is contained in:
kehaoyuan
2017-06-21 20:54:12 +08:00
parent 7a3b1d4dbe
commit de438e90c4
37 changed files with 1160 additions and 940 deletions

View File

@ -56,12 +56,16 @@ public class CropImageActivity extends BaseActivity {
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
toast("上传成功");
} else if (msg.what == 1) {
toast("上传失败");
} else if (msg.what == 2) {
toast("修改太频繁,请稍后再试");
switch (msg.what) {
case 0:
toast("上传成功");
break;
case 1:
toast("上传失败");
break;
case 2:
toast("修改太频繁,请稍后再试");
break;
}
}
};