|
|
@@ -1,36 +1,51 @@
|
|
|
package com.sheep.jiuyan.samllsheep.ui.activity;
|
|
|
|
|
|
-import android.annotation.SuppressLint;
|
|
|
import android.content.Intent;
|
|
|
-import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
+import android.view.animation.Animation;
|
|
|
+import android.view.animation.BounceInterpolator;
|
|
|
+import android.view.animation.TranslateAnimation;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
-import com.sheep.gamegroup.view.activity.AskGetMoneyAct;
|
|
|
-import com.sheep.gamegroup.view.activity.SignCardAct;
|
|
|
+import com.kfzs.duanduan.utils.NumberFormatUtils;
|
|
|
+import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
+import com.sheep.gamegroup.model.entity.Lp;
|
|
|
+import com.sheep.gamegroup.model.entity.PunchAndSign;
|
|
|
+import com.sheep.gamegroup.model.entity.RobTask;
|
|
|
+import com.sheep.gamegroup.model.entity.SheepSignResult;
|
|
|
+import com.sheep.gamegroup.model.entity.UserSign;
|
|
|
+import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
+import com.sheep.gamegroup.util.CommonUtil;
|
|
|
+import com.sheep.gamegroup.util.DataKey;
|
|
|
+import com.sheep.gamegroup.util.DataUtil;
|
|
|
+import com.sheep.gamegroup.util.Jump2View;
|
|
|
+import com.sheep.gamegroup.util.ListUtil;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
+import com.sheep.gamegroup.util.TestUtil;
|
|
|
+import com.sheep.gamegroup.util.TimeUtil;
|
|
|
+import com.sheep.gamegroup.util.ViewUtil;
|
|
|
+import com.sheep.gamegroup.util.viewHelper.LayoutParamsUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
-import com.sheep.jiuyan.samllsheep.bean.SignDay;
|
|
|
-import com.sheep.jiuyan.samllsheep.bean.SignsBean;
|
|
|
-import com.sheep.jiuyan.samllsheep.net.Network;
|
|
|
-import com.sheep.jiuyan.samllsheep.net.Scheduler;
|
|
|
+import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.ui.base.BaseActivity;
|
|
|
import com.sheep.jiuyan.samllsheep.ui.view.EggView;
|
|
|
-import com.trello.rxlifecycle2.android.ActivityEvent;
|
|
|
-import com.umeng.socialize.ShareAction;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
+import com.umeng.socialize.UMShareAPI;
|
|
|
import com.umeng.socialize.UMShareListener;
|
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
-import com.umeng.socialize.media.UMImage;
|
|
|
-import com.umeng.socialize.media.UMWeb;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.OnClick;
|
|
|
-import io.reactivex.Observer;
|
|
|
-import io.reactivex.disposables.Disposable;
|
|
|
+import rx.android.schedulers.AndroidSchedulers;
|
|
|
+import rx.functions.Action1;
|
|
|
+import rx.schedulers.Schedulers;
|
|
|
|
|
|
/**
|
|
|
* Created by: zhoujuncai.
|
|
|
@@ -47,6 +62,20 @@ public class SignActivity extends BaseActivity implements UMShareListener {
|
|
|
LinearLayout signDayList;
|
|
|
@BindView(R.id.sign_now_but)
|
|
|
TextView signNowBut;
|
|
|
+ @BindView(R.id.sign_card_num)
|
|
|
+ TextView sign_card_num;
|
|
|
+ @BindView(R.id.sheep_sign_machine)
|
|
|
+ ImageView sheep_sign_machine;
|
|
|
+ @BindView(R.id.sheep_sign_out)
|
|
|
+ ImageView sheep_sign_out;
|
|
|
+ @BindView(R.id.sheep_sign_rectangle)
|
|
|
+ ImageView sheep_sign_rectangle;
|
|
|
+ @BindView(R.id.sheep_sign_egg_rl)
|
|
|
+ View sheep_sign_egg_rl;//中奖的球与文本的容器
|
|
|
+// @BindView(R.id.sheep_sign_egg)
|
|
|
+// ImageView sheep_sign_egg;//中奖的球
|
|
|
+ @BindView(R.id.sheep_sign_egg_msg)
|
|
|
+ TextView sheep_sign_egg_msg;//中奖的球的文本
|
|
|
@BindView(R.id.sign_guajiangqu)
|
|
|
RelativeLayout signGuajiang;
|
|
|
/* 是否有漏签 */
|
|
|
@@ -62,89 +91,228 @@ public class SignActivity extends BaseActivity implements UMShareListener {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private float per;//图片每像素在屏幕上的距离
|
|
|
@Override
|
|
|
protected void onView() {
|
|
|
+ ViewUtil.setText(sign_card_num, ViewUtil.BLOCK);
|
|
|
+ ViewUtil.setImage(sheep_sign_machine, ViewUtil.getNetImgByName("sheep_sign_machine"));
|
|
|
+ ViewUtil.setImage(sheep_sign_rectangle, ViewUtil.getNetImgByName("sheep_sign_rectangle"));
|
|
|
+ ViewUtil.setImage(sheep_sign_out, ViewUtil.getNetImgByName("sheep_sign_out"));
|
|
|
+ //sheep_sign_bg 宽 1500 高 1768
|
|
|
+ //eggsView 宽为 864,高度为 608,距离上面 600
|
|
|
+ //sheep_sign_rectangle 宽为 864,高度为 608 距离上面 350,距离左面 300
|
|
|
+ //sheep_sign_out 宽为 218,高度为 284 距离上面 1290,距离左面 974
|
|
|
+ per = G.WIDTH / 1500f;
|
|
|
+ LayoutParamsUtil.resetLayoutParams(sheep_sign_out, new Lp(per).setTopMargin(1290).setLeftMargin(974).setWidth(218).setHeight(284));
|
|
|
+ LayoutParamsUtil.resetLayoutParams(sheep_sign_rectangle, new Lp(per).setTopMargin(600).setWidth(864).setHeight(608));
|
|
|
+ LayoutParamsUtil.resetLayoutParams(eggsView, new Lp(per).setTopMargin(600).setWidth(864).setHeight(608));
|
|
|
+ LayoutParamsUtil.resetLayoutParams(sheep_sign_egg_rl, new Lp(per).setTopMargin(1290 - 184).setLeftMargin(974 + (218 - 182) / 2).setWidth(182).setHeight(184));
|
|
|
+// ViewUtil.setEnabled(signNowBut, false);
|
|
|
+ }
|
|
|
+
|
|
|
+// public static final int[] imageResources = {
|
|
|
+// R.drawable.niudan1,
|
|
|
+// R.drawable.niudan2,
|
|
|
+// R.drawable.niudan3,
|
|
|
+// R.drawable.niudan4,
|
|
|
+// R.drawable.niudan5,
|
|
|
+// R.drawable.niudan6,
|
|
|
+// R.drawable.niudan7,
|
|
|
+// R.drawable.niudan8};
|
|
|
+
|
|
|
+ private void aEggGoOut(String msg, final Action1<Animation> animationAction1) {
|
|
|
+// sheep_sign_egg.setImageResource(imageResources[(int) (Math.random() * imageResources.length) % imageResources.length]);
|
|
|
+ ViewUtil.setText(sheep_sign_egg_msg, msg);
|
|
|
+ ViewUtil.setVisibility(sheep_sign_egg_rl, true);
|
|
|
+ Animation translateAnimation = new TranslateAnimation(0, 0, 0, per * 284);//平移动画 从0,0,平移到 0 , 284
|
|
|
+ translateAnimation.setDuration(1500);//动画持续的时间为1.5s
|
|
|
+ translateAnimation.setFillEnabled(true);//使其可以填充效果从而不回到原地
|
|
|
+ translateAnimation.setFillAfter(true);//不回到起始位置
|
|
|
+ translateAnimation.setInterpolator(new BounceInterpolator());//accelerated(加速),decelerated(减速),repeated(重复),bounced(弹跳)等
|
|
|
+// translateAnimation.setInterpolator(new AccelerateInterpolator());
|
|
|
+ translateAnimation.setAnimationListener(new Animation.AnimationListener() {
|
|
|
+ @Override
|
|
|
+ public void onAnimationStart(Animation animation) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onAnimationEnd(Animation animation) {
|
|
|
+ if(animationAction1 != null)
|
|
|
+ animationAction1.call(animation);
|
|
|
+ ViewUtil.setVisibility(sheep_sign_egg_rl, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onAnimationRepeat(Animation animation) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //如果不添加setFillEnabled和setFillAfter则动画执行结束后会自动回到远点
|
|
|
+ sheep_sign_egg_rl.startAnimation(translateAnimation);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void onData() {
|
|
|
initSigns();
|
|
|
+ initSignCardData();
|
|
|
}
|
|
|
|
|
|
- private void initSigns() {
|
|
|
- Network.api().getSigns()
|
|
|
- .compose(Scheduler.apply(this.<SignsBean>bindUntilEvent(ActivityEvent.DESTROY)))
|
|
|
- .subscribe(new Observer<SignsBean>() {
|
|
|
+ private void initSignCardData() {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getPunchAndSignCount()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ PunchAndSign punchAndSign = baseMessage.getData(PunchAndSign.class);
|
|
|
+ ViewUtil.setText(sign_card_num, punchAndSign.getSign_up_count());
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
}
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<UserSign> userSignList;
|
|
|
+ private UserSign lastUserSign;
|
|
|
|
|
|
- @SuppressLint("SetTextI18n")
|
|
|
+ private void initSigns() {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getUserSignSigns()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
- public void onNext(SignsBean signsBean) {
|
|
|
- List<SignsBean.DataBean> data = signsBean.getData();
|
|
|
- signInfoText.setText("已签到" + data.size() + "天,连续6天打卡可参与刮奖");
|
|
|
- int max = 0;
|
|
|
- /* 遍历最大签到周期 */
|
|
|
- for (SignsBean.DataBean bean : data) {
|
|
|
- if (max == 0) {
|
|
|
- max = bean.getDay();
|
|
|
- } else {
|
|
|
- max = Math.max(max, bean.getDay());
|
|
|
- }
|
|
|
- }
|
|
|
- /* 判断是否有漏签 */
|
|
|
- if (max > data.size()) {
|
|
|
- attech = true;
|
|
|
- signNowBut.setText("复活补签");
|
|
|
- /* 设置从第一天到最后一天的状态为未签到 */
|
|
|
- for (int i = 0; i < max - 1; i++) {
|
|
|
- SignsBean.DataBean dataBean = data.get(i);
|
|
|
- TextView childAt = (TextView) signDayList.getChildAt(dataBean.getDay() - 1);
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ List<UserSign> data = baseMessage.getDataList(UserSign.class);
|
|
|
+ if (data != null) {
|
|
|
+ userSignList = data;
|
|
|
+ ViewUtil.setText(signInfoText, String.format(Locale.CHINA, "已签到%d天,连续%d天打卡可参与刮奖", data.size(), SIGN_PERIOD));
|
|
|
+ int max = 0;
|
|
|
+ lastUserSign = null;
|
|
|
+ /* 遍历最大签到周期 */
|
|
|
+ for (UserSign item : data) {
|
|
|
+ if (item.getDay() > max) {
|
|
|
+ max = item.getDay();
|
|
|
+ lastUserSign = item;
|
|
|
+ }
|
|
|
+ /* 设置已签到的天数状态 */
|
|
|
+ TextView childAt = (TextView) signDayList.getChildAt(item.getDay() - 1);
|
|
|
childAt.setBackground(getResources().getDrawable(R.drawable.shape_sign_bg_select));
|
|
|
+ if (item.getDay() == SIGN_PERIOD) {
|
|
|
+ childAt.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.giftbox_open));
|
|
|
+ } else {
|
|
|
+ childAt.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.qiandao));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- /* 设置已签到的天数状态 */
|
|
|
- for (int i = 0; i < data.size(); i++) {
|
|
|
- SignsBean.DataBean dataBean = data.get(i);
|
|
|
- TextView childAt = (TextView) signDayList.getChildAt(dataBean.getDay() - 1);
|
|
|
- childAt.setBackground(getResources().getDrawable(R.drawable.shape_sign_bg_select));
|
|
|
- if (dataBean.getDay() == 6) {
|
|
|
- childAt.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.giftbox_open));
|
|
|
- } else {
|
|
|
- childAt.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.qiandao));
|
|
|
+ /* 判断是否有漏签 */
|
|
|
+ if (max > data.size()) {
|
|
|
+ attech = true;
|
|
|
+ signNowBut.setText("复活补签");
|
|
|
+ } else {//没有漏签就设置今日签到状态
|
|
|
+ //设置今日签到状态
|
|
|
+ boolean isSignToday = lastUserSign != null && lastUserSign.isToday();
|
|
|
+ ViewUtil.setText(signNowBut, isSignToday ? "已签到" : "签到");
|
|
|
+// ViewUtil.setEnabled(signNowBut, !isSignToday);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ G.showToast(R.string.service_data_error);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onComplete() {
|
|
|
-
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ G.showToast(baseMessage);
|
|
|
}
|
|
|
});
|
|
|
+// Network.api().getSigns()
|
|
|
+// .compose(Scheduler.apply(this.<SignsBean>bindUntilEvent(ActivityEvent.DESTROY)))
|
|
|
+// .subscribe(new Observer<SignsBean>() {
|
|
|
+// @Override
|
|
|
+// public void onSubscribe(Disposable d) {
|
|
|
+// }
|
|
|
+//
|
|
|
+// @SuppressLint("SetTextI18n")
|
|
|
+// @Override
|
|
|
+// public void onNext(SignsBean signsBean) {
|
|
|
+// List<SignsBean.DataBean> data = signsBean.getData();
|
|
|
+// signInfoText.setText("已签到" + data.size() + "天,连续6天打卡可参与刮奖");
|
|
|
+// int max = 0;
|
|
|
+// /* 遍历最大签到周期 */
|
|
|
+// for (SignsBean.DataBean bean : data) {
|
|
|
+// if (max == 0) {
|
|
|
+// max = bean.getDay();
|
|
|
+// } else {
|
|
|
+// max = Math.max(max, bean.getDay());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// /* 判断是否有漏签 */
|
|
|
+// if (max > data.size()) {
|
|
|
+// attech = true;
|
|
|
+// signNowBut.setText("复活补签");
|
|
|
+// /* 设置从第一天到最后一天的状态为未签到 */
|
|
|
+// for (int i = 0; i < max - 1; i++) {
|
|
|
+// UserSign dataBean = data.get(i);
|
|
|
+// TextView childAt = (TextView) signDayList.getChildAt(dataBean.getDay() - 1);
|
|
|
+// childAt.setBackground(getResources().getDrawable(R.drawable.shape_sign_bg_select));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// /* 设置已签到的天数状态 */
|
|
|
+// for (int i = 0; i < data.size(); i++) {
|
|
|
+// SignsBean.DataBean dataBean = data.get(i);
|
|
|
+// TextView childAt = (TextView) signDayList.getChildAt(dataBean.getDay() - 1);
|
|
|
+// childAt.setBackground(getResources().getDrawable(R.drawable.shape_sign_bg_select));
|
|
|
+// if (dataBean.getDay() == 6) {
|
|
|
+// childAt.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.giftbox_open));
|
|
|
+// } else {
|
|
|
+// childAt.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.qiandao));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onError(Throwable e) {
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onComplete() {
|
|
|
+// }
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
+ //签到周期
|
|
|
+ public static final int SIGN_PERIOD = 6;
|
|
|
+
|
|
|
/**
|
|
|
* 补签
|
|
|
*/
|
|
|
private void attechSign() {
|
|
|
- Network.api().signInSupplement()
|
|
|
- .compose(Scheduler.apply(this.<SignDay>bindUntilEvent(ActivityEvent.DESTROY)))
|
|
|
- .subscribe(new Observer<SignDay>() {
|
|
|
- @Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ UserSign willUserSign;
|
|
|
+ if (ListUtil.isEmpty(userSignList)) {
|
|
|
+ willUserSign = new UserSign();
|
|
|
+ willUserSign.setSign_date(TimeUtil.TimeStamp2Date(System.currentTimeMillis(), "yyyy-MM-dd"));
|
|
|
+ willUserSign.setDay(1);
|
|
|
+ } else {
|
|
|
+ Collections.sort(userSignList);
|
|
|
+ int i = 0;
|
|
|
+ for (UserSign item : userSignList) {
|
|
|
+ if (item.getDay() > i + 1) {//item.getDay()应该等于i + 1,不等于代表这天漏签了
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ willUserSign = new UserSign();
|
|
|
+ willUserSign.setDay(i + 1);
|
|
|
+ willUserSign.resetSignDate(lastUserSign);
|
|
|
+ }
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().postUserSignSignInSupplement(willUserSign.getSign_date(), willUserSign.getDay())
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
- public void onNext(SignDay signDay) {
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
attech = false;
|
|
|
signNowBut.setText("签到");
|
|
|
// 重新请求签到状态接口
|
|
|
@@ -152,88 +320,168 @@ public class SignActivity extends BaseActivity implements UMShareListener {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onComplete() {
|
|
|
-
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ G.showToast(baseMessage);
|
|
|
}
|
|
|
});
|
|
|
+// Network.api().signInSupplement()
|
|
|
+// .compose(Scheduler.apply(this.<SignDay>bindUntilEvent(ActivityEvent.DESTROY)))
|
|
|
+// .subscribe(new Observer<SignDay>() {
|
|
|
+// @Override
|
|
|
+// public void onSubscribe(Disposable d) {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onNext(SignDay signDay) {
|
|
|
+// attech = false;
|
|
|
+// signNowBut.setText("签到");
|
|
|
+// // 重新请求签到状态接口
|
|
|
+// initSigns();
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onError(Throwable e) {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onComplete() {
|
|
|
+//
|
|
|
+// }
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 签到
|
|
|
*/
|
|
|
private void signNow() {
|
|
|
- Network.api().signEveryDay()
|
|
|
- .compose(Scheduler.apply(this.<SignDay>bindUntilEvent(ActivityEvent.DESTROY)))
|
|
|
- .subscribe(new Observer<SignDay>() {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().postUserSignSignIn()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onNext(SignDay signDay) {
|
|
|
- signNowBut.setText("已签到");
|
|
|
- signNowBut.setClickable(false);
|
|
|
- signNowBut.setFocusable(false);
|
|
|
- makeAndShowWindow("已签到", signDay.getData());
|
|
|
- initSigns();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onError(Throwable e) {
|
|
|
-
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ final SheepSignResult sheepSignResult = baseMessage.getData(SheepSignResult.class);
|
|
|
+ if (sheepSignResult.isSign()){
|
|
|
+ tryShowSignResultAndTask("签到成功", sheepSignResult.getAmount());
|
|
|
+ } else {
|
|
|
+ eggsView.setStop(false);
|
|
|
+ aEggGoOut(NumberFormatUtils.retainMost2(sheepSignResult.getAmount()), new Action1<Animation>(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void call(Animation animation) {
|
|
|
+ signNowBut.setText("已签到");
|
|
|
+ tryShowSignResultAndTask("签到成功", sheepSignResult.getAmount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ initSigns();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onComplete() {
|
|
|
-
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ G.showToast(baseMessage);
|
|
|
+// makeAndShowWindow("已签到", signDay.getData());
|
|
|
}
|
|
|
});
|
|
|
+// Network.api().signEveryDay()
|
|
|
+// .compose(Scheduler.apply(this.<SignDay>bindUntilEvent(ActivityEvent.DESTROY)))
|
|
|
+// .subscribe(new Observer<SignDay>() {
|
|
|
+// @Override
|
|
|
+// public void onSubscribe(Disposable d) {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onNext(SignDay signDay) {
|
|
|
+// signNowBut.setText("已签到");
|
|
|
+// signNowBut.setClickable(false);
|
|
|
+// signNowBut.setFocusable(false);
|
|
|
+// makeAndShowWindow("已签到", signDay.getData());
|
|
|
+// initSigns();
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onError(Throwable e) {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onComplete() {
|
|
|
+//
|
|
|
+// }
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 创建并显示窗口
|
|
|
- */
|
|
|
- @SuppressLint({"InflateParams", "SetTextI18n"})
|
|
|
- private void makeAndShowWindow(String title, double money) {
|
|
|
- final View dialog = LayoutInflater.from(this).inflate(R.layout.sign_ok_dialog, null);
|
|
|
- ((TextView) dialog.findViewById(R.id.sign_window_title)).setText(title);
|
|
|
- ((TextView) dialog.findViewById(R.id.sign_money_number)).setText("+" + money);
|
|
|
- dialog.findViewById(R.id.sign_window_next).setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- // 换一个
|
|
|
- }
|
|
|
- });
|
|
|
- dialog.findViewById(R.id.sign_window_share).setOnClickListener(new View.OnClickListener() {
|
|
|
+ private void showSignResultAndTask(final String title, final double money, RobTask robTask) {
|
|
|
+ ViewUtil.newInstance().showRobDutyDialog(this, robTask, R.layout.dialog_sign_result_and_task, new Action1<View>() {
|
|
|
@Override
|
|
|
- public void onClick(View v) {
|
|
|
- ((ViewGroup) getWindow().getDecorView()).removeView(dialog);
|
|
|
- UMWeb web = new UMWeb("下载链接");
|
|
|
- web.setTitle(getString(R.string.app_name));
|
|
|
- web.setThumb(new UMImage(SignActivity.this, R.drawable.icon));
|
|
|
- web.setDescription("任务详情");
|
|
|
- new ShareAction(SignActivity.this)
|
|
|
- .withMedia(web)
|
|
|
- .setDisplayList(SHARE_MEDIA.QQ, SHARE_MEDIA.WEIXIN, SHARE_MEDIA.QZONE, SHARE_MEDIA.WEIXIN_CIRCLE)
|
|
|
- .setCallback(SignActivity.this)
|
|
|
- .open();
|
|
|
+ public void call(View view) {
|
|
|
+ ViewUtil.setText((TextView) view.findViewById(R.id.sign_window_title), title);
|
|
|
+ ViewUtil.setText((TextView) view.findViewById(R.id.sign_money_number), String.format(Locale.CHINA, "+%s", NumberFormatUtils.retainMost2(money)));
|
|
|
}
|
|
|
});
|
|
|
- dialog.findViewById(R.id.close_but).setOnClickListener(new View.OnClickListener() {
|
|
|
+ }
|
|
|
+
|
|
|
+ private void tryShowSignResultAndTask(final String title, final double money) {
|
|
|
+ CommonUtil.getInstance().robTask(new Action1<RobTask>() {
|
|
|
@Override
|
|
|
- public void onClick(View v) {
|
|
|
- ((ViewGroup) getWindow().getDecorView()).removeView(dialog);
|
|
|
+ public void call(RobTask robTask) {
|
|
|
+ if (robTask != null) {
|
|
|
+ DataUtil.putAsInt(DataKey.KEY_ORDER, robTask.getOrder());
|
|
|
+ try {
|
|
|
+ showSignResultAndTask(title, money, robTask);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ G.showToast(e.getMessage());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ G.showToast("任务已被抢光!请实时关注任务发布!");
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
- ((ViewGroup) getWindow().getDecorView()).addView(dialog);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 创建并显示窗口
|
|
|
+// */
|
|
|
+// @SuppressLint({"InflateParams", "SetTextI18n"})
|
|
|
+// private void makeAndShowWindow(String title, double money) {
|
|
|
+// final View dialog = LayoutInflater.from(this).inflate(R.layout.sign_ok_dialog, null);
|
|
|
+// ((TextView) dialog.findViewById(R.id.sign_window_title)).setText(title);
|
|
|
+// ((TextView) dialog.findViewById(R.id.sign_money_number)).setText("+" + money);
|
|
|
+// dialog.findViewById(R.id.sign_window_next).setOnClickListener(new View.OnClickListener() {
|
|
|
+// @Override
|
|
|
+// public void onClick(View v) {
|
|
|
+// // 换一个
|
|
|
+// }
|
|
|
+// });
|
|
|
+// dialog.findViewById(R.id.sign_window_share).setOnClickListener(new View.OnClickListener() {
|
|
|
+// @Override
|
|
|
+// public void onClick(View v) {
|
|
|
+// ((ViewGroup) getWindow().getDecorView()).removeView(dialog);
|
|
|
+// UMWeb web = new UMWeb("下载链接");
|
|
|
+// web.setTitle(getString(R.string.app_name));
|
|
|
+// web.setThumb(new UMImage(SignActivity.this, R.drawable.icon));
|
|
|
+// web.setDescription("任务详情");
|
|
|
+// new ShareAction(SignActivity.this)
|
|
|
+// .withMedia(web)
|
|
|
+// .setDisplayList(SHARE_MEDIA.QQ, SHARE_MEDIA.WEIXIN, SHARE_MEDIA.QZONE, SHARE_MEDIA.WEIXIN_CIRCLE)
|
|
|
+// .setCallback(SignActivity.this)
|
|
|
+// .open();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// dialog.findViewById(R.id.close_but).setOnClickListener(new View.OnClickListener() {
|
|
|
+// @Override
|
|
|
+// public void onClick(View v) {
|
|
|
+// ((ViewGroup) getWindow().getDecorView()).removeView(dialog);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// ((ViewGroup) getWindow().getDecorView()).addView(dialog);
|
|
|
+// }
|
|
|
+
|
|
|
@OnClick(R.id.back_but)
|
|
|
public void onBackButClicked() {
|
|
|
finish();
|
|
|
@@ -246,8 +494,13 @@ public class SignActivity extends BaseActivity implements UMShareListener {
|
|
|
|
|
|
@OnClick(R.id.sign_now_but)
|
|
|
public void onSignNowButClicked() {
|
|
|
- if (attech) {
|
|
|
- attechSign();
|
|
|
+ if (attech && lastUserSign != null && lastUserSign.isToday()) {//有漏签并且今日已经签到,才能进行最近的补签
|
|
|
+ CommonUtil.getInstance().tryShowShareDialog(new Action1<View>() {
|
|
|
+ @Override
|
|
|
+ public void call(View view) {
|
|
|
+ ViewUtil.setText((TextView) view.findViewById(R.id.ask_share_title), "邀请获得复活机会");
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
} else {
|
|
|
signNow();
|
|
|
}
|
|
|
@@ -255,61 +508,88 @@ public class SignActivity extends BaseActivity implements UMShareListener {
|
|
|
|
|
|
@OnClick(R.id.go_to_pack_but)
|
|
|
public void onGoToPackButClicked() {
|
|
|
- startActivity(new Intent(SignActivity.this, SignCardAct.class));
|
|
|
- finish();
|
|
|
+ Jump2View.getInstance().goSignCardAct(this, null);
|
|
|
}
|
|
|
|
|
|
+ //默认最小奖励
|
|
|
+ public static final float DEFAULT_FLOAT = 0.01f;
|
|
|
+
|
|
|
@OnClick(R.id.sign_guajiangqu)
|
|
|
public void onSignGuajiangquClicked() {
|
|
|
- Network.api().signScratchCard()
|
|
|
- .compose(Scheduler.apply(this.<SignDay>bindUntilEvent(ActivityEvent.DESTROY)))
|
|
|
- .subscribe(new Observer<SignDay>() {
|
|
|
- @Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().postUserSignScratchCard()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
- public void onNext(SignDay signDay) {
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ Float aFloat = baseMessage.getData(Float.class, DEFAULT_FLOAT);
|
|
|
signGuajiang.setVisibility(View.GONE);
|
|
|
- makeAndShowWindow("刮奖成功", signDay.getData());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onError(Throwable e) {
|
|
|
-
|
|
|
+ tryShowSignResultAndTask("刮奖成功", aFloat);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onComplete() {
|
|
|
-
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ G.showToast(baseMessage);
|
|
|
}
|
|
|
});
|
|
|
+// Network.api().signScratchCard()
|
|
|
+// .compose(Scheduler.apply(this.<SignDay>bindUntilEvent(ActivityEvent.DESTROY)))
|
|
|
+// .subscribe(new Observer<SignDay>() {
|
|
|
+// @Override
|
|
|
+// public void onSubscribe(Disposable d) {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onNext(SignDay signDay) {
|
|
|
+// signGuajiang.setVisibility(View.GONE);
|
|
|
+// makeAndShowWindow("刮奖成功", signDay.getData());
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onError(Throwable e) {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onComplete() {
|
|
|
+//
|
|
|
+// }
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
@OnClick(R.id.go_to_yaoqing)
|
|
|
public void onGoToYaoqingClicked() {
|
|
|
- startActivity(new Intent(SignActivity.this, AskGetMoneyAct.class));
|
|
|
- finish();
|
|
|
+ Jump2View.getInstance().goAskGetMoney(this, null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onStart(SHARE_MEDIA share_media) {
|
|
|
-
|
|
|
+ LogUtil.println("SignActivity", "share", "onStart", share_media.getName());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onResult(SHARE_MEDIA share_media) {
|
|
|
-
|
|
|
+ LogUtil.println("SignActivity", "share", "onResult", share_media.getName());
|
|
|
+ if (attech)
|
|
|
+ attechSign();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(SHARE_MEDIA share_media, Throwable throwable) {
|
|
|
-
|
|
|
+ String msg = throwable.getMessage();
|
|
|
+ G.showToast(msg != null && msg.contains("没有安装应用") ? "没有安装应用" : msg);
|
|
|
+ LogUtil.println("SignActivity", "share", "onError", share_media.getName(), throwable.getMessage());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onCancel(SHARE_MEDIA share_media) {
|
|
|
+ LogUtil.println("SignActivity", "share", "onCancel", share_media.getName());
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
|
|
|
}
|
|
|
}
|