admin
6 天以前 7f0825f8195a522ed7e8bcdb6347f3a719e06c74
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
package com.weikou.beibeivideo.ui.recommend;
 
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
 
import com.androidquery.AQuery;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.lcjian.library.util.ManifestDataUtil;
import com.lcjian.library.util.common.AndroidManifestUtil;
import com.lcjian.library.util.common.StringUtils;
import com.lcjian.library.widget.FlowLayout;
import com.lcjian.library.widget.MyGridView;
import com.qq.e.ads.cfg.VideoOption;
import com.qq.e.ads.nativ.ADSize;
import com.qq.e.ads.nativ.NativeExpressAD;
import com.qq.e.ads.nativ.NativeExpressADView;
import com.qq.e.comm.util.AdError;
import com.umeng.analytics.MobclickAgent;
import com.weikou.beibeivideo.BasicTextHttpResponseHandler;
import com.weikou.beibeivideo.BeibeiVideoAPI;
import com.weikou.beibeivideo.entity.ad.AdPositionEnum;
import com.weikou.beibeivideo.entity.ad.ExpressAdContainer;
import com.weikou.beibeivideo.ui.BaseActivity;
import com.weikou.beibeivideo.ui.common.CommonFragmentActivity;
import com.weikou.beibeivideo.ui.common.GridVideoAdapter1;
import com.weikou.beibeivideo.ui.main.MainActivity;
import com.weikou.beibeivideo.ui.video.SuggestKeysAdapter;
import com.weikou.beibeivideo.util.BeibeiConstant;
import com.weikou.beibeivideo.R;
import com.weikou.beibeivideo.util.DimenUtils;
import com.weikou.beibeivideo.util.ad.AdUtil;
import com.weikou.beibeivideo.util.ad.ExpressAdManager;
import com.weikou.beibeivideo.util.goldcorn.GoldCornUtil;
import com.weikou.beibeivideo.util.ui.TopStatusSettings;
 
import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONObject;
 
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
 
public class SearchActivity extends BaseActivity implements OnClickListener {
 
    private EditText et_search_key;
 
    private TextView tv_clear;
 
    private TextView tv_search_cancel;
 
    private GridView gv_hot_search;
 
    private FlowLayout fl_history_search;
 
    private LinearLayout ll_search_history, ll_search_rank;
 
    private SearchSuggestFragment suggestFragment;
 
    private FrameLayout fl_suggest;
 
    private String value = "";
 
    private AQuery mAQuery;
 
 
    private void initView() {
        fl_advertisement = findViewById(R.id.fl_advertisement);
        et_search_key = findViewById(R.id.et_search_key);
        fl_advertisement.setOnClickListener(this);
        tv_search_cancel = findViewById(R.id.tv_search_cancel);
        gv_hot_search = findViewById(R.id.gv_hot_search);
        fl_history_search = findViewById(R.id.fl_history_search);
        tv_clear = findViewById(R.id.tv_search_clear_his);
        ll_search_history = findViewById(R.id.ll_search_history);
        fl_suggest = findViewById(R.id.fl_suggest);
        ll_search_rank = findViewById(R.id.ll_search_rank);
        mAQuery = new AQuery(this);
    }
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.search_actvity);
        TopStatusSettings.setStatusViewAndDeepColor(this);
        initView();
        suggestFragment = new SearchSuggestFragment();
 
        et_search_key.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
 
                    if (StringUtils.isEmpty(et_search_key.getEditableText()
                            + "") && StringUtils.isEmpty(et_search_key.getHint() + "")) {
                        Toast.makeText(SearchActivity.this, "请输入搜索内容!", Toast.LENGTH_LONG).show();
                        return false;
                    } else {
                        if (!StringUtils.isEmpty(et_search_key.getEditableText()
                                + "")) {
                            jumpToSearch(et_search_key.getEditableText()
                                    + "");
                        } else {
                            jumpToSearch(et_search_key.getHint() + "");
                        }
                    }
 
 
                    return true;
                }
                return false;
            }
        });
 
        tv_search_cancel.setOnClickListener(this);
        tv_clear.setOnClickListener(this);
 
        value = getIntent().getStringExtra("value");
        if (!StringUtils.isEmpty(value)) {
            et_search_key.setHint(value);
            // et_search_key.setSelection(value.length());
        }
 
        et_search_key.addTextChangedListener(new TextWatcher() {
 
            @Override
            public void onTextChanged(CharSequence s, int start, int before,
                                      int count) {
 
            }
 
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                                          int after) {
 
            }
 
            @Override
            public void afterTextChanged(Editable s) {
                if (s != null && !TextUtils.isEmpty(s.toString())) {
                    et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0,
                            R.drawable.ic_clear, 0);
                } else {
                    et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0,
                            0, 0);
                }
                suggestSearch(s != null ? s.toString() : null);
            }
        });
 
        if (!TextUtils.isEmpty(value)) {
            et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0,
                    R.drawable.ic_clear, 0);
        } else {
            et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0,
                    0, 0);
        }
 
        et_search_key.setOnTouchListener(new OnTouchListener() {
 
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // getCompoundDrawables() 可以获取一个长度为4的数组,
                // 存放drawableLeft,Right,Top,Bottom四个图片资源对象
                // index=2 表示的是 drawableRight 图片资源对象
 
                Drawable drawable = et_search_key.getCompoundDrawables()[2];
                if (drawable == null)
                    return false;
 
                if (event.getAction() != MotionEvent.ACTION_UP)
                    return false;
 
                // drawable.getIntrinsicWidth() 获取drawable资源图片呈现的宽度
                if (event.getX() > et_search_key.getWidth()
                        - et_search_key.getPaddingRight()
                        - drawable.getIntrinsicWidth()) {
                    et_search_key.setText("");
                }
                return false;
            }
        });
 
 
        gv_hot_search.setOnItemClickListener(new OnItemClickListener() {
 
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {
                jumpToSearch((String) parent.getItemAtPosition(position));
            }
        });
 
        et_search_key.setHint(getIntent().getStringExtra("key"));
        mAQuery.id(R.id.iv_short_video).clicked(new OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SearchActivity.this, MainActivity.class).putExtra("position", 0+"").putExtra("cposition", 1+""));
                finish();
            }
        });
 
        getHotSearch();
        getHistorySearch();
        initAdvertisement();// 广点通广告
        getSearchRank();
    }
 
    @Override
    public void onResume() {
        super.onResume();
        getHistorySearch();
    }
 
    @Override
    public void onPause() {
        super.onPause();
    }
 
    @Override
    public void onClick(final View v) {
        switch (v.getId()) {
            case R.id.tv_search_cancel:
                if (fl_suggest.getVisibility() == View.VISIBLE) {
                    hiddenSuggestFragment();
                } else
                    finish();
                break;
            case R.id.tv_search_clear_his:
                clearHistorySearch();
                break;
            case R.id.tv_top_bar_left:
                finish();
                break;
            default:
                break;
        }
    }
 
 
    private void hiddenSuggestFragment() {
        fl_suggest.setVisibility(View.GONE);
        getSupportFragmentManager().beginTransaction().remove(suggestFragment).commitAllowingStateLoss();
    }
 
    private void showSuggestFragment(String key, List<String> list) {
        Bundle bundle = new Bundle();
        bundle.putString("key", key);
        bundle.putString("list", new Gson().toJson(list));
        fl_suggest.setVisibility(View.VISIBLE);
//        if (suggestFragment.isAdded()) {
//            return;
//        }
        suggestFragment.setItemClickListener(new SearchSuggestFragment.OnItemClickListener() {
            @Override
            public void onClick(String st) {
                jumpToSearch(st);
                hiddenSuggestFragment();
            }
        });
 
        suggestFragment.setArguments(bundle);
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_suggest, suggestFragment).commitAllowingStateLoss();
    }
 
    private void suggestSearch(String key) {
        if (StringUtils.isEmpty(key)) {
            hiddenSuggestFragment();
        }
 
 
        SharedPreferences preferences = getSharedPreferences("user",
                Context.MODE_PRIVATE);
        String uid = preferences.getString("uid", "");
        BeibeiVideoAPI.suggestSearch(this, uid, key,
                new BasicTextHttpResponseHandler() {
 
                    @Override
                    public void onSuccessPerfect(int statusCode,
                                                 Header[] headers, JSONObject jsonObject)
                            throws Exception {
                        List<String> results = null;
                        if (jsonObject.getBoolean("IsPost")) {
                            Gson gson = new GsonBuilder().setFieldNamingPolicy(
                                    FieldNamingPolicy.UPPER_CAMEL_CASE)
                                    .create();
                            results = gson.fromJson(jsonObject
                                    .getJSONObject("Data").getJSONArray("data")
                                    .toString(), new TypeToken<List<String>>() {
                            }.getType());
 
 
//                            SuggestKeysAdapter adapter = new SuggestKeysAdapter(getApplicationContext(), results);
//                            et_search_key.setAdapter(adapter);
//                            adapter.notifyDataSetChanged();
                        }
 
                        if (results != null && results.size() > 0) {
                            showSuggestFragment(key, results);
                            suggestFragment.setData(key, results);
                        } else {
                            hiddenSuggestFragment();
                        }
 
                    }
                });
    }
 
    private void getHistorySearch() {
        SharedPreferences historySp = getSharedPreferences("search_history",
                Context.MODE_PRIVATE);
        String historyStr = historySp.getString("history", "");
        if (!StringUtils.isBlank(historyStr)) {
            String[] historyArray = historyStr.split(",");
            ll_search_history.setVisibility(View.VISIBLE);
            List<String> history = new ArrayList<>();
            for (int i = 0; i < 10 && i < historyArray.length; i++) {
                if (!TextUtils.isEmpty(historyArray[historyArray.length - 1 - i])) {
                    String st = historyArray[historyArray.length - 1 - i];
                    if (st != null && !history.contains(st.trim()))
                        history.add(st.trim());
                }
            }
 
            fl_history_search.removeAllViews();
            for (String st : history) {
                TextView textView = new TextView(getApplicationContext());
                textView.setEllipsize(TextUtils.TruncateAt.END);
                textView.setTextSize(13);
                textView.setPadding(DimenUtils.dip2px(getApplicationContext(), 20), DimenUtils.dip2px(getApplicationContext(), 5), DimenUtils.dip2px(getApplicationContext(), 20), DimenUtils.dip2px(getApplicationContext(), 5));
                textView.setText(st);
                textView.setTextColor(getResources().getColor(R.color.search_item_text_color));
                textView.setBackgroundResource(R.drawable.shape_search_history_item_bg);
                FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
                params.setMargins(0, DimenUtils.dip2px(getApplicationContext(), 15), DimenUtils.dip2px(getApplicationContext(), 13), 0);
                textView.setLayoutParams(params);
                textView.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        jumpToSearch(st);
                    }
                });
                fl_history_search.addView(textView);
            }
        } else {
            ll_search_history.setVisibility(View.GONE);
        }
    }
 
    private void clearHistorySearch() {
        SharedPreferences historySp = getSharedPreferences("search_history",
                Context.MODE_PRIVATE);
        Editor ed = historySp.edit();
        ed.putString("history", "");
        ed.commit();
        getHistorySearch();
    }
 
    private void getHotSearch() {
        SharedPreferences preferences = getSharedPreferences("user",
                Context.MODE_PRIVATE);
        String uid = preferences.getString("uid", "");
        BeibeiVideoAPI.getHotSearch(this, uid,
                new BasicTextHttpResponseHandler() {
                    @Override
                    public void onSuccessPerfect(int statusCode,
                                                 Header[] headers, JSONObject jsonObject)
                            throws Exception {
                        if (jsonObject.getBoolean("IsPost")) {
                            Gson gson = new GsonBuilder().setFieldNamingPolicy(
                                    FieldNamingPolicy.UPPER_CAMEL_CASE)
                                    .create();
                            List<String> hotSearchs = gson.fromJson(jsonObject
                                    .getJSONObject("Data").getJSONArray("data")
                                    .toString(), new TypeToken<List<String>>() {
                            }.getType());
                            if (hotSearchs == null || hotSearchs.size() == 0) {
                                gv_hot_search.setVisibility(View.GONE);
                            } else {
                                gv_hot_search.setVisibility(View.VISIBLE);
                            }
 
                            gv_hot_search.setAdapter(new HotSearchAdapter(
                                    hotSearchs, true));
                        } else {
                            gv_hot_search.setVisibility(View.GONE);
                        }
                    }
                });
    }
 
    private void getSearchRank() {
        BeibeiVideoAPI.getSearchRank(this,
                new BasicTextHttpResponseHandler() {
                    @Override
                    public void onSuccessPerfect(int statusCode,
                                                 Header[] headers, JSONObject jsonObject)
                            throws Exception {
                        if (jsonObject.getBoolean("IsPost")) {
                            JSONObject data = jsonObject
                                    .getJSONObject("Data").getJSONObject("data");
                            initSearchRank(data);
                        }
                    }
                });
    }
 
    /**
     * 广点通广告
     */
    private FrameLayout fl_advertisement;
 
    // 1.加载广告,先设置加载上下文环境和条件
    private void initAdvertisement() {
        //vivo无广告
//        if ("vivo".equalsIgnoreCase(ManifestDataUtil.getAppMetaData(getApplicationContext(), "UMENG_CHANNEL"))) {
//            return;
//        }
 
        AdUtil.AD_TYPE adType1 = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.videoSearch);
        if (adType1 == AdUtil.AD_TYPE.gdt) {
            adType1 = AdUtil.AD_TYPE.gdt2;
        }
        final AdUtil.AD_TYPE adType =adType1;
 
        fl_advertisement.post(new Runnable() {
            @Override
            public void run() {
                int width = fl_advertisement.getWidth() - fl_advertisement.getPaddingLeft() - fl_advertisement.getPaddingRight();
                ExpressAdManager adManager =  new ExpressAdManager(adType,ExpressAdManager.POSITION_SEARCH, getApplicationContext());
                adManager.loadSearchAd(DimenUtils.px2dip(getApplicationContext(), width), new ExpressAdManager.IAdLoadListener() {
                    @Override
                    public void onSuccess(List<ExpressAdContainer> adList) {
                        if (adList != null && adList.size() > 0) {
                            adManager.renderAndFillAd(SearchActivity.this, adList.get(0), fl_advertisement, ExpressAdManager.POSITION_SEARCH, new ExpressAdManager.IAdEventListener() {
                                @Override
                                public void closeAd(ExpressAdContainer ad) {
                                    fl_advertisement.removeAllViews();
                                }
                            });
                        } else if (adType != null) {
                            AdUtil.AD_TYPE newAdType = null;
                            if (adType == AdUtil.AD_TYPE.gdt2) {
                                newAdType = AdUtil.AD_TYPE.csj;
                            } else
                                newAdType = AdUtil.AD_TYPE.gdt2;
 
//                            if (AndroidManifestUtil.isHuaWeiChannel(getApplicationContext()))
//                                newAdType = AdUtil.AD_TYPE.hw;
 
                            new ExpressAdManager(newAdType,ExpressAdManager.POSITION_SEARCH, getApplicationContext()).loadSearchAd(DimenUtils.px2dip(getApplicationContext(), width), new ExpressAdManager.IAdLoadListener() {
                                @Override
                                public void onSuccess(List<ExpressAdContainer> adList) {
                                    if (adList != null && adList.size() > 0) {
                                        ExpressAdManager.renderAndFillAd(SearchActivity.this, adList.get(0), fl_advertisement,ExpressAdManager.POSITION_SEARCH, new ExpressAdManager.IAdEventListener() {
                                            @Override
                                            public void closeAd(ExpressAdContainer ad) {
                                                fl_advertisement.removeAllViews();
                                            }
                                        });
                                    }
 
                                }
                            });
                        }
 
                    }
                });
            }
        });
    }
 
    private void initSearchRank(JSONObject data) {
        ll_search_rank.removeAllViews();
        Type type = new TypeToken<List<String>>() {
        }.getType();
        Gson gson = new Gson();
        int count = 0;
        for (Iterator<String> its = data.keys(); its.hasNext(); ) {
            String key = its.next();
            JSONArray array = data.optJSONArray(key);
            List<String> list = gson.fromJson(array.toString(), type);
            String[] sts = new String[list.size()];
            int row = list.size() / 2;
            for (int i = 0; i < list.size(); i++) {
                if (i < row) {
                    sts[i * 2] = list.get(i);
                } else {
                    sts[(i % row) * 2 + 1] = list.get(i);
                }
 
            }
            count++;
            addSearchRankView(key, Arrays.asList(sts), ll_search_rank, count == data.length());
        }
    }
 
    private void addSearchRankView(String title, List<String> contentList, LinearLayout container, boolean last) {
        View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.item_search_rank, null);
        MyGridView gv = view.findViewById(R.id.gv_content);
        TextView tv_title = view.findViewById(R.id.tv_title);
        tv_title.setText(title);
        gv.setAdapter(new SearchRankAdapter(contentList, getApplicationContext()));
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DimenUtils.dip2px(getApplicationContext(), 284), LinearLayout.LayoutParams.WRAP_CONTENT);
        params.rightMargin = DimenUtils.dip2px(getApplicationContext(), !last ? 11 : 0);
        container.addView(view, params);
    }
 
    private void jumpToSearch(String key) {
        Intent intent = new Intent(SearchActivity.this,
                SearchResultActivity.class);
        intent.putExtra("key", key);
        if (getIntent() != null) {
            intent.putExtra("goldcorn", getIntent().getStringExtra("goldcorn"));
            getIntent().removeExtra("goldcorn");
        }
        startActivity(intent);
    }
 
 
    class SearchRankAdapter extends BaseAdapter {
 
        private List<String> mList;
        private LayoutInflater layoutInflater;
 
        public SearchRankAdapter(List<String> list, Context context) {
            this.mList = list;
            layoutInflater = LayoutInflater.from(context);
        }
 
        //最多8个
        @Override
        public int getCount() {
            return mList == null ? 0 : (mList.size()>8?8:mList.size());
        }
 
        @Override
        public Object getItem(int position) {
            return mList.get(position);
        }
 
        @Override
        public long getItemId(int position) {
            return position;
        }
 
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder viewHolder;
            if (convertView == null) {
                viewHolder = new ViewHolder();
                convertView = LayoutInflater.from(parent.getContext()).inflate(
                        R.layout.item_search_rank_content, parent, false);
                viewHolder.tv_rank = convertView
                        .findViewById(R.id.tv_rank);
                viewHolder.tv_content = convertView
                        .findViewById(R.id.tv_content);
                convertView.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) convertView.getTag();
            }
            if (position % 2 == 0) {
                viewHolder.tv_rank.setText((position / 2 + 1) + "");
            } else {
                viewHolder.tv_rank.setText((getCount() / 2 + (position + 1) / 2) + "");
            }
            viewHolder.tv_content.setText(mList.get(position));
 
            String color = "#C2C2C2";
            switch (viewHolder.tv_rank.getText() + "") {
                case "1":
                    color = "#FE3E3C";
                    break;
                case "2":
                    color = "#FE853C";
                    break;
                case "3":
                    color = "#FEC03C";
                    break;
                default:
                    color = "#C2C2C2";
            }
            GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT,
                    new int[]{Color.parseColor(color), Color.parseColor(color)});
            gd.setCornerRadius(DimenUtils.dip2px(convertView.getContext(), 4));
            viewHolder.tv_rank.setBackground(gd);
            convertView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    jumpToSearch(mList.get(position));
                }
            });
            return convertView;
        }
 
        class ViewHolder {
            TextView tv_rank;
            TextView tv_content;
        }
    }
 
    @Override
    protected void onDestroy() {
        super.onDestroy();
 
    }
}