团队冲刺2
一、前言
昨天 |
1、环境搭建 2、明确任务详情 3、简单客户端界面设计 4、设计实现的功能 |
今天 |
1、优化客户端界面 2、实现检索功能 |
遇到的问题 |
1、安卓端不知如何设计,以及实现功能,分配的任务有人不适合 2、界面UI设计不够美观 |
二、设计思路
为了简化开发难度,我们团队统一采用Spring boot+Vue+Maven等等来设计我们这个项目。
配置
1、在buildscrip–>dependencies 模块下面添加
dependencies { classpath 'com.android.tools.build:gradle:3.6.2' classpath "com.mob.sdk:MobSDK:2018.0319.1724" }
2、在使用SMSSDK模块的build.gradle中,添加MobSDK插件和扩展
// 添加插件 apply plugin: 'com.mob.sdk' // 在MobSDK的扩展中注册SMSSDK的相关信息 MobSDK { appKey "申请Mob的appkey" appSecret "申请Mob的AppSecret" SMSSDK {} }
功能代码
MainActivity.java
public class MainActivity extends AppCompatActivity { private Button buttonCode, buttonLogin; private EditText editTextPhoneNum, editTextCode; private String phoneNum, code; private EventHandler eh; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonCode = findViewById(R.id.buttonCode); buttonLogin = findViewById(R.id.buttonLogin); editTextCode = findViewById(R.id.editTextCode); editTextPhoneNum = findViewById(R.id.editTextPhoneNum); eh = new EventHandler() { @Override public void afterEvent(int event, int result, Object data) { if (result == SMSSDK.RESULT_COMPLETE) { //回调完成 if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) { //提交验证码成功 runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, "登录成功", Toast.LENGTH_SHORT).show(); } }); } else if (event == SMSSDK.EVENT_GET_VOICE_VERIFICATION_CODE) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, "语音验证发送", Toast.LENGTH_SHORT).show(); } }); } else if (event == SMSSDK.EVENT_GET_VERIFICATION_CODE) { //获取验证码成功 runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, "验证码已发送", Toast.LENGTH_SHORT).show(); } }); } else if (event == SMSSDK.EVENT_GET_SUPPORTED_COUNTRIES) { Log.i("test", "test"); } } else { ((Throwable) data).printStackTrace(); Throwable throwable = (Throwable) data; throwable.printStackTrace(); Log.i("1234", throwable.toString()); try { JSONObject obj = new JSONObject(Objects.requireNonNull(throwable.getMessage())); final String des = obj.optString("detail"); if (!TextUtils.isEmpty(des)) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, des, Toast.LENGTH_SHORT).show(); } }); } } catch (JSONException e) { e.printStackTrace(); } } } }; //注册一个事件回调监听,用于处理SMSSDK接口请求的结果 SMSSDK.registerEventHandler(eh); buttonCode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { phoneNum = editTextPhoneNum.getText().toString(); if (!phoneNum.isEmpty()) { //利用正则表达式获取检验手机号 if (Utils.checkTel(phoneNum)) { //获取验证码 SMSSDK.getVerificationCode("86", phoneNum); } else { Toast.makeText(getApplicationContext(), "请输入有效的手机号", Toast.LENGTH_LONG).show(); } } else { Toast.makeText(getApplicationContext(), "请输入手机号", Toast.LENGTH_LONG).show(); return; } phoneNum = editTextPhoneNum.getText().toString(); } }); buttonLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { code = editTextCode.getText().toString(); if (!code.isEmpty()) { //提交验证码 SMSSDK.submitVerificationCode("86", phoneNum, code); } else { Toast.makeText(getApplicationContext(), "请输入验证码", Toast.LENGTH_LONG).show(); } } }); } //使用完EventHandler需注销,否则可能出现内存泄漏 @Override protected void onDestroy() { super.onDestroy(); SMSSDK.unregisterEventHandler(eh); } }