|
|
@@ -1,46 +1,122 @@
|
|
|
package com.sheep.gamegroup.module.pay.activity;
|
|
|
|
|
|
+import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.graphics.drawable.ColorDrawable;
|
|
|
+import android.os.Bundle;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.view.View;
|
|
|
|
|
|
import com.sheep.gamegroup.absBase.BaseContainerActivity;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
+import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
+import com.sheep.gamegroup.module.pay.fragment.CheckCaptchaFragment;
|
|
|
+import com.sheep.gamegroup.module.pay.fragment.CompletionInfoFragment;
|
|
|
+import com.sheep.gamegroup.module.pay.fragment.ConfirmUpdateFragment;
|
|
|
+import com.sheep.gamegroup.module.pay.fragment.SetPasswordFragment;
|
|
|
+import com.sheep.gamegroup.module.pay.fragment.VerifyPayPwdFragment;
|
|
|
+import com.sheep.gamegroup.util.CommonUtil;
|
|
|
+import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
+
|
|
|
+import butterknife.BindView;
|
|
|
+import butterknife.OnClick;
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
+import rx.functions.Action1;
|
|
|
|
|
|
public class ActPayPassword extends BaseContainerActivity {
|
|
|
|
|
|
+ public final static int ACTION_COMPLETION = 1;
|
|
|
+ public final static int ACTION_SET_PWD = 2;
|
|
|
+ public final static int ACTION_SEND_CAPTCHA = 3;
|
|
|
+ public final static int ACTION_CONFIRM_UPDATE = 4;
|
|
|
+ public final static int ACTION_VERIFY_PAY_PWD = 5;
|
|
|
+
|
|
|
+ @BindView(R.id.frame_container)
|
|
|
+ View container;
|
|
|
+
|
|
|
+ protected boolean needRegisterEventBus() {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initView() {
|
|
|
+ super.initView();
|
|
|
+ container.setBackgroundResource(R.color.mask_black);
|
|
|
+ TitleBarUtils.getInstance().setShowOrHide(this, false);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
protected Fragment initFragment() {
|
|
|
- return null;
|
|
|
+ int action = getIntent().getIntExtra("action", -1);
|
|
|
+ return getFragment(action);
|
|
|
}
|
|
|
|
|
|
+ private Fragment getFragment(int action) {
|
|
|
+ if (action == ACTION_COMPLETION) {
|
|
|
+ return new CompletionInfoFragment();
|
|
|
+ } else if (action == ACTION_SEND_CAPTCHA) {
|
|
|
+ return new CheckCaptchaFragment();
|
|
|
+ } else if (action == ACTION_CONFIRM_UPDATE) {
|
|
|
+ return new ConfirmUpdateFragment();
|
|
|
+ } else if (action == ACTION_SET_PWD) {
|
|
|
+ return new SetPasswordFragment();
|
|
|
+ } else if (action == ACTION_VERIFY_PAY_PWD) {
|
|
|
+ return VerifyPayPwdFragment.newInstance(getIntent().getStringExtra("ext"));
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- public static void setPwd(Context context, int want) {
|
|
|
+ @Subscribe
|
|
|
+ public void whenActionComming(PayPasswordEvent ev) {
|
|
|
+ replaceFragment(getFragment(ev.action));
|
|
|
+ }
|
|
|
|
|
|
+ public static void setPwd(Context context) {
|
|
|
+ CommonUtil.getInstance().getUserInfo(SpUtils.getToken(context), (user)->{
|
|
|
+ Intent in = new Intent(context, ActPayPassword.class);
|
|
|
+ if (TextUtils.isEmpty(user.getMobile()) || user.getCertification_count() <= 0) {
|
|
|
+ in.putExtra("action", ACTION_COMPLETION);
|
|
|
+ } else if (user.hasPayPwd()) {
|
|
|
+ in.putExtra("action", ACTION_CONFIRM_UPDATE);
|
|
|
+ } else {
|
|
|
+ in.putExtra("action", ACTION_SEND_CAPTCHA);
|
|
|
+ }
|
|
|
+ context.startActivity(in);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- public static void verifyPwd(Context context) {
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService().needPayPwd()
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
- @Override
|
|
|
- public void onError(BaseMessage baseMessage) {
|
|
|
- G.showToast("支付失败:" + baseMessage.getErrorMsg());
|
|
|
- }
|
|
|
+ public static boolean verifyPwd(Activity activity, String ext) {
|
|
|
+ UserEntity user = DataUtil.getInstance().getUserEntity();
|
|
|
+ if(user.hasPayPwd()) {
|
|
|
+ Intent in = new Intent(activity, ActPayPassword.class);
|
|
|
+ in.putExtra("action", ACTION_VERIFY_PAY_PWD);
|
|
|
+ in.putExtra("ext", ext);
|
|
|
+ activity.startActivityForResult(in, 3);
|
|
|
+ return true;
|
|
|
+ } else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onNext(BaseMessage baseMessage) {
|
|
|
+ public static class PayPasswordEvent {
|
|
|
+ public int action;
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
+ public PayPasswordEvent(int action) {
|
|
|
+ this.action = action;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|