SetInfoActivity.java 2.72 KB
Newer Older
ydl committed
1 2 3 4 5 6 7 8
package com.yidianling.user.mine;

import android.content.Intent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import com.ydl.ydlcommon.base.BaseActivity;
9
import com.ydl.ydlcommon.bean.StatusBarOptions;
ydl committed
10 11 12 13 14
import com.ydl.ydlcommon.view.DeleteEditTextView;
import com.ydl.ydlcommon.view.TitleBar;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.user.R;

15 16
import org.jetbrains.annotations.NotNull;

ydl committed
17 18 19 20 21 22
/**
 * 短信息填写
 * Created by softrice on 15/9/29.
 */
public class SetInfoActivity extends BaseActivity {
    public static final String INPUT = "INPUT";
23 24 25 26 27
    @NotNull
    @Override
    public StatusBarOptions getStatusViewOptions() {
        return new StatusBarOptions(true,true);
    }
ydl committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    public static Intent getIntent(String input) {
        Intent intent = new Intent();
        intent.putExtra(INPUT, input);
        return intent;
    }

    public static String getInput(Intent intent) {
        if (intent == null) {
            return null;
        }
        return intent.getStringExtra(INPUT);
    }

    String mTitle;
    String mOldString;

//    @BindView(R.id.det_set_info)
    DeleteEditTextView det_set_info;
//    @BindView(R.id.tb_title_bar)
    TitleBar tb_title_bar;

    Animation shake;

    @Override
    protected int layoutResId() {
        return R.layout.user_mine_activity_set_info;
    }

    @Override
    protected void initDataAndEvent() {
        det_set_info = findViewById(R.id.det_set_info);
        tb_title_bar = findViewById(R.id.tb_title_bar);
        mTitle = getIntent().getStringExtra("mTitle");
        mOldString = getIntent().getStringExtra("mOldString");
        init();
    }


    void init() {

        shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.user_mine_shake);

        tb_title_bar.setTitle(mTitle);
        det_set_info.setText(mOldString);

        tb_title_bar.setOnRightTextClick(new TitleBar.OnTitleBarTextClick() {
            @Override
            public void onClick(View view, boolean isActive) {
                if (checkInput()) {
                    ToastUtil.toastShort("保存成功");
                    setResult(RESULT_OK, getIntent(det_set_info.getText().toString()));
                    finish();
                }
            }
        });

    }

    boolean checkInput() {
        if (det_set_info.getText().length() == 0) {
            ToastUtil.toastShort("请输入昵称");
            det_set_info.startAnimation(shake);
            return false;
        }

        if (det_set_info.getText().length() > 6) {
            ToastUtil.toastShort("昵称最多6个字哦");
            det_set_info.startAnimation(shake);
            return false;
        }
        return true;
    }

}