review代码(2017-08-14~2017-08-18)

审查日期:2017-08-14

审查人员:鸣人

代码文件:FindPasswordActivity(找回密码界面)

一、代码规范

注:1、注释过少

2、屏蔽掉的代码未删除

三、注释填充

注:1、优化了键盘输入

 public void keyboardListener() {
        SoftKeyboardUtil.observeSoftKeyboard(this, new SoftKeyboardUtil.OnSoftKeyboardChangeListener() {
            @Override
            public void onSoftKeyBoardChange(int softKeybardHeight, boolean visible) {
                if (visible) { //键盘可见
                    if (!isKeybardScroll) {
                        int bottomNavigationBarHeight = 0; //底部虚拟导航按键高度
                        if (DisplayUtil.checkDeviceHasNavigationBar(PersonalFindPasswordActivity.this)) { //检查设备是否包含底部虚拟导航按键
                            bottomNavigationBarHeight = DisplayUtil.getNavigationBarHeight(PersonalFindPasswordActivity.this);
                        }
                        int screenHeight = DisplayUtil.getScreenHeight(PersonalFindPasswordActivity.this);
                        float scroll = mButton.getY() + mButton.getHeight() - (screenHeight + bottomNavigationBarHeight - softKeybardHeight) + 3;
                        if (scroll > 0) {
                            container.scrollTo(0, (int) scroll); //滚动高度使键盘位于登录按钮下面
                        }
                        isKeybardScroll = true;
                    }
                } else { //键盘不可见
                    container.scrollTo(0, 0);
                    isKeybardScroll = false;
                }
            }
        });
    }

审查日期:2017-08-15

审查人员:鸣人

代码文件:HeadpicClipActivity(图片裁剪界面)

一、代码规范

注:1、统一使用butterknife不使用findViewById方法

 @Bind(R.id.status_view)
    View statusView;
    @Bind(R.id.iv_back)
    ImageView bt_back;
    @Bind(R.id.title)
    TextView titleName;
    @Bind(R.id.src_pic)
    ImageView srcPic;
    @Bind(R.id.clipView)
    ClipView clipview;

2、屏蔽掉的代码未删除

三、注释填充

注:将过多的Log删除

审查日期:2017-08-16

审查人员:鸣人

代码文件:ResetPasswordActivity(重新设置密码界面)

一、代码规范

注:1、注释过少

   @Bind(R.id.id_password_old)
   EditText oldPassword; //旧密码输入框
   @Bind(R.id.id_password_new)
   EditText newPassword;  //新密码输入框
   @Bind(R.id.id_password_check)
   EditText checkPassword;  //检查新密码输入框
   @Bind(R.id.button_reset_password)
   Button mButton;  //设置密码按钮
   @Bind(R.id.back)
   ImageView back;  //返回按钮
   @Bind(R.id.base_toolbar_title)
   TextView baseToolbarTitle;  //顶部标题
   @Bind(R.id.status_view)
   View statusView;  //状态栏

三、注释填充

注:将网络请求方法提出变独立方法,解耦

//重新设置密码,密码的判断
    @OnClick(R.id.button_reset_password)
    public void resetPassword() {
        String newPasswordText = newPassword.getText().toString();
        String checkPasswordText = checkPassword.getText().toString();
        if (newPasswordText.contains(" ")) {
            new DialogUtil(this).showError("新密码中不能含有空格");
            return;
        } else if (newPasswordText.length() > 30 || newPasswordText.length() < 6) {
            new DialogUtil(this).showError("请输入6-30位新密码");
            return;
        } else if (!checkPasswordText.equals(newPasswordText)) {
            new DialogUtil(this).showError("两次新密码输入不一致");
            return;
        }
        TCAgent.onEvent(this, "点击修改密码修改按钮");
        String useid = SharedPreferencesUtil.readString(PersonalResetPasswordActivity.this, SpConstant.FILE_USER_INFO, SpConstant.KEY_USER_ID);
        String token = SharedPreferencesUtil.readString(PersonalResetPasswordActivity.this, SpConstant.FILE_USER_INFO, SpConstant.KEY_TOKEN);
        //防止重复提交
        mButton.setClickable(false);
        requestResetPassword();
    }

审查日期:2017-08-17

审查人员:鸣人

代码文件:RenameNicknameActivity(重新设置昵称界面)

一、代码规范

注:1、注释过少

    @Bind(R.id.rename_nickname_text)
    EditText etRename; //重命名输入框
    @Bind(R.id.tv_rename_nickname_tip)
    TextView textViewHint;  //提示文字
    @Bind(R.id.button_rename_nickname)
    Button buttonRename;  //点击设置重命名 
    private final String NICKNAME_PATTERN = "[\\w_-\\u2E80-\\u9FFF]+";  //正则表达式
    @Bind(R.id.back)  //返回按钮
    ImageView back;
    @Bind(R.id.base_toolbar_title)
    TextView baseToolbarTitle;  //头部按钮
    @Bind(R.id.status_view)
    View statusView;  //状态栏
    private boolean isNight;  //夜间模式

三、注释填充

注:1、因为此页面较少TalkingData的统计,添加了TalkingData的统计

审查日期:2017-08-18

审查人员:鸣人

代码文件:RegisterSettingActivity(注册设置界面)

一、代码规范

注:1、注释过少

2、屏蔽掉的代码未删除

三、注释填充

注:1、优化选择图片的模式,并增加了注释

private void setHeadImage() {
        String[] titles = {"拍照", "从相册中选取", "取消"};
        List> datas = new ArrayList<>();
        for (int i = 0; i < titles.length; i++) {
            Map itemData = new HashMap<>();
            itemData.put("name", titles[i]);
            datas.add(itemData);
        }
        SimpleAdapter adapter = new SimpleAdapter(this, datas, R.layout.simple_text_list_item, new String[]{"name"}, new int[]{R.id.simple_text_name});
        DialogPlus dialogPlus = DialogPlus.newDialog(this)
                .setAdapter(adapter)
                .setGravity(Gravity.BOTTOM)
                .setOnItemClickListener(new OnItemClickListener() {
                    @Override
                    public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
                        if (dialog.isShowing()) {
                            dialog.dismiss();
                        }
                        Intent intent;
                        switch (position) {
                            //拍照
                            case 0:
                                intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
                                startActivityForResult(intent, REQUEST_CAPTURE);
                                break;
                            //相册选择
                            case 1:
                                intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                                startActivityForResult(Intent.createChooser(intent, "请选择图片"), REQUEST_PICK);
                                break;
                        }
                    }
                })
                .create();
        dialogPlus.show();
    }

你可能感兴趣的:(review代码(2017-08-14~2017-08-18))