|
@@ -12,6 +12,8 @@ import android.content.Intent;
|
|
|
import android.content.IntentFilter;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
import android.util.DisplayMetrics;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
@@ -22,7 +24,6 @@ import android.view.WindowManager;
|
|
|
import android.view.animation.LinearInterpolator;
|
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
|
-import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -34,11 +35,12 @@ import com.edufound.reader.annotation.BindView;
|
|
|
import com.edufound.reader.apiserver.UserApiServerImpl;
|
|
|
import com.edufound.reader.application.EApplication;
|
|
|
import com.edufound.reader.bean.BaiDuUserInfo;
|
|
|
-import com.edufound.reader.bean.ChannelCodeEnum;
|
|
|
import com.edufound.reader.bean.HttpResultBean;
|
|
|
+import com.edufound.reader.bean.SignBean;
|
|
|
import com.edufound.reader.bean.UserBean;
|
|
|
import com.edufound.reader.botsdk.BotRegisterListener;
|
|
|
import com.edufound.reader.botsdk.IBotIntentCallback;
|
|
|
+import com.edufound.reader.cusview.CusToast;
|
|
|
import com.edufound.reader.receiver.HomeKeyEventReceiver;
|
|
|
import com.edufound.reader.receiver.NetworkChangeReceiver;
|
|
|
import com.edufound.reader.receiver.ShowFollowReceiver;
|
|
@@ -48,7 +50,6 @@ import com.edufound.reader.util.EfunboxUtil;
|
|
|
import com.edufound.reader.util.LiuHaiScreenUtil;
|
|
|
import com.edufound.reader.util.MMKVEncodeKey;
|
|
|
import com.edufound.reader.util.MMKVUtil;
|
|
|
-import com.edufound.reader.util.PermissionsUtil;
|
|
|
import com.edufound.reader.util.SizeUtils;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
@@ -74,6 +75,8 @@ import io.reactivex.rxjava3.functions.Consumer;
|
|
|
|
|
|
public abstract class BaseActivity extends AppCompatActivity {
|
|
|
|
|
|
+ private static final int SHOW_FOLLOW = 0x5512;
|
|
|
+ private static final int SHOW_FIRST_TIP = 0x5513;
|
|
|
public CompositeDisposable mCompositeDisposable;
|
|
|
//按home键的receiver
|
|
|
HomeKeyEventReceiver mHomeReceiver;
|
|
@@ -261,68 +264,117 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
public void showFollowCountAnim(String count) {
|
|
|
- View mFollowView = LayoutInflater.from(this).inflate(R.layout.anim_getfollow, null);
|
|
|
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
- ((TextView) mFollowView.findViewById(R.id.anim_getfollow_followcount)).setText("+" + count);
|
|
|
- params.gravity = Gravity.CENTER;
|
|
|
- mFollowView.setLayoutParams(params);
|
|
|
- ObjectAnimator mRotationImgAnim = ObjectAnimator.ofFloat(mFollowView, "translationY", 0, -150);
|
|
|
- mRotationImgAnim.setDuration(1500);
|
|
|
- LinearInterpolator interpolator = new LinearInterpolator();
|
|
|
- mRotationImgAnim.setInterpolator(interpolator); //设置匀速旋转,不卡顿 icon_anim.start();
|
|
|
- ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mFollowView, "alpha", 1f, 0f);
|
|
|
- alphaAnim.setDuration(1500);
|
|
|
- getRootView().addView(mFollowView);
|
|
|
- AnimatorSet animatorSet = new AnimatorSet();
|
|
|
- animatorSet.play(mRotationImgAnim).with(alphaAnim);
|
|
|
- animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
- @Override
|
|
|
- public void onAnimationEnd(Animator animation) {
|
|
|
- super.onAnimationEnd(animation);
|
|
|
- getRootView().removeView(mFollowView);
|
|
|
- }
|
|
|
- });
|
|
|
- animatorSet.start();
|
|
|
+// View mFollowView = LayoutInflater.from(this).inflate(R.layout.anim_getfollow, null);
|
|
|
+// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
+// ((TextView) mFollowView.findViewById(R.id.anim_getfollow_followcount)).setText("+" + count);
|
|
|
+// params.gravity = Gravity.CENTER;
|
|
|
+// mFollowView.setLayoutParams(params);
|
|
|
+// ObjectAnimator mRotationImgAnim = ObjectAnimator.ofFloat(mFollowView, "translationY", 0, -150);
|
|
|
+// mRotationImgAnim.setDuration(1500);
|
|
|
+// LinearInterpolator interpolator = new LinearInterpolator();
|
|
|
+// mRotationImgAnim.setInterpolator(interpolator); //设置匀速旋转,不卡顿 icon_anim.start();
|
|
|
+// ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mFollowView, "alpha", 1f, 0f);
|
|
|
+// alphaAnim.setDuration(1500);
|
|
|
+// getRootView().addView(mFollowView);
|
|
|
+// AnimatorSet animatorSet = new AnimatorSet();
|
|
|
+// animatorSet.play(mRotationImgAnim).with(alphaAnim);
|
|
|
+// animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
+// @Override
|
|
|
+// public void onAnimationEnd(Animator animation) {
|
|
|
+// super.onAnimationEnd(animation);
|
|
|
+// getRootView().removeView(mFollowView);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// animatorSet.start();
|
|
|
//
|
|
|
+ for (int i = 0; i < Integer.valueOf(count); i++) {
|
|
|
+ Message message = new Message();
|
|
|
+ message.what = SHOW_FOLLOW;
|
|
|
+ message.arg1 = i;
|
|
|
+ baseHandler.sendMessageDelayed(message, i * 250);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void showFirstTouchView() {
|
|
|
- mFirstIntoView = LayoutInflater.from(this).inflate(R.layout.first_tip, null);
|
|
|
- ImageView touch = mFirstIntoView.findViewById(R.id.first_touch);
|
|
|
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
- params.gravity = Gravity.RIGHT | Gravity.CENTER;
|
|
|
- params.rightMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 80);
|
|
|
- mFirstIntoView.setLayoutParams(params);
|
|
|
- ObjectAnimator translationYUp = ObjectAnimator.ofFloat(touch, "translationY", 80, -30);
|
|
|
- ObjectAnimator translationYDown = ObjectAnimator.ofFloat(touch, "translationY", -30, 80);
|
|
|
- translationYUp.setDuration(3000);
|
|
|
- translationYDown.setDuration(3000);
|
|
|
- LinearInterpolator interpolator = new LinearInterpolator();
|
|
|
- translationYUp.setInterpolator(interpolator); //设置匀速旋转,不卡顿
|
|
|
- translationYDown.setInterpolator(interpolator); //设置匀速旋转,不卡顿
|
|
|
- getRootView().addView(mFirstIntoView);
|
|
|
- AnimatorSet animatorSet = new AnimatorSet();
|
|
|
- animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
- @Override
|
|
|
- public void onAnimationEnd(Animator animation) {
|
|
|
- super.onAnimationEnd(animation);
|
|
|
- animatorSet.start();
|
|
|
+ Handler baseHandler = new Handler(new Handler.Callback() {
|
|
|
+ @Override
|
|
|
+ public boolean handleMessage(@NonNull Message message) {
|
|
|
+ switch (message.what) {
|
|
|
+ case SHOW_FOLLOW:
|
|
|
+ ImageView imageView = new ImageView(getBaseContext());
|
|
|
+ imageView.setImageResource(R.drawable.testhua);
|
|
|
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 50), SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 50));
|
|
|
+ params.gravity = Gravity.RIGHT | Gravity.CENTER;
|
|
|
+ params.topMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 80);
|
|
|
+ if (Integer.valueOf(message.arg1) % 2 == 0) {
|
|
|
+ //双数
|
|
|
+ params.rightMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 30);
|
|
|
+ } else {
|
|
|
+ params.rightMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 70);
|
|
|
+ }
|
|
|
|
|
|
+ imageView.setLayoutParams(params);
|
|
|
+ getRootView().addView(imageView);
|
|
|
+ ObjectAnimator mRotationImgAnim = ObjectAnimator.ofFloat(imageView, "translationY", 0, -200);
|
|
|
+ mRotationImgAnim.setDuration(1500);
|
|
|
+ ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(imageView, "alpha", 1f, 0f);
|
|
|
+ alphaAnim.setDuration(1500);
|
|
|
+ AnimatorSet animatorSet = new AnimatorSet();
|
|
|
+ animatorSet.play(mRotationImgAnim).with(alphaAnim);
|
|
|
+ animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
+ @Override
|
|
|
+ public void onAnimationEnd(Animator animation) {
|
|
|
+ super.onAnimationEnd(animation);
|
|
|
+ getRootView().removeView(imageView);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ animatorSet.start();
|
|
|
+ break;
|
|
|
+ case SHOW_FIRST_TIP:
|
|
|
+ mFirstIntoView = LayoutInflater.from(getBaseContext()).inflate(R.layout.first_tip, null);
|
|
|
+ ImageView touch = mFirstIntoView.findViewById(R.id.first_touch);
|
|
|
+ FrameLayout.LayoutParams first_params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
+ first_params.gravity = Gravity.RIGHT | Gravity.CENTER;
|
|
|
+ first_params.rightMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 80);
|
|
|
+ mFirstIntoView.setLayoutParams(first_params);
|
|
|
+ ObjectAnimator translationYUp = ObjectAnimator.ofFloat(touch, "translationY", 80, -30);
|
|
|
+ ObjectAnimator translationYDown = ObjectAnimator.ofFloat(touch, "translationY", -30, 80);
|
|
|
+ translationYUp.setDuration(3000);
|
|
|
+ translationYDown.setDuration(3000);
|
|
|
+ LinearInterpolator interpolator = new LinearInterpolator();
|
|
|
+ translationYUp.setInterpolator(interpolator); //设置匀速旋转,不卡顿
|
|
|
+ translationYDown.setInterpolator(interpolator); //设置匀速旋转,不卡顿
|
|
|
+ getRootView().addView(mFirstIntoView);
|
|
|
+ AnimatorSet first_animatorSet = new AnimatorSet();
|
|
|
+ first_animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
+ @Override
|
|
|
+ public void onAnimationEnd(Animator animation) {
|
|
|
+ super.onAnimationEnd(animation);
|
|
|
+ first_animatorSet.start();
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mFirstIntoView.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
+ first_animatorSet.pause();
|
|
|
+ removeFirstTipView();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ first_animatorSet.playSequentially(translationYUp, translationYDown);
|
|
|
+ first_animatorSet.start();
|
|
|
+ MMKVUtil.getInstance().encode("first_into", false);
|
|
|
+ break;
|
|
|
}
|
|
|
- });
|
|
|
- mFirstIntoView.setOnTouchListener(new View.OnTouchListener() {
|
|
|
- @Override
|
|
|
- public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
- animatorSet.pause();
|
|
|
- removeFirstTipView();
|
|
|
- return true;
|
|
|
- }
|
|
|
- });
|
|
|
- animatorSet.playSequentially(translationYUp, translationYDown);
|
|
|
- animatorSet.start();
|
|
|
- MMKVUtil.getInstance().encode("first_into", false);
|
|
|
-
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ public void showFirstTouchView() {
|
|
|
+ baseHandler.sendEmptyMessage(SHOW_FIRST_TIP);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -477,6 +529,22 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
Consts.setmConstsUserBean(bean.getData());
|
|
|
Logger.e("看看到底对没有:" + mGson.toJson(Consts.getmConstsUserBean()));
|
|
|
refUserInfo(Consts.getmConstsUserBean());
|
|
|
+ userApiServer.loginSign(topActivity, new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("info:" + info.getRetDetail());
|
|
|
+ HttpResultBean<SignBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<SignBean>>() {
|
|
|
+ }.getType());
|
|
|
+ if (bean.getData().getIsSign()) {
|
|
|
+ CusToast.getInstance(topActivity).show("恭喜签到成功\n奖励" + bean.getData().getCount() + "朵小红花", 2000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|