BaseActivity.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. package com.edufound.reader.base;
  2. import android.animation.Animator;
  3. import android.animation.AnimatorListenerAdapter;
  4. import android.animation.AnimatorSet;
  5. import android.animation.ObjectAnimator;
  6. import android.annotation.SuppressLint;
  7. import android.app.Activity;
  8. import android.content.BroadcastReceiver;
  9. import android.content.Context;
  10. import android.content.Intent;
  11. import android.content.IntentFilter;
  12. import android.os.Build;
  13. import android.os.Bundle;
  14. import android.os.Handler;
  15. import android.os.Message;
  16. import android.util.DisplayMetrics;
  17. import android.view.Gravity;
  18. import android.view.LayoutInflater;
  19. import android.view.MotionEvent;
  20. import android.view.View;
  21. import android.view.ViewGroup;
  22. import android.view.WindowManager;
  23. import android.view.animation.LinearInterpolator;
  24. import android.widget.FrameLayout;
  25. import android.widget.ImageView;
  26. import android.widget.Toast;
  27. import com.alibaba.fastjson.JSONObject;
  28. import com.baidu.duer.bot.directive.payload.AmountInfo;
  29. import com.baidu.duer.botsdk.BotIntent;
  30. import com.baidu.duer.botsdk.IAccountChargeMsgListener;
  31. import com.edufound.reader.R;
  32. import com.edufound.reader.annotation.BindView;
  33. import com.edufound.reader.apiserver.UserApiServerImpl;
  34. import com.edufound.reader.application.EApplication;
  35. import com.edufound.reader.bean.BaiDuUserInfo;
  36. import com.edufound.reader.bean.HttpResultBean;
  37. import com.edufound.reader.bean.SignBean;
  38. import com.edufound.reader.bean.UserBean;
  39. import com.edufound.reader.botsdk.BotRegisterListener;
  40. import com.edufound.reader.botsdk.IBotIntentCallback;
  41. import com.edufound.reader.cusview.CusToast;
  42. import com.edufound.reader.receiver.HomeKeyEventReceiver;
  43. import com.edufound.reader.receiver.NetworkChangeReceiver;
  44. import com.edufound.reader.receiver.ShowFollowReceiver;
  45. import com.edufound.reader.util.Consts;
  46. import com.edufound.reader.util.DeviceUuidFactory;
  47. import com.edufound.reader.util.EfunboxUtil;
  48. import com.edufound.reader.util.LiuHaiScreenUtil;
  49. import com.edufound.reader.util.MMKVEncodeKey;
  50. import com.edufound.reader.util.MMKVUtil;
  51. import com.edufound.reader.util.SizeUtils;
  52. import com.google.gson.Gson;
  53. import com.google.gson.reflect.TypeToken;
  54. import com.jakewharton.rxbinding4.view.RxView;
  55. import com.okhttplib.HttpInfo;
  56. import com.okhttplib.callback.Callback;
  57. import com.orhanobut.logger.Logger;
  58. import java.io.IOException;
  59. import java.lang.reflect.Field;
  60. import java.lang.reflect.InvocationTargetException;
  61. import java.lang.reflect.Method;
  62. import java.util.HashMap;
  63. import java.util.Map;
  64. import java.util.concurrent.TimeUnit;
  65. import androidx.annotation.NonNull;
  66. import androidx.appcompat.app.AppCompatActivity;
  67. import io.reactivex.rxjava3.annotations.Nullable;
  68. import io.reactivex.rxjava3.disposables.CompositeDisposable;
  69. import io.reactivex.rxjava3.disposables.Disposable;
  70. import io.reactivex.rxjava3.functions.Consumer;
  71. public abstract class BaseActivity extends AppCompatActivity {
  72. private static final int SHOW_FOLLOW = 0x5512;
  73. private static final int SHOW_FIRST_TIP = 0x5513;
  74. public CompositeDisposable mCompositeDisposable;
  75. //按home键的receiver
  76. HomeKeyEventReceiver mHomeReceiver;
  77. //登录广播action
  78. //Gson
  79. Gson mGson;
  80. View mFirstIntoView;
  81. @Override
  82. protected void onCreate(@Nullable Bundle savedInstanceState) {
  83. super.onCreate(savedInstanceState);
  84. // EfunboxUtil.setCustomDensity(this, Consts.getmApplicAtion());
  85. EApplication.mActivityList.add(this);
  86. EfunboxUtil.initDesignSize(this);
  87. setContentView(this.getLayoutId());
  88. initBase();
  89. bindViews(this);
  90. initView();
  91. }
  92. void initBase() {
  93. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  94. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
  95. LiuHaiScreenUtil.openFullScreenModel(this);
  96. }
  97. mGson = new Gson();
  98. //获取录音权限
  99. // PermissionsUtil.verifyAudioPermissions(this);
  100. if (Consts.getScreenSize() == null) {
  101. DisplayMetrics outMetrics = new DisplayMetrics();
  102. getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
  103. int widthPixels = outMetrics.widthPixels;
  104. int heightPixels = outMetrics.heightPixels;
  105. int arr[] = {widthPixels, heightPixels};
  106. Consts.setScreenSize(arr);
  107. }
  108. mCompositeDisposable = new CompositeDisposable();
  109. mHomeReceiver = new HomeKeyEventReceiver();
  110. //注册home广播
  111. registerReceiver(mHomeReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
  112. // 注册网络广播
  113. NetworkChangeReceiver.registerReceiver(this);
  114. NetworkChangeReceiver.registerObserver(NetStateChangeObserver);
  115. //注册百度广播
  116. BotRegisterListener.registerListener(mBotIntentCallBack, mIAccountChargeMsgListener);
  117. //注册小红花广播
  118. ShowFollowReceiver.registerReceiver(this);
  119. ShowFollowReceiver.registerObserver(showFollow);
  120. }
  121. @Override
  122. protected void onDestroy() {
  123. super.onDestroy();
  124. EApplication.mActivityList.remove(this);
  125. BotRegisterListener.removeListener(mBotIntentCallBack);
  126. clearDisposable();
  127. unregisterReceiver(mHomeReceiver);
  128. NetworkChangeReceiver.unRegisterReceiver(this);
  129. NetworkChangeReceiver.unRegisterObserver(NetStateChangeObserver);
  130. ShowFollowReceiver.unRegisterReceiver(this);
  131. ShowFollowReceiver.unRegisterObserver(showFollow);
  132. }
  133. /**
  134. * 设置布局
  135. *
  136. * @return
  137. */
  138. public abstract int getLayoutId();
  139. /**
  140. * 初始化视图
  141. */
  142. public abstract void initView();
  143. public static void bindViews(Activity activity) {
  144. Class<? extends Activity> activityClass = activity.getClass();//获取activity的class
  145. Field[] fields = activityClass.getDeclaredFields();//获取activity的字段
  146. //遍历所有的字段
  147. for (Field field : fields) {
  148. //获取该字段的注解
  149. BindView bindView = field.getAnnotation(BindView.class);
  150. //!=null 说明该字段有注解并且是指定的注解
  151. if (bindView != null) {
  152. //获取到注解总传入的数值value
  153. int viewId = bindView.id();
  154. if (viewId != -1) {
  155. try {
  156. //获取到activity中findViewById的方法
  157. Method findViewByIdMethod = activityClass.getMethod("findViewById", int.class);
  158. try {
  159. //执行findViewById方法
  160. Object resView = findViewByIdMethod.invoke(activity, viewId);
  161. //允许通过反射访问私有变量
  162. field.setAccessible(true);
  163. //把字段的值设置该view的实例
  164. field.set(activity, resView);
  165. } catch (IllegalAccessException e) {
  166. e.printStackTrace();
  167. } catch (InvocationTargetException e) {
  168. e.printStackTrace();
  169. }
  170. } catch (NoSuchMethodException e) {
  171. e.printStackTrace();
  172. }
  173. }
  174. }
  175. }
  176. }
  177. /**
  178. * 添加订阅
  179. */
  180. public void addDisposable(Disposable mDisposable) {
  181. if (mCompositeDisposable == null) {
  182. mCompositeDisposable = new CompositeDisposable();
  183. }
  184. mCompositeDisposable.add(mDisposable);
  185. }
  186. /**
  187. * 取消所有订阅
  188. */
  189. public void clearDisposable() {
  190. if (mCompositeDisposable != null) {
  191. mCompositeDisposable.clear();
  192. }
  193. }
  194. @SuppressLint("AutoDispose")
  195. public void addUiClickListener(View view, Consumer onNext) {
  196. addDisposable(RxView.clicks(view).throttleFirst(2, TimeUnit.SECONDS).subscribe(onNext));
  197. }
  198. public abstract void onGetDisconnect();
  199. public abstract void onGetMobileConnect();
  200. public abstract void onGetWifiConnect();
  201. NetworkChangeReceiver.NetStateChangeObserver NetStateChangeObserver = new NetworkChangeReceiver.NetStateChangeObserver() {
  202. @Override
  203. public void onDisconnect() {
  204. //断网了
  205. onGetDisconnect();
  206. Toast.makeText(Consts.getmApplicAtion(), "网络异常,请检查网络。", Toast.LENGTH_SHORT).show();
  207. }
  208. @Override
  209. public void onMobileConnect() {
  210. //有网了(移动网络)
  211. onGetMobileConnect();
  212. }
  213. @Override
  214. public void onWifiConnect() {
  215. //有网了(wifi)
  216. onGetWifiConnect();
  217. }
  218. };
  219. protected void onLoginSuccess() {
  220. }
  221. BroadcastReceiver loginReceiver = new BroadcastReceiver() {
  222. @Override
  223. public void onReceive(Context context, Intent intent) {
  224. onLoginSuccess();
  225. }
  226. };
  227. public ViewGroup getRootView() {
  228. return findViewById(android.R.id.content);
  229. }
  230. public void showFollowCountAnim(String count) {
  231. // View mFollowView = LayoutInflater.from(this).inflate(R.layout.anim_getfollow, null);
  232. // FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  233. // ((TextView) mFollowView.findViewById(R.id.anim_getfollow_followcount)).setText("+" + count);
  234. // params.gravity = Gravity.CENTER;
  235. // mFollowView.setLayoutParams(params);
  236. // ObjectAnimator mRotationImgAnim = ObjectAnimator.ofFloat(mFollowView, "translationY", 0, -150);
  237. // mRotationImgAnim.setDuration(1500);
  238. // LinearInterpolator interpolator = new LinearInterpolator();
  239. // mRotationImgAnim.setInterpolator(interpolator); //设置匀速旋转,不卡顿 icon_anim.start();
  240. // ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mFollowView, "alpha", 1f, 0f);
  241. // alphaAnim.setDuration(1500);
  242. // getRootView().addView(mFollowView);
  243. // AnimatorSet animatorSet = new AnimatorSet();
  244. // animatorSet.play(mRotationImgAnim).with(alphaAnim);
  245. // animatorSet.addListener(new AnimatorListenerAdapter() {
  246. // @Override
  247. // public void onAnimationEnd(Animator animation) {
  248. // super.onAnimationEnd(animation);
  249. // getRootView().removeView(mFollowView);
  250. // }
  251. // });
  252. // animatorSet.start();
  253. //
  254. for (int i = 0; i < Integer.valueOf(count); i++) {
  255. Message message = new Message();
  256. message.what = SHOW_FOLLOW;
  257. message.arg1 = i;
  258. baseHandler.sendMessageDelayed(message, i * 250);
  259. }
  260. }
  261. Handler baseHandler = new Handler(new Handler.Callback() {
  262. @Override
  263. public boolean handleMessage(@NonNull Message message) {
  264. switch (message.what) {
  265. case SHOW_FOLLOW:
  266. ImageView imageView = new ImageView(getBaseContext());
  267. imageView.setImageResource(R.drawable.testhua);
  268. FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 50), SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 50));
  269. params.gravity = Gravity.RIGHT | Gravity.CENTER;
  270. params.topMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 80);
  271. if (Integer.valueOf(message.arg1) % 2 == 0) {
  272. //双数
  273. params.rightMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 30);
  274. } else {
  275. params.rightMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 70);
  276. }
  277. imageView.setLayoutParams(params);
  278. getRootView().addView(imageView);
  279. ObjectAnimator mRotationImgAnim = ObjectAnimator.ofFloat(imageView, "translationY", 0, -200);
  280. mRotationImgAnim.setDuration(1500);
  281. ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(imageView, "alpha", 1f, 0f);
  282. alphaAnim.setDuration(1500);
  283. AnimatorSet animatorSet = new AnimatorSet();
  284. animatorSet.play(mRotationImgAnim).with(alphaAnim);
  285. animatorSet.addListener(new AnimatorListenerAdapter() {
  286. @Override
  287. public void onAnimationEnd(Animator animation) {
  288. super.onAnimationEnd(animation);
  289. getRootView().removeView(imageView);
  290. }
  291. });
  292. animatorSet.start();
  293. break;
  294. case SHOW_FIRST_TIP:
  295. mFirstIntoView = LayoutInflater.from(getBaseContext()).inflate(R.layout.first_tip, null);
  296. ImageView touch = mFirstIntoView.findViewById(R.id.first_touch);
  297. FrameLayout.LayoutParams first_params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  298. first_params.gravity = Gravity.RIGHT | Gravity.CENTER;
  299. first_params.rightMargin = SizeUtils.dp2px(Consts.getmApplicAtion().getBaseContext(), 80);
  300. mFirstIntoView.setLayoutParams(first_params);
  301. ObjectAnimator translationYUp = ObjectAnimator.ofFloat(touch, "translationY", 80, -30);
  302. ObjectAnimator translationYDown = ObjectAnimator.ofFloat(touch, "translationY", -30, 80);
  303. translationYUp.setDuration(3000);
  304. translationYDown.setDuration(3000);
  305. LinearInterpolator interpolator = new LinearInterpolator();
  306. translationYUp.setInterpolator(interpolator); //设置匀速旋转,不卡顿
  307. translationYDown.setInterpolator(interpolator); //设置匀速旋转,不卡顿
  308. getRootView().addView(mFirstIntoView);
  309. AnimatorSet first_animatorSet = new AnimatorSet();
  310. first_animatorSet.addListener(new AnimatorListenerAdapter() {
  311. @Override
  312. public void onAnimationEnd(Animator animation) {
  313. super.onAnimationEnd(animation);
  314. first_animatorSet.start();
  315. }
  316. });
  317. mFirstIntoView.setOnTouchListener(new View.OnTouchListener() {
  318. @Override
  319. public boolean onTouch(View view, MotionEvent motionEvent) {
  320. first_animatorSet.pause();
  321. removeFirstTipView();
  322. return true;
  323. }
  324. });
  325. first_animatorSet.playSequentially(translationYUp, translationYDown);
  326. first_animatorSet.start();
  327. MMKVUtil.getInstance().encode("first_into", false);
  328. break;
  329. }
  330. return false;
  331. }
  332. });
  333. public void showFirstTouchView() {
  334. baseHandler.sendEmptyMessage(SHOW_FIRST_TIP);
  335. }
  336. public void removeFirstTipView() {
  337. if (mFirstIntoView != null) {
  338. getRootView().removeView(mFirstIntoView);
  339. mFirstIntoView = null;
  340. }
  341. }
  342. public Gson getGson() {
  343. return mGson;
  344. }
  345. public void toNextActivity(Class clazz) {
  346. Intent intent = new Intent(this, clazz);
  347. startActivity(intent);
  348. }
  349. public void toNextActivity(Class clazz, Bundle bundle) {
  350. Intent intent = new Intent(this, clazz);
  351. intent.putExtra("params_bundle", bundle);
  352. startActivity(intent);
  353. }
  354. public void toNextActivityForResult(Class clazz, Bundle bundle, int resultCode) {
  355. Intent intent = new Intent(this, clazz);
  356. intent.putExtra("params_bundle", bundle);
  357. startActivityForResult(intent, resultCode);
  358. }
  359. //百度的回调逻辑代码块
  360. protected void botHandleIntent(BotIntent intent, String customData) {
  361. }
  362. protected void botOnClickLink(String url, HashMap<String, String> paramMap) {
  363. }
  364. protected void botOnHandleScreenNavigatorEvent(int event) {
  365. }
  366. protected void botOnLinkAccountSucceed(String s, String s1) {
  367. }
  368. protected void refUserInfo(UserBean bean) {
  369. }
  370. /**
  371. * 支付状态改变的通知
  372. *
  373. * @param purchaseResult 支付结果 SUCCESS 支付成功 - ERROR 支付发生错误
  374. * @param authorizationAmount 应收金额信息
  375. * @param capturedAmount 实际扣款信息
  376. * @param creationTimestamp 订单创建时间戳
  377. * @param baiduOrderReferenceId 此次交易百度生成的订单Id
  378. * @param sellerOrderId 对应支付的订单ID
  379. * @param msg 订单信息
  380. */
  381. protected void botOnChargeStatusUpdated(String purchaseResult, AmountInfo authorizationAmount,
  382. AmountInfo capturedAmount, long creationTimestamp,
  383. String baiduOrderReferenceId, String sellerOrderId, String msg) {
  384. }
  385. /**
  386. * 购买结果更新
  387. *
  388. * @param purchaseResult 支付结果,SUCCESS 支付成功 -ERROR 支付发生错误
  389. * @param productId 商品id
  390. * @param baiduOrderId 百度侧订单id
  391. * @param sellerOrderId 卖家订单id
  392. * @param msg 订单备注信息
  393. */
  394. protected void botOnBuyStatusUpdated(@NonNull final String purchaseResult,
  395. @NonNull final String productId,
  396. @NonNull final String baiduOrderId,
  397. @NonNull final String sellerOrderId, @Nullable final String msg, String token) {
  398. }
  399. IBotIntentCallback mBotIntentCallBack = new IBotIntentCallback() {
  400. @Override
  401. public void handleIntent(BotIntent intent, String customData) {
  402. Logger.e("fragment---intent.name:" + intent.name);
  403. if (intent.name.equals("all_login")) {
  404. //用户主动要求登录
  405. Consts.setIsNeedLogin(true);
  406. EfunboxUtil.userLogin(EApplication.mActivityList.get(EApplication.mActivityList.size() - 1));
  407. return;
  408. } else if (intent.name.equals("user_info")) {
  409. //获取是不是百度VIP
  410. Consts.setmConstsBaiDuUserBean(mGson.fromJson(customData, BaiDuUserInfo.class));
  411. Logger.e("json----" + mGson.toJson(Consts.getmConstsBaiDuUserBean()));
  412. if (Consts.getIsNeedLogin()) {
  413. BotRegisterListener.BaiDuLogin();
  414. } else {
  415. Consts.setIsNeedLogin(true);
  416. }
  417. botHandleIntent(intent, customData);
  418. return;
  419. }
  420. if (BotRegisterListener.isNoLoginIntent(intent)) {
  421. //不是获取手机号
  422. Logger.e("不是获取手机号--不是获取手机号:" + intent.name + "---" + intent.slots.toString());
  423. botHandleIntent(intent, customData);
  424. } else {
  425. Logger.e("是获取手机号--是获取手机号");
  426. //是获取手机号
  427. if (intent.slots.get(0).value.equals("SUCCESS")) {
  428. //获取手机号Token成功
  429. String token = intent.slots.get(1).value;
  430. UserApiServerImpl userApiServer = new UserApiServerImpl();
  431. Activity topActivity = EApplication.mActivityList.get(EApplication.mActivityList.size() - 1);
  432. userApiServer.getBaiDuUserPhone(topActivity, token, new Callback() {
  433. @Override
  434. public void onSuccess(HttpInfo info) throws IOException {
  435. JSONObject object = JSONObject.parseObject(info.getRetDetail().toString());
  436. String phone = JSONObject.parseObject(object.getString("data")).getString("phone");
  437. Logger.e("获取的手机号:" + phone);
  438. if (EfunboxUtil.isMobileNO(phone)) {
  439. Map<String, String> map = new HashMap<>();
  440. map.put("deviceCode", DeviceUuidFactory.getUuid());
  441. map.put("channel", Consts.getUmengChannel());
  442. map.put("mobileNo", phone);
  443. map.put("nickName", EfunboxUtil.setPhoneMiddle(phone));
  444. Logger.e("Consts.getmConstsBaiDuUserBean().getUserInfo().getUserId():" + Consts.getmConstsBaiDuUserBean().getUserInfo().getUserId());
  445. map.put("userId", Consts.getmConstsBaiDuUserBean().getUserInfo().getUserId());
  446. if (MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE).equals("") || MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE) == null) {
  447. //如果没有,默认给一年级
  448. map.put("grade", "PRIMARY_FIRST_GRADE");
  449. } else {
  450. map.put("grade", MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE));
  451. }
  452. String json = mGson.toJson(map);
  453. Logger.e("json:" + json);
  454. userApiServer.registerUserId(topActivity, json, new Callback() {
  455. @Override
  456. public void onSuccess(HttpInfo info) throws IOException {
  457. Logger.e("手机号注册成功:" + info.getRetDetail());
  458. HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
  459. }.getType());
  460. Consts.setUID(bean.getData().getUid());
  461. //用户是否登录,登录了,创建Consts的userbean
  462. String nickName = EfunboxUtil.setPhoneMiddle(bean.getData().getMobile());
  463. bean.getData().setNickName(nickName);
  464. Consts.setmConstsUserBean(bean.getData());
  465. Logger.e("看看到底对没有:" + mGson.toJson(Consts.getmConstsUserBean()));
  466. refUserInfo(Consts.getmConstsUserBean());
  467. userApiServer.loginSign(topActivity, new Callback() {
  468. @Override
  469. public void onSuccess(HttpInfo info) throws IOException {
  470. Logger.e("info:" + info.getRetDetail());
  471. HttpResultBean<SignBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<SignBean>>() {
  472. }.getType());
  473. if (bean.getData().getIsSign()) {
  474. CusToast.getInstance(topActivity).show("恭喜签到成功\n奖励" + bean.getData().getCount() + "朵小红花", 2000);
  475. }
  476. }
  477. @Override
  478. public void onFailure(HttpInfo info) throws IOException {
  479. }
  480. });
  481. }
  482. @Override
  483. public void onFailure(HttpInfo info) throws IOException {
  484. Logger.e("手机号注册失败:" + info.getRetDetail());
  485. Toast.makeText(topActivity, "注册失败", Toast.LENGTH_SHORT).show();
  486. }
  487. });
  488. } else {
  489. Toast.makeText(topActivity, "手机号不正确", Toast.LENGTH_SHORT).show();
  490. }
  491. }
  492. @Override
  493. public void onFailure(HttpInfo info) throws IOException {
  494. }
  495. });
  496. } else if (intent.slots.get(0).value.equals("FAIL")) {
  497. //获取手机号Token失败
  498. }
  499. }
  500. }
  501. @Override
  502. public void onClickLink(String url, HashMap<String, String> paramMap) {
  503. botOnClickLink(url, paramMap);
  504. }
  505. @Override
  506. public void onHandleScreenNavigatorEvent(int event) {
  507. botOnHandleScreenNavigatorEvent(event);
  508. }
  509. };
  510. IAccountChargeMsgListener mIAccountChargeMsgListener = new IAccountChargeMsgListener() {
  511. @Override
  512. public void onLinkAccountSucceed(String s, String s1) {
  513. botOnLinkAccountSucceed(s, s1);
  514. }
  515. @Override
  516. public void onChargeStatusUpdated(String purchaseResult, AmountInfo authorizationAmount,
  517. AmountInfo capturedAmount, long creationTimestamp,
  518. String baiduOrderReferenceId, String sellerOrderId, String msg) {
  519. botOnChargeStatusUpdated(purchaseResult, authorizationAmount, capturedAmount, creationTimestamp, baiduOrderReferenceId, sellerOrderId, msg);
  520. }
  521. @Override
  522. public void onBuyStatusUpdated(@NonNull final String purchaseResult,
  523. @NonNull final String productId,
  524. @NonNull final String baiduOrderId,
  525. @NonNull final String sellerOrderId, @Nullable final String msg, String token) {
  526. Consts.setIsNeedLogin(false);
  527. //处理支付回调
  528. Logger.e("purchaseResult:" + purchaseResult);
  529. Logger.e("productId:" + productId);
  530. Logger.e("baiduOrderId:" + baiduOrderId);
  531. Logger.e("sellerOrderId:" + sellerOrderId);
  532. Logger.e("msg:" + msg);
  533. Logger.e("token:" + token);
  534. if (purchaseResult.equals("SUCCESS")) {
  535. //成功
  536. } else if (purchaseResult.equals("ERROR")) {
  537. //支付失败
  538. }
  539. botOnBuyStatusUpdated(purchaseResult, productId, baiduOrderId, sellerOrderId, msg, token);
  540. }
  541. };
  542. @Override
  543. protected void onResume() {
  544. super.onResume();
  545. // if (Consts.getUmengChannel().equals(ChannelCodeEnum.BAIDU.getChannelCode())) {
  546. // if (!Consts.getIsNeedLogin()) {
  547. // BotRegisterListener.getBaiDuVipInfo();
  548. // }
  549. // }
  550. }
  551. ShowFollowReceiver.ShowFollow showFollow = new ShowFollowReceiver.ShowFollow() {
  552. @Override
  553. public void showFollow(Intent intent) {
  554. showFollowCountAnim(intent.getStringExtra("follow_count"));
  555. }
  556. };
  557. }