admin
2021-06-11 ae4dc86b64bd8ef85bc832106741fb98e8d516da
app/src/main/java/com/tejia/lijin/app/ui/main/BetterGoodsFragment.java
@@ -2,6 +2,7 @@
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -29,10 +30,12 @@
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.ShoppingApi;
import com.tejia.lijin.app.ShoppingApplication;
import com.tejia.lijin.app.callBack.PermissionInterface;
import com.tejia.lijin.app.entity.HomeBanner;
import com.tejia.lijin.app.entity.TrendsCategory;
import com.tejia.lijin.app.entity.common.ImageShowEntity;
import com.tejia.lijin.app.entity.trends.ConvertLinkJumpVO;
import com.tejia.lijin.app.entity.trends.SendCircleCommment;
import com.tejia.lijin.app.entity.trends.SendCircleContent;
import com.tejia.lijin.app.entity.trends.SendCircleImage;
@@ -40,13 +43,22 @@
import com.tejia.lijin.app.ui.dialog.SendCircleShareDialog;
import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog;
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
import com.tejia.lijin.app.ui.mine.LoginSelectActivity;
import com.tejia.lijin.app.ui.mine.MyInfoActivity;
import com.tejia.lijin.app.ui.recommend.SearchActivity;
import com.tejia.lijin.app.ui.recommend.ShareExplosionsGoodsDetailActivity;
import com.tejia.lijin.app.ui.trends.BigImageActivity;
import com.tejia.lijin.app.ui.trends.SendCircleAdapter;
import com.tejia.lijin.app.util.ApkUtil;
import com.tejia.lijin.app.util.Constant;
import com.tejia.lijin.app.util.ExceptionConstant;
import com.tejia.lijin.app.util.GoodsBuyJumpUtil;
import com.tejia.lijin.app.util.PermissionHelper;
import com.tejia.lijin.app.util.baichuan.AlibcTradeUtil;
import com.tejia.lijin.app.util.clipboard.ClipboardUtil;
import com.tejia.lijin.app.util.ui.HomeUIUtil;
import com.tejia.lijin.app.util.ui.TextViewUtil;
import com.tejia.lijin.app.util.ui.dialog.DialogUtil;
import com.tejia.lijin.app.util.user.UserUtil;
import com.wpc.library.RetainViewFragment;
import com.wpc.library.content.ConnectivityChangeHelper;
@@ -129,7 +141,7 @@
    private void init() {
        ((FrameLayout) mAquery.id(R.id.fl_search).getView()).setBackground(HomeUIUtil.getHomeTopBg("#FF227B", "#FF2A3E"));
        ((FrameLayout) mAquery.id(R.id.fl_search).getView()).setBackground(HomeUIUtil.getHomeTopBg(getContext()));
        mCategory = (TrendsCategory) getArguments().getSerializable("category");
        cId = getArguments().getString("cid", "0");
        cate = getArguments().getString("cate");
@@ -219,7 +231,7 @@
                        page++;
                        isLoad = false;
                        iv_loading.setVisibility(View.VISIBLE);
                        tv_loading.setText("正在加载更多数据");
                        tv_loading.setText(getResources().getString(R.string.loading_more_text));
                        getContentList();
                    }
                }
@@ -478,9 +490,97 @@
                        }
                    }
                    if (adapter == null) {
                        adapter = new SendCircleAdapter(getActivity(), mBannerList, mContentList, BetterGoodsFragment.this);
                        adapter = new SendCircleAdapter(getActivity(), mBannerList, mContentList, BetterGoodsFragment.this, new TextViewUtil.URLClickListener() {
                            @Override
                            public void onClick(final String url) {
                                ShoppingApi.evaluateConvertLink(
                                        getContext(), UserUtil.
                                                getUid(getContext()), url, new
                                                BasicTextHttpResponseHandler() {
                                                    @Override
                                                    public void onStart() {
                                                        super.onStart();
                                                        DialogUtil.show(pd);
                                                    }
                                                    @Override
                                                    public void onSuccessPerfect(int statusCode, Header[]
                                                            headers, JSONObject jsonObject) throws Exception {
                                                        super.onSuccessPerfect(statusCode, headers, jsonObject);
                                                        //成功
                                                        if (jsonObject.optInt("code") == 0) {
                                                            JSONObject data = jsonObject.optJSONObject("data");
                                                            ConvertLinkJumpVO jumpVO = new Gson().fromJson(data.toString(), ConvertLinkJumpVO.class);
                                                            switch (jumpVO.getSourceType()) {
                                                                case Constant.GOODS_TYPE_TB:
                                                                    GoodsBuyJumpUtil.jumpTB(getActivity(), null, jumpVO.getJumpLink().getJumpLink(), jumpVO.getJumpLink().getNativeJumpLink(), null, null);
                                                                    break;
                                                                case Constant.GOODS_TYPE_JD:
                                                                    GoodsBuyJumpUtil.jumpJD(getActivity(), jumpVO.getJumpLink(), null, null);
                                                                    break;
                                                                case Constant.GOODS_TYPE_PDD:
                                                                    GoodsBuyJumpUtil.jumpPDD(getActivity(), jumpVO.getJumpLink(), null);
                                                                    break;
                                                                case Constant.GOODS_TYPE_VIP:
                                                                    GoodsBuyJumpUtil.jumpVIPShop(getActivity(), jumpVO.getJumpLink(), null);
                                                                    break;
                                                                case Constant.GOODS_TYPE_SUNING:
                                                                    GoodsBuyJumpUtil.jumpSuning(getActivity(), jumpVO.getJumpLink(), null);
                                                                    break;
                                                            }
                                                        } else {
                                                            int code = jsonObject.optInt("code");
                                                            switch (code) {
                                                                case ExceptionConstant.CODE_NOT_LOGIN:
                                                                    startActivity(new Intent(getContext(), LoginSelectActivity.class));
                                                                    break;
                                                                case ExceptionConstant.CODE_AUTH_PDD_NO_AUTH:
                                                                    Toast.makeText(getContext(), "请备案拼多多账号", Toast.LENGTH_SHORT).show();
                                                                    startActivity(new Intent(getContext(), MyInfoActivity.class));
                                                                    break;
                                                                case ExceptionConstant.CODE_AUTH_TAOBAO_NO_AUTH:
                                                                    Toast.makeText(getContext(), "请授权淘宝账号", Toast.LENGTH_SHORT).show();
                                                                    startActivity(new Intent(getContext(), MyInfoActivity.class));
                                                                    break;
                                                                case ExceptionConstant.CODE_JUMP_NO_SUPPORT:
                                                                    //不支持跳转
                                                                    JSONObject data = jsonObject.optJSONObject("data");
                                                                    ConvertLinkJumpVO jumpVO = new Gson().fromJson(data.toString(), ConvertLinkJumpVO.class);
                                                                    if (jumpVO.getSourceType() != null && jumpVO.getSourceType() == Constant.GOODS_TYPE_TB) {
                                                                        //复制口令跳转到淘宝
                                                                        //是否安装淘宝
                                                                        if (ApkUtil.checkAPP(getContext(), "com.taobao.taobao")) {
                                                                            ClipboardUtil.copy(getContext(), url);
                                                                            startActivity(getContext().getPackageManager().getLaunchIntentForPackage("com.taobao.taobao"));
                                                                        }
                                                                    }
                                                                    break;
                                                                default:
                                                                    Toast.makeText(getContext(), jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
                                                            }
                                                        }
                                                    }
                                                    @Override
                                                    public void onFailure(int statusCode, Header[]
                                                            headers, String jsonObject, Throwable e) {
                                                        super.onFailure(statusCode, headers, jsonObject, e);
                                                        Toast.makeText(getContext(), "网络请求出错", Toast.LENGTH_SHORT).show();
                                                    }
                                                    @Override
                                                    public void onFinish() {
                                                        super.onFinish();
                                                        DialogUtil.dismiss(pd);
                                                    }
                                                });
                            }
                        });
                        rv_better_goods.setRecycledViewPool(new RecyclerView.RecycledViewPool());
                        rv_better_goods.setAdapter(adapter);
                        initLoadingView();
                    } else {
                        adapter.notifyDataSetChanged();
@@ -507,7 +607,8 @@
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
            public void onFailure(int statusCode, Header[] headers, String
                    responseString, Throwable throwable) {
                super.onFailure(statusCode, headers, responseString, throwable);
                bottom.setVisibility(View.GONE);
                if (NetUtils.getNetworkState(srl_better_goods.getContext()).equalsIgnoreCase(NetUtils.NETWORK_NONE)) {
@@ -570,51 +671,46 @@
    public void copyComment(final SendCircleContent content, SendCircleCommment comment) {
        actionParams = new ActionParams(content, comment);
        actionParams.type = ActionParams.TYPE_COPY_COMMENT;
        prepareAction(new IPrePareSuccessListener() {
        Long uid = UserUtil.getUid(getContext());
        ShoppingApi.evaluateCopyComment(getContext(), uid, actionParams.content.getId(), actionParams.comment.getId(), new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccess() {
                Long uid = UserUtil.getUid(getContext());
                ShoppingApi.evaluateCopyComment(getContext(), uid, actionParams.content.getId(), actionParams.comment.getId(), new BasicTextHttpResponseHandler() {
                    @Override
                    public void onStart() {
                        super.onStart();
                        if (!pd.isShowing())
                            pd.show();
            public void onStart() {
                super.onStart();
                DialogUtil.show(pd);
            }
                    }
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                super.onSuccessPerfect(statusCode, headers, jsonObject);
                if (!filterResponse(jsonObject))
                    return;
                if (jsonObject.optInt("code") == 0) {
                    copyTypeMap.put(content.getId(), 2);
                    ClipboardUtil.copy(getContext(), jsonObject.optJSONObject("data").optString("text"));
                    Toast.makeText(getContext(), "复制成功", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getContext(), jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
                }
            }
                    @Override
                    public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                        super.onSuccessPerfect(statusCode, headers, jsonObject);
                        if (!filterResponse(jsonObject))
                            return;
                        if (jsonObject.optInt("code") == 0) {
                            copyTypeMap.put(content.getId(), 2);
                            ClipboardUtil.copy(getContext(), jsonObject.optJSONObject("data").optString("text"));
                            Toast.makeText(getContext(), "复制成功", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(getContext(), jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
                        }
                    }
            @Override
            public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) {
                super.onFailure(statusCode, headers, jsonObject, e);
            }
                    @Override
                    public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) {
                        super.onFailure(statusCode, headers, jsonObject, e);
                    }
                    @Override
                    public void onFinish() {
                        super.onFinish();
                        if (pd.isShowing())
                            pd.dismiss();
                    }
                });
            @Override
            public void onFinish() {
                super.onFinish();
                if (pd.isShowing())
                    pd.dismiss();
            }
        });
    }
    @Override
    public void createERCode(SendCircleContent content, List<SendCircleImage> imgList, SendCircleImage img, final int position) {
    public void createERCode(SendCircleContent
                                     content, List<SendCircleImage> imgList, SendCircleImage img, final int position) {
        actionParams = new ActionParams(content, imgList, img, position);
        actionParams.type = ActionParams.TYPE_CREATE_ERCODE;
        prepareAction(new IPrePareSuccessListener() {
@@ -772,7 +868,7 @@
                            if (list.length() > 0) {
                                //保存图片
                                String rootPath = android.os.Environment.getExternalStorageDirectory()
                                        + "/blksapp";
                                        + "/tejiaapp";
                                File rootFile = new File(rootPath);
                                if (!rootFile.exists()) {
                                    rootFile.mkdirs();
@@ -842,8 +938,40 @@
    @Override
    public void copyRecommendText(SendCircleContent content) {
        ClipboardUtil.copy(getContext(), content.getTitle());
        Toast.makeText(getContext(), "复制成功", Toast.LENGTH_SHORT).show();
        ShoppingApi.evaluateCopyRecommend(getContext(), UserUtil.getUid(getContext()), content.getId(), new BasicTextHttpResponseHandler() {
            @Override
            public void onStart() {
                super.onStart();
                DialogUtil.show(pd);
            }
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                super.onSuccessPerfect(statusCode, headers, jsonObject);
                if (jsonObject.optInt("code") == 0) {
                    JSONObject data = jsonObject.optJSONObject("data");
                    String content = data.optString("content");
                    ClipboardUtil.copy(getContext(), content);
                    Toast.makeText(getContext(), "复制成功", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getContext(), jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
                }
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) {
                super.onFailure(statusCode, headers, jsonObject, e);
                Toast.makeText(getContext(), "网络请求出错", Toast.LENGTH_SHORT).show();
            }
            @Override
            public void onFinish() {
                super.onFinish();
                DialogUtil.dismiss(pd);
            }
        });
        copyTypeMap.put(content.getId(), 1);
    }
@@ -926,7 +1054,7 @@
        if (!pd.isShowing())
            pd.show();
        Long uid = UserUtil.getUid(getContext());
        ShoppingApi.getTaoBaoAuthInfo(getContext(), uid + "", null, "share", true, new BasicTextHttpResponseHandler() {
        ShoppingApi.getTaoBaoAuthInfo(getContext(), UserUtil.getUid(ShoppingApplication.application), null, "share", true, new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                if (jsonObject.optInt("code") == 0) {