admin
2021-06-11 ae4dc86b64bd8ef85bc832106741fb98e8d516da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
package com.tejia.lijin.app.ui.mine;
 
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.provider.Settings;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.gson.Gson;
import com.tejia.lijin.app.ShoppingApplication;
import com.tejia.lijin.app.util.user.UserUtil;
import com.wpc.library.content.ConnectivityChangeHelper;
import com.wpc.library.recyclerviewhelper.DividerItemDecoration;
import com.wpc.library.util.common.DimenUtils;
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.ShoppingApi;
import com.tejia.lijin.app.contract.SelectionStoreHouse31Contract;
import com.tejia.lijin.app.entity.SelectionStoreHouse;
import com.tejia.lijin.app.entity.TaoBaoGoodsBrief;
import com.tejia.lijin.app.entity.goods.ShareCommonGoods;
import com.tejia.lijin.app.presenter.SelectionStoreHouse31Presenter;
import com.tejia.lijin.app.ui.dialog.JumpTaoBaoDialog;
import com.tejia.lijin.app.ui.dialog.OrderAppealHistoryDeleteHintDialog;
import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog;
import com.tejia.lijin.app.ui.recommend.MultiGoodsShareActivity;
import com.tejia.lijin.app.util.TopStatusSettings;
import com.tejia.lijin.app.view.BaseActivity;
 
import org.apache.http.Header;
import org.json.JSONObject;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * Created by weikou2015 on 2018/1/19.
 * 分享库
 */
public class SelectionStoreHouseActivity31 extends BaseActivity<SelectionStoreHouse31Contract.SelectionStoreHouseView,
        SelectionStoreHouse31Presenter> implements SelectionStoreHouse31Contract.SelectionStoreHouseView, View.OnClickListener {
    private TextView tv_left;
    private TextView tv_middle;
    private View bottom;
    private ImageView iv_loading;
    private TextView tv_loading;
    private LinearLayout ll_delete, ll_go_scan;
    private TextView tv_delete;
    public CheckBox cb_delete_all;
    //    private TextView tv_delete_all;
    private SwipeRefreshLayout rl_collect;
    private RecyclerView rv_share_house;
    private ToggleButton tv_top_bar_right;
    private SelectionStoreHouseAdapter31 adapter;
    private boolean isLoad = false;
    private ImageView iv_slid_top;
    private String TYPE = "goodsStorage";
    private TextView tv_notice_content;
    private LinearLayout ll_notice;
    private ImageView iv_close;
    private ConnectivityChangeHelper mChangeHelper;
    private LinearLayout ll_no_net, ll_request_failture, ll_content;
    public JumpTaoBaoDialog dialog;
    public TextView tv_share;
    private boolean cb_touch = false;
    private int goodsType = 1;////平台: 1淘宝 2京东 3拼多多
 
    private TextView storehouse_tb;//淘宝tab
    private TextView storehouse_jd;//京东tab
    private TextView storehouse_pdd;//拼多多tab
    private View storehouse_tbline;
    private View storehouse_jdline;
    private View storehouse_pddline;
 
 
    @Override
    protected void initActivityView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_selection_storehouse);
    }
 
    @Override
    protected void findViewById() {
        TopStatusSettings.setStatusViewAndDeepColor(this);
        storehouse_tb = findViewById(R.id.storehouse_tb);
        storehouse_jd = findViewById(R.id.storehouse_jd);
        storehouse_pdd = findViewById(R.id.storehouse_pdd);
        storehouse_tbline = findViewById(R.id.storehouse_tbline);
        storehouse_jdline = findViewById(R.id.storehouse_jdline);
        storehouse_pddline = findViewById(R.id.storehouse_pddline);
        storehouse_tb.setOnClickListener(this);
        storehouse_jd.setOnClickListener(this);
        storehouse_pdd.setOnClickListener(this);
        tv_left = findViewById(R.id.tv_top_bar_left);
        tv_middle = findViewById(R.id.tv_top_bar_middle);
        tv_top_bar_right = findViewById(R.id.btn_delete);
        rl_collect = findViewById(R.id.rl_collect);
        rv_share_house = findViewById(R.id.rv_share_house);
        tv_delete = findViewById(R.id.tv_delete);
        tv_share = findViewById(R.id.tv_share);
        cb_delete_all = findViewById(R.id.cb_delete_all);
        ll_delete = findViewById(R.id.ll_delete);
        ll_go_scan = findViewById(R.id.ll_go_scan);
        iv_slid_top = findViewById(R.id.iv_slid_top);
        iv_slid_top.setOnClickListener(this);
        ll_delete.setVisibility(View.GONE);
        tv_top_bar_right.setVisibility(View.INVISIBLE);
        tv_middle.setText("分享库");
        tv_left.setOnClickListener(this);
        tv_top_bar_right.setOnClickListener(this);
        tv_top_bar_right.setChecked(false);
        tv_delete.setOnClickListener(this);
        tv_share.setOnClickListener(this);
        ll_content = findViewById(R.id.ll_content);
        ll_no_net = findViewById(R.id.ll_no_net);
        ll_go_scan = findViewById(R.id.ll_go_scan);
        ll_request_failture = findViewById(R.id.ll_request_failture);
        findViewById(R.id.tv_net_setting).setOnClickListener(this);
        findViewById(R.id.tv_refresh).setOnClickListener(this);
 
        float hRatio = 260 / 720f;
        float wRatio = 23 / 720f;
        int bottomPo = (int) (DimenUtils.getScreenWidth(this) * hRatio);
        int rightPo = (int) (DimenUtils.getScreenWidth(this) * wRatio);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DimenUtils.dip2px(this, 40), DimenUtils.dip2px(this, 40));
        params.setMargins(0, 0, rightPo, bottomPo);
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        iv_slid_top.setLayoutParams(params);
        //设置 RecyclerView 显示模式
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        rv_share_house.setLayoutManager(linearLayoutManager);
        DividerItemDecoration decoration = new DividerItemDecoration(DividerItemDecoration.VERTICAL);
        decoration.setSize(DimenUtils.dip2px(this, 5));
        rv_share_house.addItemDecoration(decoration);
        adapter = new SelectionStoreHouseAdapter31(SelectionStoreHouseActivity31.this, wList);
 
        bottom = LayoutInflater.from(this).inflate(R.layout.item_recyclerview_bottom, null);
        tv_loading = bottom.findViewById(R.id.tv_loading);
        iv_loading = bottom.findViewById(R.id.iv_loading);
        AnimationDrawable animationDrawable = (AnimationDrawable) getResources().getDrawable(
                R.drawable.anim_list_loading);
        iv_loading.setImageDrawable(animationDrawable);
        animationDrawable.start();
//        Glide.with(this).load(R.drawable.gif_loading).into(iv_loading);
        bottom.setVisibility(View.GONE);
        adapter.addFooterView(bottom);
 
        tv_notice_content = findViewById(R.id.tv_notice_content);
        ll_notice = findViewById(R.id.ll_notice);
        iv_close = findViewById(R.id.iv_close);
 
        View header = LayoutInflater.from(this).inflate(R.layout.item_recyclerview_bottom, null);
        header.findViewById(R.id.iv_loading).setVisibility(View.GONE);
        header.findViewById(R.id.tv_loading).setVisibility(View.GONE);
        header.findViewById(R.id.ll_loading).setLayoutParams(new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, DimenUtils.dip2px(this, 8)));
        adapter.addHeaderView(header);
 
        rv_share_house.setAdapter(adapter);
        ((SimpleItemAnimator) rv_share_house.getItemAnimator()).setSupportsChangeAnimations(false); //取消RecyclerView的动画效果
        mChangeHelper = new ConnectivityChangeHelper(this,
                new ConnectivityChangeHelper.OnConnectivityChangeListener() {
 
                    @Override
                    public void onNetworkUnAvailable() {
                    }
 
                    @Override
                    public void onNetworkAvailable() {
                        mPresenter.requestState(0, ll_delete
                                , ll_go_scan, ll_no_net, ll_request_failture, ll_content, tv_top_bar_right);
                        if (wList.size() == 0) {
                            setData();
                        }
                    }
                });
 
        rl_collect.setColorSchemeColors(getResources().getColor(R.color.theme));
        rl_collect.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                page = 1;
                rl_collect.setRefreshing(true);
                if (!tv_top_bar_right.isChecked())
                    setData();
                else
                    rl_collect.setRefreshing(false);
            }
        });
 
        rv_share_house.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
                int first = manager.findFirstVisibleItemPosition();
                int last = manager.findLastVisibleItemPosition();
                int total = manager.getItemCount();
                if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                    if (first == 0) {
                        iv_slid_top.setVisibility(View.GONE);
                    }
                    if (last == total - 1 && wList.size() < count && isLoad && !tv_top_bar_right.isChecked()) {
                        page++;
                        isLoad = false;
                        iv_loading.setVisibility(View.VISIBLE);
                        tv_loading.setText("正在加载更多是数据");
                        setData();
                    }
                }
            }
 
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, final int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (Math.abs(dy) > 10) {
                    if (dy > 0) {
                        iv_slid_top.setVisibility(View.GONE);
                    } else {
                        iv_slid_top.setVisibility(View.VISIBLE);
                    }
                }
            }
        });
        cb_delete_all.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                cb_touch = true;
                return false;
            }
        });
        /**
         * 全选按钮
         */
        cb_delete_all.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    adapter.allSelect(true, goodsType);
                } else {
                    if (cb_touch)
                        adapter.allSelect(false, goodsType);
                }
                cb_touch = false;
            }
        });
        rl_collect.setRefreshing(true);
    }
 
    @Override
    protected SelectionStoreHouse31Presenter createPresenter() {
        return new SelectionStoreHouse31Presenter(this);
    }
 
 
    @Override
    protected void getData() {
        //小黄条
        mPresenter.getAppPageNotification(TYPE);
    }
 
 
    @Override
    protected void onResume() {
        super.onResume();
        mChangeHelper.registerReceiver();
        if (dialog != null && dialog.isShowing())
            dialog.dismiss();
    }
 
    @Override
    protected void onPause() {
        super.onPause();
        mChangeHelper.unregisterReceiver();
    }
 
    /**
     * 小黄条
     */
 
    List<SelectionStoreHouse> wList = new ArrayList<>();
 
    private int page = 1;//页码初始值
 
    private int count = 999;
 
    /**
     * 获取分享库数据
     */
    public void setData() {
        tv_top_bar_right.setEnabled(false);
        if (page > 1) {
            bottom.setVisibility(View.VISIBLE);
        } else {
            bottom.setVisibility(View.GONE);
        }
        mPresenter.getSelectioStoreHouseList(page + "", UserUtil.getUid(ShoppingApplication.application), goodsType + "");
    }
 
    ShapeLoadingDialog pd = null;
    private boolean storehouse_mode = false;//淘宝京东拼多多 选中标记
    private boolean storehouse_modeJD = false;//淘宝京东拼多多 选中标记
    private boolean storehouse_modePDD = false;//淘宝京东拼多多 选中标记
 
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_top_bar_left:
                finish();
                break;
            case R.id.iv_slid_top://滚动到顶部
                rv_share_house.getLayoutManager().scrollToPosition(0);
                break;
            case R.id.tv_delete://删除
                int size = 0;
                if (goodsType == 1) {//淘宝
                    size = adapter.selectList.size();
                } else if (goodsType == 2) {//京东
                    size = adapter.selectListJD.size();
                } else {//拼多多
                    size = adapter.selectListPDD.size();
                }
                if (size > 0) {
                    OrderAppealHistoryDeleteHintDialog.Builder builder = new OrderAppealHistoryDeleteHintDialog.Builder(this);
                    builder.setMessage("删除后将无法恢复,确定要删除?").setNegativeButton("不了", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    }).setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            delete(goodsType);
                        }
                    }).create().show();
                }
                break;
            case R.id.tv_share://分享
                int size2 = 0;
                if (goodsType == 1) {//淘宝
                    size2 = adapter.selectList.size();
                } else if (goodsType == 2) {//京东
                    size2 = adapter.selectListJD.size();
                } else {//拼多多
                    size2 = adapter.selectListPDD.size();
                }
                if (size2 > 0 && size2 < 10) {
                    final Intent intent = new Intent(SelectionStoreHouseActivity31.this, MultiGoodsShareActivity.class);
                    //整理数据
                    Map<String, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
                    for (SelectionStoreHouse house : wList)
                        goodsMap.put(house.getStorageId(), house.getGoods());
                    final List<ShareCommonGoods> shareGoodsList = new ArrayList<>();
                    ArrayList<String> ids = null;
 
                    if (goodsType == 1) {//淘宝
                        ids = adapter.selectList;
                    } else if (goodsType == 2) {//京东
                        ids = adapter.selectListJD;
                    } else {//拼多多
                        ids = adapter.selectListPDD;
                    }
 
 
                    if (ids != null)
                        for (String id : ids) {
                            TaoBaoGoodsBrief goods = goodsMap.get(id);
                            if (goods != null) {
                                shareGoodsList.add(new ShareCommonGoods(goods.getGoodsId(), goods.getGoodsType()));
                            }
                        }
 
                    if (shareGoodsList.size() > 0) {
                        //请求分享
                        String idsString = new Gson().toJson(ids);
                        ShoppingApi.shareSelectStoreHouse(this, idsString, UserUtil.getUid(ShoppingApplication.application), goodsType, new BasicTextHttpResponseHandler() {
                            @Override
                            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                                if (jsonObject.optInt("code") == 0) {
                                    String imgUrl = jsonObject.optJSONObject("data")
                                            .optJSONObject("shareImg").optString("url");
                                    String shareId = jsonObject.optJSONObject("data").optString("shareId");
                                    //跳转界面
                                    intent.putExtra("shareId", shareId);
                                    intent.putExtra("goodsInfo", MultiGoodsShareActivity.getGoodsIntentData(shareGoodsList));
                                    startActivityForResult(intent, 11);
                                } else {
                                    Toast.makeText(SelectionStoreHouseActivity31.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
                                    finish();
                                }
                            }
 
                            @Override
                            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                                super.onFailure(statusCode, headers, responseString, throwable);
                                Toast.makeText(SelectionStoreHouseActivity31.this, "数据获取失败", Toast.LENGTH_SHORT).show();
                                finish();
                            }
                        });
                    }
                } else if (size2 == 0) {
                    Toast.makeText(SelectionStoreHouseActivity31.this, "请选择商品", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(SelectionStoreHouseActivity31.this, "最多分享9个商品", Toast.LENGTH_SHORT).show();
                }
                break;
            /**
             * 选择/or/完成
             */
            case R.id.btn_delete:
                if (tv_top_bar_right.isChecked()) {//完成(选中)
                    ll_delete.setVisibility(View.VISIBLE);//底部 选择/删除/分享栏(显示)
                    rl_collect.setEnabled(false);
                    if (goodsType == 1) {//淘宝
                        storehouse_mode = true;
                    } else if (goodsType == 2) {//京东
                        storehouse_modeJD = true;
                    } else {//拼多多
                        storehouse_modePDD = true;
                    }
                } else {//选择(取消)
                    ll_delete.setVisibility(View.GONE);//底部 选择/删除/分享栏(隐藏)
                    rl_collect.setEnabled(true);
                    if (goodsType == 1) {//淘宝
                        storehouse_mode = false;
                    } else if (goodsType == 2) {//京东
                        storehouse_modeJD = false;
                    } else {//拼多多
                        storehouse_modePDD = false;
                    }
                }
                this.setSelectedMode(tv_top_bar_right.isChecked(), goodsType);
                break;
            case R.id.tv_net_setting://设置
                startActivity(new Intent(Settings.ACTION_SETTINGS));
                break;
            case R.id.tv_refresh://刷新
                startActivity(new Intent(Settings.ACTION_SETTINGS));
                break;
            case R.id.storehouse_tb://淘宝
                goodsType = 1;
                page = 1;
                rl_collect.setRefreshing(true);
                mPresenter.setBar(1, storehouse_tb, storehouse_jd, storehouse_pdd, storehouse_tbline, storehouse_jdline, storehouse_pddline);
                setData();
                tv_top_bar_right.setChecked(storehouse_mode);
//                this.setSelectedMode(storehouse_mode, goodsType);
                ll_delete.setVisibility(storehouse_mode ? View.VISIBLE : View.GONE);
                break;
            case R.id.storehouse_jd://京东
                goodsType = 2;
                page = 1;
                rl_collect.setRefreshing(true);
                mPresenter.setBar(2, storehouse_tb, storehouse_jd, storehouse_pdd, storehouse_tbline, storehouse_jdline, storehouse_pddline);
                setData();
                tv_top_bar_right.setChecked(storehouse_modeJD);
//                this.setSelectedMode(storehouse_modeJD, goodsType);
                ll_delete.setVisibility(storehouse_modeJD ? View.VISIBLE : View.GONE);
                break;
            case R.id.storehouse_pdd://拼多多
                goodsType = 3;
                page = 1;
                rl_collect.setRefreshing(true);
                mPresenter.setBar(3, storehouse_tb, storehouse_jd, storehouse_pdd, storehouse_tbline, storehouse_jdline, storehouse_pddline);
                setData();
                tv_top_bar_right.setChecked(storehouse_modePDD);
//                this.setSelectedMode(storehouse_modeJD, goodsType);
                ll_delete.setVisibility(storehouse_modePDD ? View.VISIBLE : View.GONE);
                break;
            default:
                break;
        }
    }
 
    /**
     * 分享后回调
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 11 && resultCode == 12) {
            //清除选中数据
            if (goodsType == 1) {
                adapter.selectList.clear();
            } else if (goodsType == 2) {
                adapter.selectListJD.clear();
            } else {
                adapter.selectListPDD.clear();
            }
            //右上角 改未未选中
            tv_top_bar_right.setChecked(false);
            rl_collect.setEnabled(true);//下拉刷新
            updateView();//更新 顶部和底部状态栏
            ll_delete.setVisibility(View.GONE);
            ActivityResult = true;//设置分享回调标记
            setData();//再次请求数据
        }
    }
 
    /**
     * 标记是否是onActivityResult 返回防止重新请求数据 显示item选择框
     */
    private boolean ActivityResult = false;
 
    /**
     * 请求删除选择商品
     */
    private void delete(int goodsType) {
        if (pd == null) {
            pd = new ShapeLoadingDialog.Builder(this).build();
        }
        pd.show();
        String ids = "";//获取要删除的商品ID
        if (goodsType == 1) {//淘宝
            ids = JSONArray.parseArray(JSON.toJSONString(adapter.selectList)).toJSONString();
        } else if (goodsType == 2) {//京东
            ids = JSONArray.parseArray(JSON.toJSONString(adapter.selectListJD)).toJSONString();
        } else {//拼多多
            ids = JSONArray.parseArray(JSON.toJSONString(adapter.selectListPDD)).toJSONString();
        }
        //请求删除选择商品
        mPresenter.deleteSelectStoreHouse(ids, UserUtil.getUid(ShoppingApplication.application));
    }
 
    /**
     * 更新 选择状态 更新全选/删除/分享状态
     */
    public void updateView() {
//        tv_top_bar_right.setChecked(isSelectedMode());
        //因为在点击分享后就会回调onActivityResult方法 但是上面的选择按钮状态没有改变
        //所有当已经选中改变下面底部栏隐藏
        if (!tv_top_bar_right.isChecked()) {
            ll_delete.setVisibility(View.VISIBLE);
        } else {
            ll_delete.setVisibility(View.GONE);
        }
        //清除 当前京东拼多多淘宝 选中状态
        if (goodsType == 1) {
            storehouse_mode = false;
        } else if (goodsType == 2) {
            storehouse_modeJD = false;
        } else
            storehouse_modePDD = false;
        //右上角 按钮设置为未选中
        tv_top_bar_right.setChecked(false);
    }
 
    /**
     * 重置adapter-item选中
     *
     * @param selectedMode
     * @param goodsType
     */
    public void setSelectedMode(boolean selectedMode, int goodsType) {
        adapter.setSelectedMode(selectedMode, goodsType, storehouse_modeJD, storehouse_modePDD, storehouse_mode);
    }
 
    public boolean isSelectedMode() {
        return adapter.isSelectedMode();
    }
 
 
    /**
     * 小黄条
     *
     * @param jsonObject
     */
    @Override
    public void onAppPageNotificationSuccess(JSONObject jsonObject) {
        mPresenter.setAppPageNotificationSuccess(jsonObject, tv_notice_content, ll_notice, iv_close);
    }
 
    @Override
    public void onAppPageNotificationFail(String errorInfo) {
 
    }
 
    /**
     * 分享库数据 请求成功
     *
     * @param jsonObject
     */
    @Override
    public void onSelectioStoreHouseListSuccess(JSONObject jsonObject) {
        count = mPresenter.setresult_list(jsonObject, page, wList, adapter, count, bottom, iv_loading, tv_loading, ll_delete
                , ll_go_scan, ll_no_net, ll_request_failture, ll_content, tv_top_bar_right, goodsType);
        if (goodsType == 1) {
            this.setSelectedMode(ActivityResult ? false : storehouse_mode, goodsType);
        } else if (goodsType == 2) {
            this.setSelectedMode(ActivityResult ? false : storehouse_modeJD, goodsType);
        } else {
            this.setSelectedMode(ActivityResult ? false : storehouse_modePDD, goodsType);
        }
        isLoad = true;
        rl_collect.setRefreshing(false);
        tv_top_bar_right.setEnabled(true);//允许点击
        ActivityResult = false;
    }
 
    /**
     * 分享库数据 请求失败
     *
     * @param errorInfo
     */
    @Override
    public void onSelectioStoreHouseListFail(String errorInfo) {
        mPresenter.setSelectioStoreHouseListFail(bottom, ll_delete
                , ll_go_scan, ll_no_net, ll_request_failture, ll_content, tv_top_bar_right, wList);
        isLoad = true;
        rl_collect.setRefreshing(false);
        tv_top_bar_right.setEnabled(true);
    }
 
    /**
     * 删除成功
     *
     * @param jsonObject
     */
    @Override
    public void onDeleteSelectStoreHouseSuccess(JSONObject jsonObject) {
        mPresenter.setDeleteSelectStoreHouseSuccess(jsonObject, wList, adapter, pd, ll_delete
                , ll_go_scan, ll_no_net, ll_request_failture, ll_content, tv_top_bar_right, goodsType);
        rl_collect.setRefreshing(false);
        rl_collect.setEnabled(true);
        if (goodsType == 1) {
            storehouse_mode = false;
        } else if (goodsType == 2) {
            storehouse_modeJD = false;
        } else {
            storehouse_modePDD = false;
        }
 
    }
 
    /**
     * 删除商品请求失败
     *
     * @param errorInfo
     */
    @Override
    public void onDeleteSelectStoreHouseFail(String errorInfo) {
        if (pd != null) {
            pd.dismiss();
        }
        rl_collect.setRefreshing(false);
        Toast.makeText(SelectionStoreHouseActivity31.this, "删除失败----" + errorInfo, Toast.LENGTH_LONG).show();
    }
 
    /**
     * 主线程刷新 adapter
     */
    public void SetnotifyDataSetChanged() {
        adapter.notifyDataSetChanged();
//        rl_collect.postDelayed(new Runnable() {
//            @Override
//            public void run() {
//
//            }
//        }, 50);
    }
}