Selaa lähdekoodia

添加信用卡界面部分正则,接口重新添加了参数

guoxin 8 vuotta sitten
vanhempi
commit
7a20f4dff4

+ 2 - 1
app/src/main/java/com/sheep/groups/creditcard/ApplyForCreditCardActivity.java

@@ -78,7 +78,7 @@ public class ApplyForCreditCardActivity extends AppCompatActivity implements OnN
 
     @Override
     public void onNextStep(int stepType) {
-
+        Log.e("BasicInfoPresenter", "act-onNextStep: " );
         switch (stepType){
             case STEP_BASICS:
                 openDetails();
@@ -106,6 +106,7 @@ public class ApplyForCreditCardActivity extends AppCompatActivity implements OnN
                 .beginTransaction()
                 .add(R.id.fl_credit_card_container,detailsFragment,ApplyForCreditCardDetailsFragment.class.getSimpleName())
                 .commit();
+        Log.e("BasicInfoPresenter", "openDetails: " );
     }
 
     private void openCommit(){

+ 30 - 6
app/src/main/java/com/sheep/groups/creditcard/ApplyForCreditCardBasicInfoFragment.java

@@ -73,7 +73,6 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
     private CreditCardDisplayFragment normalCardDisplayFragment;
     private CreditCardDisplayFragment goldCardDisplayFragment;
     private int curType = CreditCardDisplayFragment.CARD_TYPE_NORMAL;
-    private String ticket;
 
     @Override
     public void onAttach(Context context) {
@@ -177,16 +176,27 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
             Toast.makeText(activity,"请填写手机号",Toast.LENGTH_SHORT).show();
             return;
         }
+
+        if(etMobile.getText().toString().length() != 11){
+            Toast.makeText(activity,"手机号位数不正确",Toast.LENGTH_SHORT).show();
+            return;
+        }
         if(TextUtils.isEmpty(etIdNo.getText().toString())){
             Toast.makeText(activity,"请填写身份证号",Toast.LENGTH_SHORT).show();
             return;
         }
 
+        if(etIdNo.getText().toString().length() != 18){
+            Toast.makeText(activity,"身份证号位数不正确",Toast.LENGTH_SHORT).show();
+            return;
+        }
+
         Map<String,String> map = new HashMap<>();
         map.put("name",etName.getText().toString());
         map.put("mobile",etMobile.getText().toString());
         map.put("id_card",etIdNo.getText().toString());
         map.put("card_id",getCardId());
+        Log.e(TAG, "sendDynamic: "+map.toString());
         presenter.getDynamic(map);
         new CountDownUtil(tvDynamic)
                 .setCountDownMillis(60_000L)//倒计时60000ms
@@ -195,7 +205,7 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
     }
 
     private String getCardId(){
-        String cardId = "";
+        String cardId = String.valueOf(CreditCardDisplayFragment.CARD_NORMAL_PAINT);
         if(CreditCardDisplayFragment.CARD_TYPE_NORMAL == curType){
             cardId =  String.valueOf(normalCardDisplayFragment.getCardDetailType());
         }
@@ -217,7 +227,7 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
     public void onConfirm() {
 
 
-        if(TextUtils.isEmpty(ticket)){
+        if(TextUtils.isEmpty(presenter.getTicket())){
             Toast.makeText(activity,"请先获取验证码",Toast.LENGTH_SHORT).show();
             return;
         }
@@ -231,7 +241,7 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
         map.put("token", SpUtils.getOpenId(SheepApp.mContext));
         map.put("card_id",getCardId());
         map.put("code",etDynamic.getText().toString());
-        map.put("ticket",ticket);
+        map.put("ticket",presenter.getTicket());
 
 
         presenter.commitBasic(map);
@@ -239,6 +249,7 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
     }
     @Override
     public void goNext(){
+        Log.e(TAG, "goNext:fragment " );
         //记录信息
         CreditCardInfosManager manager = CreditCardInfosManager.getInstance();
         manager.card_id = getCardId();
@@ -246,7 +257,7 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
         manager.b_mobile = etMobile.getText().toString();
         manager.b_card = etIdNo.getText().toString();
         manager.b_sms = etDynamic.getText().toString();
-        manager.ticket = ticket;
+        manager.ticket = presenter.getTicket();
 
         onNextStepCallback.onNextStep(ApplyForCreditCardActivity.STEP_BASICS);
     }
@@ -258,7 +269,7 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
 
     @Override
     public void showProgress(String msg) {
-
+        Toast.makeText(activity,msg,Toast.LENGTH_SHORT).show();
     }
 
 
@@ -278,6 +289,7 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
         switch (view.getId()){
             case R.id.btn_next:
                 clickBtnNext();
+//                goNext();
                 break;
             case R.id.btn_card_normal:
                 selectNormalCard();
@@ -298,10 +310,22 @@ public class ApplyForCreditCardBasicInfoFragment extends DaggerFragment implemen
             Toast.makeText(activity,"请填写手机号",Toast.LENGTH_SHORT).show();
             return;
         }
+
+        if(!RegexUtils.isMobileSimple(etMobile.getText().toString())){
+            Toast.makeText(activity,"手机号不正确",Toast.LENGTH_SHORT).show();
+            return;
+        }
+
         if(TextUtils.isEmpty(etIdNo.getText().toString())){
             Toast.makeText(activity,"请填写身份证号",Toast.LENGTH_SHORT).show();
             return;
         }
+
+        if(!RegexUtils.isIDCard18(etIdNo.getText().toString())){
+            Toast.makeText(activity,"身份证号不正确",Toast.LENGTH_SHORT).show();
+            return;
+        }
+
         if(TextUtils.isEmpty(etDynamic.getText().toString())){
             Toast.makeText(activity,"请填验证码",Toast.LENGTH_SHORT).show();
             return;

+ 93 - 28
app/src/main/java/com/sheep/groups/creditcard/ApplyForCreditCardDetailsFragment.java

@@ -24,6 +24,7 @@ import com.kfzs.libs.IView;
 import com.kfzs.libs.widget.CompleteCommitEditText;
 import com.kfzs.libs.widget.alpha.AlphaButton;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import java.util.Calendar;
 import java.util.HashMap;
@@ -85,9 +86,9 @@ public class ApplyForCreditCardDetailsFragment extends DaggerFragment implements
     @BindView(R.id.cb_agreement)
     CheckBox cbAgreement;
     @BindView(R.id.sp_relationship_immediate_relatives)
-    Spinner spImmediateRelationship;
+    AppCompatSpinner spImmediateRelationship;
     @BindView(R.id.sp_relationship_other)
-    Spinner spOtherRelationship;
+    AppCompatSpinner spOtherRelationship;
     @BindView(R.id.cb_expire)
     CheckBox cbExpire;
 
@@ -112,7 +113,7 @@ public class ApplyForCreditCardDetailsFragment extends DaggerFragment implements
 
     @Override
     public void setupDaggerComponent() {
-
+        DaggerDetailsComponent.builder().httpComponent(SheepApp.getInstance().getHttpComponent()).build().inject(this);
     }
 
     @Override
@@ -173,23 +174,35 @@ public class ApplyForCreditCardDetailsFragment extends DaggerFragment implements
         setOnCompleteEdit(etIRName,"c_d_name");
         setOnCompleteEdit(etIRMobile,"c_d_mobile");
         //c_d_relation
-        spImmediateRelationship.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+        spImmediateRelationship.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                 String value = (String) adapterImmediateRelatives.getItem(position);
                 CreditCardInfosManager.getInstance().c_d_relation = value;
                 presenter.commitFormData("c_d_relation",value,CreditCardInfosManager.getInstance().card_id);
             }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
         });
+
         //c_o_relation
-        spOtherRelationship.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+        spOtherRelationship.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                 String value = (String) adapterOther.getItem(position);
                 CreditCardInfosManager.getInstance().c_d_relation = value;
                 presenter.commitFormData("c_o_relation",value,CreditCardInfosManager.getInstance().card_id);
             }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
         });
+
         setOnCompleteEdit(etOtherName,"c_o_name");
         setOnCompleteEdit(etOtherMobile,"c_o_mobile");
         tvIdCardExpire.setOnClickListener(new View.OnClickListener() {
@@ -209,7 +222,7 @@ public class ApplyForCreditCardDetailsFragment extends DaggerFragment implements
                     CreditCardInfosManager.getInstance().c_id_expire = expire;
                     presenter.commitFormData("c_id_expire",expire,CreditCardInfosManager.getInstance().card_id);
                 }
-                else CreditCardInfosManager.getInstance().c_id_expire = (String) tvIdCardExpire.getText();
+                else CreditCardInfosManager.getInstance().c_id_expire = tvIdCardExpire.getText().toString();
 
             }
         });
@@ -359,38 +372,90 @@ public class ApplyForCreditCardDetailsFragment extends DaggerFragment implements
             return;
         }
 
+        CreditCardInfosManager manager = CreditCardInfosManager.getInstance();
 
         Map<String,String> map = new HashMap<>();
+        String p_city = etCity.getText().toString();
+        map.put("p_city",p_city);
+        manager.p_city = p_city;
+
+        String p_address = etAddress.getText().toString();
+        map.put("p_address",p_address);
+        manager.p_address = p_address;
+
+        String p_email = etEmail.getText().toString();
+        map.put("p_email",p_email);
+        manager.p_email = p_email;
+
+        String p_marray = CreditCardInfosManager.getInstance().p_marray;
+        map.put("p_marray",p_marray);
+        manager.p_marray = p_marray;
+
+        String p_edu = etEducation.getText().toString();
+        map.put("p_edu",p_edu);
+        manager.p_edu =p_edu;
+
+        String w_name = etCompanyName.getText().toString();
+        map.put("w_name",w_name);
+        manager.w_name = w_name;
+
+        String w_city = etCompanyCity.getText().toString();
+        map.put("w_city",w_city);
+        manager.w_city = w_city;
+
+        String w_address = etCompanyAddress.getText().toString();
+        map.put("w_address",w_address);
+        manager.w_address = w_address;
+
+        String w_tel = etCompanyPhoneQ.getText().toString() + etCompanyPhoneNo.getText().toString();
+        map.put("w_tel",w_tel);
+        manager.w_tel = w_tel;
+
+        String w_age = etWorkYear.getText().toString();
+        map.put("w_age",w_age);
+        manager.w_age = w_age;
+
+        String c_d_name = etIRName.getText().toString();
+        map.put("c_d_name",c_d_name);
+        manager.c_d_name = c_d_name;
+
+        String c_d_mobile = etIRMobile.getText().toString();
+        map.put("c_d_mobile",c_d_mobile);
+        manager.c_d_mobile = c_d_mobile;
 
-        map.put("p_city",etCity.getText().toString());
-        map.put("p_address",etAddress.getText().toString());
-        map.put("p_email",etEmail.getText().toString());
-        map.put("p_marray",CreditCardInfosManager.getInstance().p_marray);
-
-        map.put("p_edu",etEducation.getText().toString());
-        map.put("w_name",etCompanyName.getText().toString());
-        map.put("w_city",etCompanyCity.getText().toString());
-        map.put("w_address",etCompanyAddress.getText().toString());
-        map.put("w_tel",etCompanyPhoneQ.getText().toString() + etCompanyPhoneNo.getText().toString());
-        map.put("w_age",etWorkYear.getText().toString());
-        map.put("c_d_name",etIRName.getText().toString());
-        map.put("c_d_mobile",etIRMobile.getText().toString());
         map.put("c_d_relation",CreditCardInfosManager.getInstance().c_d_relation);
 
-        map.put("c_o_name",etOtherName.getText().toString());
-        map.put("c_o_mobile",etOtherMobile.getText().toString());
+        String c_o_name = etOtherName.getText().toString();
+        map.put("c_o_name",c_o_name);
+        manager.c_o_name =c_o_name;
+
+        String c_o_mobile = etOtherMobile.getText().toString();
+        map.put("c_o_mobile",c_o_mobile);
+        manager.c_o_mobile = c_o_mobile;
+
         map.put("c_o_relation",CreditCardInfosManager.getInstance().c_o_relation);
 
         if(cbExpire.isChecked()){
             map.put("c_id_expire",CreditCardInfosManager.getInstance().c_id_expire);
         }
         else {
-            map.put("c_id_expire",tvIdCardExpire.getText().toString());
+            String c_id_expire = tvIdCardExpire.getText().toString();
+            map.put("c_id_expire",c_id_expire);
+            manager.c_id_expire = c_id_expire;
         }
 
-        map.put("o_p_number",etCarNo.getText().toString());
-        map.put("o_tel",etHomeQ.getText().toString() + etHomePhone.getText().toString());
-        map.put("o_qq",etQQ.getText().toString());
+        String o_p_number = etCarNo.getText().toString();
+        map.put("o_p_number",o_p_number);
+        manager.o_p_number = o_p_number;
+
+        String o_tel = etHomeQ.getText().toString() + etHomePhone.getText().toString();
+        map.put("o_tel",o_tel);
+        manager.o_tel = o_tel;
+
+        String o_qq = etQQ.getText().toString();
+        map.put("o_qq",o_qq);
+        manager.o_qq = o_qq;
+
         map.put("is_agree",String.valueOf(CreditCardInfosManager.getInstance().is_agree));
         presenter.commitDetails(map);
     }
@@ -403,7 +468,7 @@ public class ApplyForCreditCardDetailsFragment extends DaggerFragment implements
 
     @Override
     public void showProgress(String msg) {
-
+        Toast.makeText(activity,msg,Toast.LENGTH_SHORT).show();
     }
 
     @Override

+ 34 - 8
app/src/main/java/com/sheep/groups/creditcard/BasicInfoPresenter.java

@@ -8,6 +8,9 @@ import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 
+import org.json.JSONException;
+import org.json.JSONObject;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -120,6 +123,7 @@ public class BasicInfoPresenter implements BasicInfoContact.Presenter {
 
     @Override
     public void commitBasic(Map<String, String> map) {
+        Log.e(TAG, "commitBasic: "+map.toString() );
         httpService
                 .commitCreditCardBasic(map)
                 .subscribeOn(Schedulers.io())
@@ -132,15 +136,26 @@ public class BasicInfoPresenter implements BasicInfoContact.Presenter {
 
                     @Override
                     public void onError(Throwable e) {
-                        Log.e(TAG, "onError: "+e.getMessage() );
+                        Log.e(TAG, "onError:commitBasic: "+e.getMessage() );
                     }
 
                     @Override
                     public void onNext(String s) {
-                        Log.e(TAG, "onNext: "+s );
-                        if(isContactViewActive()){
-                            view.goNext();
+                        Log.e(TAG, "onNext-commitBasic: "+s );
+
+                        try {
+                            JSONObject object = new JSONObject(s);
+                            if(object.getBoolean("success")){
+                                view.goNext();
+                            }
+                            else {
+                                view.showProgress(object.getString("errors"));
+                            }
+
+                        } catch (JSONException e) {
+                            e.printStackTrace();
                         }
+
                     }
                 });
     }
@@ -160,17 +175,28 @@ public class BasicInfoPresenter implements BasicInfoContact.Presenter {
                     @Override
                     public void onError(Throwable e) {
                         Log.e(TAG, "onError: "+e.getMessage() );
+                        view.showProgress(e.getMessage());
                     }
 
                     @Override
                     public void onNext(String s) {
                         Log.e(TAG, "onNext: "+s );
+                        view.showProgress(s);
                         //保存ticket
-//                        ticket = ;
-
-                        if(isContactViewActive()){
-                            //提示验证码发送情况
+                        try {
+                            JSONObject object = new JSONObject(s);
+                            if(object.getBoolean("success")){
+                                ticket = object.getJSONObject("data").getString("ticket");
+                                view.showProgress(object.getString("验证码发送成功"));
+                            }
+                            else {
+                                view.showProgress(object.getString("errors"));
+                            }
+
+                        } catch (JSONException e) {
+                            e.printStackTrace();
                         }
+
                     }
                 });
     }

+ 1 - 1
app/src/main/java/com/sheep/groups/creditcard/CreditCardInfosManager.java

@@ -17,7 +17,7 @@ public class CreditCardInfosManager {
 
     public static CreditCardInfosManager getInstance(){
         if(instance == null){
-            synchronized (instance){
+            synchronized (CreditCardInfosManager.class){
                 if(instance == null){
                     instance = new CreditCardInfosManager();
                 }

+ 3 - 0
app/src/main/java/com/sheep/groups/creditcard/DetailsPresenter.java

@@ -96,11 +96,14 @@ public class DetailsPresenter implements DetailsContact.Presenter {
                     @Override
                     public void onError(Throwable e) {
                         Log.e(TAG, "onError: "+e.getMessage() );
+                        view.showProgress(e.getLocalizedMessage());
                     }
 
                     @Override
                     public void onNext(String s) {
                         Log.e(TAG, "onNext: "+s );
+                        view.showProgress(s);
+                        view.goNext();
                     }
                 });
     }

+ 113 - 0
app/src/main/java/com/sheep/groups/creditcard/RegexConstants.java

@@ -0,0 +1,113 @@
+package com.sheep.groups.creditcard;
+
+/**
+ * Created by guoxin on 2018/4/3.
+ */
+public final class RegexConstants {
+
+    /**
+     * Regex of simple mobile.
+     */
+    public static final String REGEX_MOBILE_SIMPLE = "^[1]\\d{10}$";
+    /**
+     * Regex of exact mobile.
+     * <p>china mobile: 134(0-8), 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 178, 182, 183, 184, 187, 188, 198</p>
+     * <p>china unicom: 130, 131, 132, 145, 155, 156, 166, 171, 175, 176, 185, 186</p>
+     * <p>china telecom: 133, 153, 173, 177, 180, 181, 189, 199</p>
+     * <p>global star: 1349</p>
+     * <p>virtual operator: 170</p>
+     */
+    public static final String REGEX_MOBILE_EXACT  = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(16[6])|(17[0,1,3,5-8])|(18[0-9])|(19[8,9]))\\d{8}$";
+    /**
+     * Regex of telephone number.
+     */
+    public static final String REGEX_TEL           = "^0\\d{2,3}[- ]?\\d{7,8}";
+    /**
+     * Regex of id card number which length is 15.
+     */
+    public static final String REGEX_ID_CARD15     = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$";
+    /**
+     * Regex of id card number which length is 18.
+     */
+    public static final String REGEX_ID_CARD18     = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$";
+    /**
+     * Regex of email.
+     */
+    public static final String REGEX_EMAIL         = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
+    /**
+     * Regex of url.
+     */
+    public static final String REGEX_URL           = "[a-zA-z]+://[^\\s]*";
+    /**
+     * Regex of Chinese character.
+     */
+    public static final String REGEX_ZH            = "^[\\u4e00-\\u9fa5]+$";
+    /**
+     * Regex of username.
+     * <p>scope for "a-z", "A-Z", "0-9", "_", "Chinese character"</p>
+     * <p>can't end with "_"</p>
+     * <p>length is between 6 to 20</p>
+     */
+    public static final String REGEX_USERNAME      = "^[\\w\\u4e00-\\u9fa5]{6,20}(?<!_)$";
+    /**
+     * Regex of date which pattern is "yyyy-MM-dd".
+     */
+    public static final String REGEX_DATE          = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$";
+    /**
+     * Regex of ip address.
+     */
+    public static final String REGEX_IP            = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";
+
+    ///////////////////////////////////////////////////////////////////////////
+    // The following come from http://tool.oschina.net/regex
+    ///////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Regex of double-byte characters.
+     */
+    public static final String REGEX_DOUBLE_BYTE_CHAR     = "[^\\x00-\\xff]";
+    /**
+     * Regex of blank line.
+     */
+    public static final String REGEX_BLANK_LINE           = "\\n\\s*\\r";
+    /**
+     * Regex of QQ number.
+     */
+    public static final String REGEX_QQ_NUM               = "[1-9][0-9]{4,}";
+    /**
+     * Regex of postal code in China.
+     */
+    public static final String REGEX_CHINA_POSTAL_CODE    = "[1-9]\\d{5}(?!\\d)";
+    /**
+     * Regex of positive integer.
+     */
+    public static final String REGEX_POSITIVE_INTEGER     = "^[1-9]\\d*$";
+    /**
+     * Regex of negative integer.
+     */
+    public static final String REGEX_NEGATIVE_INTEGER     = "^-[1-9]\\d*$";
+    /**
+     * Regex of integer.
+     */
+    public static final String REGEX_INTEGER              = "^-?[1-9]\\d*$";
+    /**
+     * Regex of non-negative integer.
+     */
+    public static final String REGEX_NOT_NEGATIVE_INTEGER = "^[1-9]\\d*|0$";
+    /**
+     * Regex of non-positive integer.
+     */
+    public static final String REGEX_NOT_POSITIVE_INTEGER = "^-[1-9]\\d*|0$";
+    /**
+     * Regex of positive float.
+     */
+    public static final String REGEX_POSITIVE_FLOAT       = "^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*$";
+    /**
+     * Regex of negative float.
+     */
+    public static final String REGEX_NEGATIVE_FLOAT       = "^-[1-9]\\d*\\.\\d*|-0\\.\\d*[1-9]\\d*$";
+
+    ///////////////////////////////////////////////////////////////////////////
+    // If u want more please visit http://toutiao.com/i6231678548520731137
+    ///////////////////////////////////////////////////////////////////////////
+}

+ 220 - 0
app/src/main/java/com/sheep/groups/creditcard/RegexUtils.java

@@ -0,0 +1,220 @@
+package com.sheep.groups.creditcard;
+
+/**
+ * Created by guoxin on 2018/4/3.
+ */
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * <pre>
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 2016/08/02
+ *     desc  : utils about regex
+ * </pre>
+ */
+public final class RegexUtils {
+
+    private RegexUtils() {
+        throw new UnsupportedOperationException("u can't instantiate me...");
+    }
+
+    ///////////////////////////////////////////////////////////////////////////
+    // If u want more please visit http://toutiao.com/i6231678548520731137
+    ///////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Return whether input matches regex of simple mobile.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isMobileSimple(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_MOBILE_SIMPLE, input);
+    }
+
+    /**
+     * Return whether input matches regex of exact mobile.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isMobileExact(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_MOBILE_EXACT, input);
+    }
+
+    /**
+     * Return whether input matches regex of telephone number.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isTel(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_TEL, input);
+    }
+
+    /**
+     * Return whether input matches regex of id card number which length is 15.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isIDCard15(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_ID_CARD15, input);
+    }
+
+    /**
+     * Return whether input matches regex of id card number which length is 18.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isIDCard18(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_ID_CARD18, input);
+    }
+
+    /**
+     * Return whether input matches regex of email.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isEmail(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_EMAIL, input);
+    }
+
+    /**
+     * Return whether input matches regex of url.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isURL(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_URL, input);
+    }
+
+    /**
+     * Return whether input matches regex of Chinese character.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isZh(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_ZH, input);
+    }
+
+    /**
+     * Return whether input matches regex of username.
+     * <p>scope for "a-z", "A-Z", "0-9", "_", "Chinese character"</p>
+     * <p>can't end with "_"</p>
+     * <p>length is between 6 to 20</p>.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isUsername(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_USERNAME, input);
+    }
+
+    /**
+     * Return whether input matches regex of date which pattern is "yyyy-MM-dd".
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isDate(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_DATE, input);
+    }
+
+    /**
+     * Return whether input matches regex of ip address.
+     *
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isIP(final CharSequence input) {
+        return isMatch(RegexConstants.REGEX_IP, input);
+    }
+
+    /**
+     * Return whether input matches the regex.
+     *
+     * @param regex The regex.
+     * @param input The input.
+     * @return {@code true}: yes<br>{@code false}: no
+     */
+    public static boolean isMatch(final String regex, final CharSequence input) {
+        return input != null && input.length() > 0 && Pattern.matches(regex, input);
+    }
+
+    /**
+     * Return the list of input matches the regex.
+     *
+     * @param regex The regex.
+     * @param input The input.
+     * @return the list of input matches the regex
+     */
+    public static List<String> getMatches(final String regex, final CharSequence input) {
+        if (input == null) return null;
+        List<String> matches = new ArrayList<>();
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(input);
+        while (matcher.find()) {
+            matches.add(matcher.group());
+        }
+        return matches;
+    }
+
+    /**
+     * Splits input around matches of the regex.
+     *
+     * @param input The input.
+     * @param regex The regex.
+     * @return the array of strings computed by splitting input around matches of regex
+     */
+    public static String[] getSplits(final String input, final String regex) {
+        if (input == null) return null;
+        return input.split(regex);
+    }
+
+    /**
+     * Replace the first subsequence of the input sequence that matches the
+     * regex with the given replacement string.
+     *
+     * @param input       The input.
+     * @param regex       The regex.
+     * @param replacement The replacement string.
+     * @return the string constructed by replacing the first matching
+     * subsequence by the replacement string, substituting captured
+     * subsequences as needed
+     */
+    public static String getReplaceFirst(final String input,
+                                         final String regex,
+                                         final String replacement) {
+        if (input == null) return null;
+        return Pattern.compile(regex).matcher(input).replaceFirst(replacement);
+    }
+
+    /**
+     * Replace every subsequence of the input sequence that matches the
+     * pattern with the given replacement string.
+     *
+     * @param input       The input.
+     * @param regex       The regex.
+     * @param replacement The replacement string.
+     * @return the string constructed by replacing each matching subsequence
+     * by the replacement string, substituting captured subsequences
+     * as needed
+     */
+    public static String getReplaceAll(final String input,
+                                       final String regex,
+                                       final String replacement) {
+        if (input == null) return null;
+        return Pattern.compile(regex).matcher(input).replaceAll(replacement);
+    }
+}

+ 1 - 1
kfzslibrary/src/main/java/com/kfzs/libs/di/http/HttpService.java

@@ -37,6 +37,6 @@ public interface HttpService {
 
     //表格形式发送
     @FormUrlEncoded
-    @POST("credits/cmbc/code")
+    @POST("credits/cmbc/extend")
     Observable<String> commitCreditCardDetails(@FieldMap Map<String, String> map);
 }