123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769 |
- package com.edufound.reader.presenter;
- import android.app.Activity;
- import android.content.Context;
- import android.content.Intent;
- import android.graphics.Rect;
- import android.os.Handler;
- import android.os.Message;
- import android.text.TextUtils;
- import android.view.View;
- import android.view.ViewGroup;
- import android.view.inputmethod.InputMethodManager;
- import android.widget.EditText;
- import android.widget.FrameLayout;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.TextView;
- import android.widget.Toast;
- import androidx.annotation.NonNull;
- import androidx.recyclerview.widget.LinearLayoutManager;
- import androidx.recyclerview.widget.RecyclerView;
- import com.edufound.reader.R;
- import com.edufound.reader.activity.MainActivity;
- import com.edufound.reader.adapter.PopupMyOrderAdapter;
- import com.edufound.reader.adapter.RankListItemAdapter;
- import com.edufound.reader.apiserver.OrderApiServerImpl;
- import com.edufound.reader.apiserver.UserApiServerImpl;
- import com.edufound.reader.application.EApplication;
- import com.edufound.reader.bean.ChannelCodeEnum;
- import com.edufound.reader.bean.HttpResultBean;
- import com.edufound.reader.bean.MyInfoBean;
- import com.edufound.reader.bean.MyOrderListBean;
- import com.edufound.reader.bean.RankListBean;
- import com.edufound.reader.bean.RecordResultBean;
- import com.edufound.reader.bean.SignBean;
- import com.edufound.reader.bean.UserBean;
- import com.edufound.reader.bean.UserEventEnum;
- import com.edufound.reader.bean.UserRecordBean;
- import com.edufound.reader.cusview.CusToast;
- import com.edufound.reader.listener.PopupRecordStatusListener;
- import com.edufound.reader.miutil.MiSoundSDKUtil;
- import com.edufound.reader.model.PopWindowModelImpl;
- import com.edufound.reader.popwindow.PopWindowUtil;
- import com.edufound.reader.util.Consts;
- import com.edufound.reader.util.DeviceUuidFactory;
- import com.edufound.reader.util.EfunboxUtil;
- import com.edufound.reader.util.GlideUtils;
- import com.edufound.reader.util.OkHttpClient;
- import com.edufound.reader.util.QRCodeUtil;
- import com.edufound.reader.util.SizeUtils;
- import com.google.gson.Gson;
- import com.google.gson.reflect.TypeToken;
- import com.jakewharton.rxbinding4.view.RxView;
- import com.okhttplib.HttpInfo;
- import com.okhttplib.callback.Callback;
- import com.okhttplib.callback.ProgressCallback;
- import com.orhanobut.logger.Logger;
- import org.json.JSONObject;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.concurrent.TimeUnit;
- public class PopWindowPresneter {
- PopWindowModelImpl mModel;
- ProgressCallback mUploadProgressBack;
- Gson mGson;
- UserApiServerImpl userApi;
- Activity mActivity;
- OrderApiServerImpl mOrderApi;
- public PopWindowPresneter() {
- userApi = new UserApiServerImpl();
- mOrderApi = new OrderApiServerImpl();
- mModel = new PopWindowModelImpl();
- mGson = new Gson();
- }
- public void initRecordStatusWindow(Activity activity, View dialog_view, RecordResultBean bean, UserRecordBean.UserRead userread, PopupRecordStatusListener listener) {
- mActivity = activity;
- FrameLayout mOverFrame = dialog_view.findViewById(R.id.popupwindow_record_status_over_frame);
- FrameLayout mUploadingFrame = dialog_view.findViewById(R.id.popupwindow_record_status_uploading_frame);
- FrameLayout mUploadingSuccessFrame = dialog_view.findViewById(R.id.popupwindow_record_status_uploading_success_frame);
- FrameLayout mUploadingErrorFrame = dialog_view.findViewById(R.id.popupwindow_record_status_uploading_error_frame);
- LinearLayout startLayout = mOverFrame.findViewById(R.id.popupwindow_record_status_over_start_layout);
- FrameLayout mRePlay = mOverFrame.findViewById(R.id.popupwindow_record_status_over_replay);
- FrameLayout mUpload = mOverFrame.findViewById(R.id.popupwindow_record_status_over_upload);
- // float a = bean.getOverall() / 100f;//百分制
- int integrity = bean.getIntegrity();
- int accuracy = bean.getAccuracy();
- int speedd = bean.getSpeed();
- int tone = bean.getTone();
- int score = (int) ((integrity * 0.5) + (bean.getOverall() * 0.3) + (speedd * 0.1) + (tone * 0.1));
- int startCount = 0;
- if (score > 0 && score <= 20) {
- //1个星星
- startCount = 1;
- } else if (score > 20 && score <= 40) {
- //2个星星
- startCount = 2;
- } else if (score > 40 && score <= 60) {
- //3个星星
- startCount = 3;
- } else if (score > 60 && score <= 80) {
- //4个星星
- startCount = 4;
- } else if (score > 80 && score <= 100) {
- //5个星星
- startCount = 5;
- }
- //先显示评测报告,处理测评报告逻辑
- {
- mOverFrame.setVisibility(View.VISIBLE);
- startLayout.removeAllViews();
- for (int i = 0; i < 5; i++) {
- ImageView start = new ImageView(activity);
- if (i < startCount) {
- start.setImageResource(R.drawable.popup_record_status_over_stars_true);
- } else {
- start.setImageResource(R.drawable.popup_record_status_over_stars_false);
- }
- start.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1));
- startLayout.addView(start);
- }
- TextView completionText = mOverFrame.findViewById(R.id.popupwindow_record_status_over_completion_text);
- TextView correctrateText = mOverFrame.findViewById(R.id.popupwindow_record_status_over_correctrate_text);
- TextView speedText = mOverFrame.findViewById(R.id.popupwindow_record_status_over_speed_text);
- TextView intonationText = mOverFrame.findViewById(R.id.popupwindow_record_status_over_intonation_text);
- completionText.post(new Runnable() {
- @Override
- public void run() {
- for (int completionPoint = 0; completionPoint < integrity; completionPoint++) {
- Message msg = new Message();
- msg.obj = completionText;
- msg.arg1 = completionPoint + 1;
- msg.what = 0x0131;
- handler.sendMessageDelayed(msg, 50 * completionPoint);
- }
- }
- });
- correctrateText.post(new Runnable() {
- @Override
- public void run() {
- for (int correctrate = 0; correctrate < accuracy; correctrate++) {
- Message msg = new Message();
- msg.obj = correctrateText;
- msg.arg1 = correctrate + 1;
- msg.what = 0x0131;
- handler.sendMessageDelayed(msg, 50 * correctrate);
- }
- }
- });
- speedText.post(new Runnable() {
- @Override
- public void run() {
- for (int speed = 0; speed < speedd; speed++) {
- Message msg = new Message();
- msg.obj = speedText;
- msg.arg1 = speed + 1;
- msg.what = 0x0131;
- handler.sendMessageDelayed(msg, 50 * speed);
- }
- }
- });
- intonationText.post(new Runnable() {
- @Override
- public void run() {
- for (int intonation = 0; intonation < tone; intonation++) {
- Message msg = new Message();
- msg.obj = intonationText;
- msg.arg1 = intonation + 1;
- msg.what = 0x0131;
- handler.sendMessageDelayed(msg, 50 * intonation);
- }
- }
- });
- mUploadProgressBack = new ProgressCallback() {
- @Override
- public void onResponseMain(String filePath, HttpInfo info) {
- super.onResponseMain(filePath, info);
- Logger.e("onResponseMain:" + info.getRetDetail());
- Logger.e("onResponseMain--netCode:" + info.getNetCode());
- if (info.getNetCode() == 200) {
- //上传完成了
- //上传成功逻辑
- {
- HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
- }.getType());
- Logger.e("filePath:" + bean.getData());
- //请求发布接口
- Map<String, String> postUserRead = new HashMap<>();
- postUserRead.put("audioPath", bean.getData());
- postUserRead.put("coverImg", userread.getCoverImg());
- postUserRead.put("exampleId", userread.getExampleId());
- postUserRead.put("originVideo", userread.getOriginVideo());
- postUserRead.put("shareImg", userread.getShareImg());
- postUserRead.put("title", userread.getTitle());
- postUserRead.put("type", "READ");
- postUserRead.put("uid", Consts.getUID());
- mModel.postUserRead(activity, mGson.toJson(postUserRead), new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- //发布朗读成功了,成功之后求情评测数据接口
- Logger.e("发布朗读成功了:" + info.getRetDetail());
- HttpResultBean<UserRecordBean.UserRead> read = info.getRetDetail(new TypeToken<HttpResultBean<UserRecordBean.UserRead>>() {
- }.getType());
- Map<String, String> postAssessment = new HashMap<>();
- postAssessment.put("complete", String.valueOf(integrity));
- postAssessment.put("speed", String.valueOf(speedd));
- postAssessment.put("intonation", String.valueOf(tone));
- postAssessment.put("score", String.valueOf(score));
- postAssessment.put("accuracy", String.valueOf(accuracy));
- postAssessment.put("userReadId", read.getData().getId());
- mModel.postAssessment(activity, mGson.toJson(postAssessment), new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- Logger.e("请求评测成功:" + info.getRetDetail());
- mUploadingSuccessFrame.setVisibility(View.VISIBLE);
- FrameLayout toLisMySelf = mUploadingSuccessFrame.findViewById(R.id.popup_record_status_upload_success_btn);
- toLisMySelf.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- PopWindowUtil.hidePopupWindow();
- // Toast.makeText(context, "去听听(首页->我的tab)", Toast.LENGTH_SHORT).show();
- EApplication.reloadApp(0);
- }
- });
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- Logger.e("请求评测失败:" + info.getRetDetail());
- }
- });
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- Logger.e("发布朗读失败了:" + info.getRetDetail());
- }
- });
- }
- } else {
- //失败逻辑
- {
- mUploadingErrorFrame.setVisibility(View.VISIBLE);
- FrameLayout mCancelUpload = mUploadingErrorFrame.findViewById(R.id.popupwindow_record_status_uploading_error_cancel_upload);
- FrameLayout mReUpload = mUploadingErrorFrame.findViewById(R.id.popupwindow_record_status_uploading_error_re_upload);
- mCancelUpload.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- PopWindowUtil.hidePopupWindow();
- }
- });
- mReUpload.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- // Toast.makeText(context, "重新上传", Toast.LENGTH_SHORT).show();
- Logger.e("重新上传");
- mUploadingErrorFrame.setVisibility(View.GONE);
- mUploadingFrame.setVisibility(View.VISIBLE);
- userApi.postUserEvent(activity, UserEventEnum.EVENT_UPLOAD.getEvent());
- mModel.upLoadRecord(activity, Consts.getRecordUpLoadFileUrl(), mUploadProgressBack);
- }
- });
- }
- }
- }
- @Override
- public void onProgressAsync(int percent, long bytesWritten, long contentLength, boolean done) {
- super.onProgressAsync(percent, bytesWritten, contentLength, done);
- }
- @Override
- public void onProgressMain(int percent, long bytesWritten, long contentLength, boolean done) {
- super.onProgressMain(percent, bytesWritten, contentLength, done);
- }
- };
- mUpload.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- //上传录音
- mOverFrame.setVisibility(View.GONE);
- mUploadingFrame.setVisibility(View.VISIBLE);
- userApi.postUserEvent(activity, UserEventEnum.EVENT_UPLOAD.getEvent());
- mModel.upLoadRecord(activity, Consts.getRecordUpLoadFileUrl(), mUploadProgressBack);
- }
- });
- mRePlay.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- listener.clickReRecord();
- }
- });
- }
- }
- public void myOrderWindowInit(Activity context, View view) {
- // for (int i = 0; i < 30; i++) {
- // mDataList.add("i=" + i);
- // }
- OkHttpClient.doGetAsync(context, new HttpInfo.Builder().setUrl(Consts.getFinalApi() + "/order"), new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- Logger.e("info:" + info.getRetDetail());
- HttpResultBean<List<MyOrderListBean>> bean = info.getRetDetail(new TypeToken<HttpResultBean<List<MyOrderListBean>>>() {
- }.getType());
- if (bean.getData() != null && bean.getData().size() > 0) {
- RecyclerView rv = view.findViewById(R.id.popupwindow_myorder_recyclerview);
- PopupMyOrderAdapter popupMyOrderAdapter = new PopupMyOrderAdapter(context, bean.getData());
- rv.addItemDecoration(new OrderSpacesItemDecoration(SizeUtils.dp2px(context, 10), bean.getData().size()));
- rv.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
- rv.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {
- @Override
- public void onChildViewAttachedToWindow(@androidx.annotation.NonNull View view) {
- }
- @Override
- public void onChildViewDetachedFromWindow(@androidx.annotation.NonNull View view) {
- }
- });
- rv.setAdapter(popupMyOrderAdapter);
- } else {
- view.findViewById(R.id.popupwindow_myorder_noitem).setVisibility(View.VISIBLE);
- }
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- }
- });
- }
- public void getBindWeChatPath(Activity activity, ImageView imageView) {
- mActivity = activity;
- userApi.getBindWeChatPath(activity, new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- Logger.e("获取绑定微信成功:" + info.getRetDetail());
- HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
- }.getType());
- imageView.setImageBitmap(QRCodeUtil.createQRCode(bean.getData(), SizeUtils.dp2px(activity, 900)));
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- Logger.e("获取绑定微信失败:" + info.getRetDetail());
- }
- });
- }
- public void getMyInfo(Activity activity, TextView textView) {
- mActivity = activity;
- userApi.getMyInfo(activity, new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- HttpResultBean<MyInfoBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<MyInfoBean>>() {
- }.getType());
- if (bean.getData().getUser().getOpenId() == null || bean.getData().getUser().getOpenId().equals("")) {
- textView.setText("");
- } else {
- textView.setText("微信昵称:" + bean.getData().getUser().getWechatName());
- textView.setVisibility(View.VISIBLE);
- }
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- }
- });
- Message message = new Message();
- message.obj = textView;
- message.what = 0x1312;
- handler.sendMessageDelayed(message, 3000);
- }
- /**
- * 排行榜
- */
- public void rankListInit(Context context, View dialog_view, String id) {
- Logger.e("id:" + id);
- //请求排行榜接口
- userApi.getRankList(id, new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- HttpResultBean<RankListBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<RankListBean>>() {
- }.getType());
- //设置数据
- if (bean.getData().getActivityUserReadList() != null && bean.getData().getActivityUserReadList().size() > 0) {
- RankListItemAdapter adapter = new RankListItemAdapter(context, bean.getData().getActivityUserReadList());
- LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
- RecyclerView recyclerView = dialog_view.findViewById(R.id.popupwindow_ranklist_recyclerview);
- recyclerView.setLayoutManager(linearLayoutManager);
- recyclerView.setAdapter(adapter);
- FrameLayout myInfoLayout = dialog_view.findViewById(R.id.popupwindow_ranklist_myinfo_layout);
- TextView myNum = dialog_view.findViewById(R.id.popupwindow_show_ranklist_my_num);
- TextView myName = dialog_view.findViewById(R.id.popupwindow_show_ranklist_my_name);
- TextView myThumb = dialog_view.findViewById(R.id.popupwindow_show_ranklist_my_thumb);
- TextView myCollection = dialog_view.findViewById(R.id.popupwindow_show_ranklist_my_collection);
- TextView myScore = dialog_view.findViewById(R.id.popupwindow_show_ranklist_my_score);
- myInfoLayout.setVisibility(View.GONE);
- boolean getMyRank = false;
- for (int i = 0; i < bean.getData().getActivityUserReadList().size(); i++) {
- if (getMyRank == false && bean.getData().getActivityUserReadList().get(i).getUser().getUid().equals(Consts.getUID())) {
- //获取到数据了,并且只获取第一次得到的
- getMyRank = true;
- myName.setText("我自己");
- myNum.setText((i + 1) + "");
- myThumb.setText(bean.getData().getActivityUserReadList().get(i).getUserRead().getLikeAmount());
- myCollection.setText(bean.getData().getActivityUserReadList().get(i).getUserRead().getFavoritesAmount());
- myScore.setText(bean.getData().getActivityUserReadList().get(i).getUserRead().getScore());
- myInfoLayout.setVisibility(View.VISIBLE);
- }
- }
- } else {
- LinearLayout recyParent = dialog_view.findViewById(R.id.popupwindow_ranklist_recyclerview_layout);
- recyParent.setVisibility(View.GONE);
- ImageView noList = dialog_view.findViewById(R.id.popupwindow_ranklist_recyclerview_layout_nolist);
- noList.setVisibility(View.VISIBLE);
- }
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- }
- });
- }
- boolean loginSuccess = false;
- MISoundLoginCallBack miSoundLoginCallback;
- int mVCodeCount = 60;
- TextView getVCodeTimeText;
- public void initMiSoundLoginWindow(Context context, View dialog_view, int type, MISoundLoginCallBack callBack) {
- miSoundLoginCallback = callBack;
- switch (type) {
- case MiSoundSDKUtil.MI_SOUND_QRCODE_TYPE:
- ImageView qrcode = dialog_view.findViewById(R.id.popupwindow_mi_sound_qrcode);
- userApi.getLoginQRCode(new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- Logger.e("info:" + info.getRetDetail());
- HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
- }.getType());
- Logger.e("bean.getData:" + bean.getData());
- if (bean.getCode().equals("200") && bean.getSuccess()) {
- Logger.e("加载二维码");
- GlideUtils.loadImageSizeKipMemoryCache(context, bean.getData(), qrcode);
- loginSuccess = false;
- handler.sendEmptyMessageDelayed(0x1313, 1000);
- } else {
- Logger.e("加载二维码失败");
- }
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- Logger.e("获取登录二维码失败");
- }
- });
- break;
- case MiSoundSDKUtil.MI_SOUND_BIND_PHONENUM: {
- EditText bindPhoneNumEdit = dialog_view.findViewById(R.id.popupwindow_mi_sound_bind_phone_num_edit);
- EditText bindPhoneNumGetVCode = dialog_view.findViewById(R.id.popupwindow_mi_sound_bind_phone_vcode_edit);
- getVCodeTimeText = dialog_view.findViewById(R.id.popupwindow_mi_sound_bind_phone_getvcode_text);
- FrameLayout mBindSubmit = dialog_view.findViewById(R.id.popupwindow_mi_sound_bind_phone_num_submit);
- TextView mErrorText = dialog_view.findViewById(R.id.popupwindow_mi_sound_bind_phone_error_text);
- mErrorText.setVisibility(View.GONE);
- // {
- // //测试
- // bindPhoneNumEdit.setText("18611822573");
- // bindPhoneNumGetVCode.setText("9999");
- // }
- RxView.focusChanges(bindPhoneNumEdit).subscribe(hasFocus -> {
- if (!hasFocus) {
- hideSoftInput(bindPhoneNumEdit);
- }
- });
- RxView.focusChanges(bindPhoneNumGetVCode).subscribe(hasFocus -> {
- if (!hasFocus) {
- hideSoftInput(bindPhoneNumGetVCode);
- }
- });
- //获取验证码
- RxView.clicks(getVCodeTimeText).throttleFirst(2, TimeUnit.SECONDS).subscribe(o -> {
- String mobile = bindPhoneNumEdit.getText().toString().trim();
- if (!EfunboxUtil.isMobileNO(mobile)) {
- //弹不出来
- // CusToast.getInstance(context).show("请输入正确的手机号", 1000);
- mErrorText.setText("请输入正确的手机号");
- mErrorText.setVisibility(View.VISIBLE);
- return;
- }
- OkHttpClient.doGetAsync(HttpInfo.Builder().setUrl(Consts.getFinalApi() + "/user/verifyCode").addParam("mobileNo", mobile), new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- getVCodeTimeText.setText(String.valueOf(mVCodeCount));
- getVCodeTimeText.setEnabled(false);
- getVCodeTimeText.setClickable(false);
- handler.sendEmptyMessageDelayed(0x1314, 1000);
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- //弹不出来
- // CusToast.getInstance(Consts.getmApplicAtion()).show("获取验证码失败", 1000);
- mErrorText.setText("获取验证码失败:" + info.getRetDetail());
- mErrorText.setVisibility(View.VISIBLE);
- getVCodeTimeText.setEnabled(true);
- getVCodeTimeText.setClickable(true);
- }
- });
- });
- //提交绑定手机号
- RxView.clicks(mBindSubmit).throttleFirst(2, TimeUnit.SECONDS).subscribe(o -> {
- String mobile = bindPhoneNumEdit.getText().toString().trim();
- if (!EfunboxUtil.isMobileNO(mobile)) {
- // CusToast.getInstance(context).show("请输入正确的手机号", 1000);
- mErrorText.setText("请输入正确的手机号");
- mErrorText.setVisibility(View.VISIBLE);
- return;
- }
- userApi.bindPhoneNum(mobile, new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
- }.getType());
- Logger.e("绑定手机号:" + info.getRetDetail());
- if (bean.getCode().equals("200")) {
- if (bean.getSuccess()) {
- Logger.e("绑定手机号成功:" + info.getRetDetail());
- Consts.setmConstsUserBean(bean.getData());
- Toast.makeText(context, "绑定手机号成功", Toast.LENGTH_LONG).show();
- mErrorText.setText("绑定手机号成功");
- mErrorText.setVisibility(View.VISIBLE);
- miSoundLoginCallback.success();
- }
- } else if (bean.getCode().equals("706")) {
- mErrorText.setText("绑定手机号失败:" + bean.getMessage());
- mErrorText.setVisibility(View.VISIBLE);
- }
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- Logger.e("绑定手机号失败:" + info.getRetDetail());
- mErrorText.setText("绑定手机号失败:" + info.getRetDetail());
- mErrorText.setVisibility(View.VISIBLE);
- }
- });
- });
- }
- break;
- case MiSoundSDKUtil.MI_SOUND_SHOW_BINDPHONENUM: {
- TextView tv = dialog_view.findViewById(R.id.popupwindow_mi_sound_show_bind_phoneNum_layout_phoneNum);
- tv.setText("手机号码 :" + Consts.getmConstsUserBean().getMobile());
- }
- break;
- }
- }
- private void hideSoftInput(View view) {
- InputMethodManager manager = ((InputMethodManager) Consts.getmApplicAtion().getSystemService(Context.INPUT_METHOD_SERVICE));
- if (manager != null) {
- manager.hideSoftInputFromWindow(view.getWindowToken(), 0);
- }
- }
- public Handler getPopHandler() {
- return handler;
- }
- private Handler handler = new Handler(new Handler.Callback() {
- @Override
- public boolean handleMessage(@NonNull Message message) {
- switch (message.what) {
- case 0x0131:
- ((TextView) message.obj).setText(message.arg1 + "/100");
- break;
- case 0x1312:
- getMyInfo(mActivity, (TextView) message.obj);
- break;
- case 0x1313:
- //小米绑定手机号轮询查询用户逻辑
- if (loginSuccess) {
- handler.removeMessages(0x1313);
- return true;
- }
- userApi.MiSoundIsLogin(DeviceUuidFactory.getUuid(), new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- try {
- JSONObject object = new JSONObject(info.getRetDetail());
- if (object.getString("code").equals("300") || object.getInt("code") == 300) {
- //暂无数据
- Logger.e("暂无数据");
- handler.sendEmptyMessageDelayed(0x1313, 1000);
- return;
- } else {
- Logger.e("info.getR:" + info.getRetDetail());
- handler.removeMessages(0x1313);
- loginSuccess = true;
- HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
- }.getType());
- Consts.setUID(bean.getData().getUid());
- //用户是否登录,登录了,创建Consts的userbean
- Consts.setmConstsUserBean(bean.getData());
- userApi.loginSign(null, new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- try {
- HttpResultBean<SignBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<SignBean>>() {
- }.getType());
- if (bean.getData().getIsSign()) {
- CusToast.getInstance(Consts.getmApplicAtion()).show("恭喜签到成功\n奖励" + bean.getData().getCount() + "朵小红花", 2000);
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- miSoundLoginCallback.success();
- if (Consts.getUmengChannel().equals(ChannelCodeEnum.YIFANG.getChannelCode()) ||
- Consts.getUmengChannel().equals(ChannelCodeEnum.TMAIL.getChannelCode()) ||
- Consts.getUmengChannel().equals(ChannelCodeEnum.MISOUND.getChannelCode())
- ) {
- //义方渠道检查权限
- if (Consts.getmConstsUserBean() != null) {
- mOrderApi.getAuth(new Callback() {
- @Override
- public void onSuccess(HttpInfo info) throws IOException {
- HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
- }.getType());
- if (!TextUtils.isEmpty(bean.getData())) {
- Consts.setIsYFVip(true);
- }
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- }
- });
- }
- }
- }
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- Logger.e("info:" + info.getRetDetail());
- }
- });
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- }
- }
- @Override
- public void onFailure(HttpInfo info) throws IOException {
- Logger.e("misound_login_error_info.get:" + info.getRetDetail());
- }
- });
- break;
- case 0x1314:
- //小米绑定手机号倒计时逻辑
- if (mVCodeCount == 0) {
- mVCodeCount = 60;
- handler.removeMessages(0x1314);
- getVCodeTimeText.setEnabled(true);
- getVCodeTimeText.setClickable(true);
- getVCodeTimeText.setText("获取验证码");
- return true;
- } else {
- mVCodeCount--;
- getVCodeTimeText.setText(String.valueOf(mVCodeCount));
- handler.sendEmptyMessageDelayed(0x1314, 1000);
- }
- break;
- }
- return false;
- }
- });
- public interface MISoundLoginCallBack {
- void success();
- }
- }
- class OrderSpacesItemDecoration extends RecyclerView.ItemDecoration {
- private int space;
- private int maxCount;
- public OrderSpacesItemDecoration(int space, int max) {
- this.space = space;
- this.maxCount = max;
- }
- @Override
- public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
- int position = parent.getChildAdapterPosition(view);
- Logger.e("position:" + position);
- Logger.e("parent:" + parent.getChildCount());
- if (position < 1) {
- outRect.top = space * 10;
- outRect.bottom = space;
- } else {
- outRect.bottom = space;
- }
- if (position == maxCount - 1) {
- outRect.bottom = space * 10;
- }
- }
- }
|