admin
2021-05-17 06a80d5c4b3a971cdc1ca3d91717ec3f6e03a443
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
package com.tejia.lijin.app.ui.BrandRebate;
 
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import com.wpc.library.widget.MyGridView;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.entity.BranShopInfo;
import com.tejia.lijin.app.ui.BaseActivity;
import com.tejia.lijin.app.util.TopStatusSettings;
import com.tejia.lijin.app.util.umengCustomEvent.BrandRebateEvent;
 
import org.json.JSONException;
 
import java.util.ArrayList;
 
/**
 * 所有有店铺
 */
public class BrandInfoAllActivity extends BaseActivity implements View.OnClickListener {
    private TextView tv_left, tv_middle;
    private MyGridView gv_category_top;
    private LinearLayout brandinfoall_loading2;
    private Bundle str = new Bundle();
    private String name;
 
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_brandinfoall);
        TopStatusSettings.setStatusViewAndDeepColor(this);
        inint();
        OnClickListener();
        gv_category_top.setNumColumns(4);
//        gv_category_top.getFocusedChild();
        str = getIntent().getBundleExtra("bList");
        name = getIntent().getStringExtra("arg");
        tv_middle.setText(name);
        try {
            settop(str);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        BrandRebateEvent.brandhistorylist(this);//品牌-浏览历史列表
    }
 
    private void inint() {
        tv_left = findViewById(R.id.tv_top_bar_left);
        tv_middle = findViewById(R.id.tv_top_bar_middle);
        gv_category_top = findViewById(R.id.brandinfoall_top);
        brandinfoall_loading2 = findViewById(R.id.brandinfoall_loading2);
    }
 
    private void OnClickListener() {
        tv_left.setOnClickListener(this);
    }
 
 
    /**
     * 设置九宫格数据
     *
     * @param list
     */
    private void settop(Bundle list) throws JSONException {
//        fragment_brand_fragment_sf.setRefreshing(false);
        ArrayList<BranShopInfo> mList = new ArrayList<>();
        for (int i = 1; i <= list.size(); i++) {
            BranShopInfo vJSON = (BranShopInfo) list.getSerializable("info" + i);
            mList.add(vJSON);
        }
        if (mList.size() > 24) {
            brandinfoall_loading2.setVisibility(View.VISIBLE);
        } else {
            brandinfoall_loading2.setVisibility(View.INVISIBLE);
        }
        //传入id 判断是不是 精选页arg
        gv_category_top.setAdapter(new BrandInfoAllAdapter(this, mList));
//        gv_category_top.setFocusable(true);
//        gv_category_top.setFocusableInTouchMode(true);
//        gv_category_top.requestFocus();
//        gv_category_top.requestFocusFromTouch();
    }
 
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //返回
            case R.id.tv_top_bar_left:
                finish();
                break;
            default:
                break;
        }
    }
 
    @Override
    protected void onDestroy() {
        super.onDestroy();
        gv_category_top = null;
        brandinfoall_loading2 = null;
        str = null;
        tv_left = null;
        tv_middle = null;
 
    }
}