Browse Source

代码优化

huyuguo 4 years ago
parent
commit
03b7504730

+ 7 - 30
app/src/main/java/com/electric/chargingpile/activity/RoutePlanSelectAddressActivity.java

503
                        list.clear();
503
                        list.clear();
504
                        adapter.notifyDataSetChanged();
504
                        adapter.notifyDataSetChanged();
505
                    }
505
                    }
506
507
//                    if (poiItems != null && poiItems.size() > 0) {
508
////                        aMap.clear();// 清理之前的图标
509
//                        PoiOverlay poiOverlay = new PoiOverlay(aMap, poiItems);
510
//                        poiOverlay.removeFromMap();
511
//                        poiOverlay.addToMap();
512
//                        poiOverlay.zoomToSpan();
513
//                    } else if (suggestionCities != null
514
//                            && suggestionCities.size() > 0) {
515
//                        showSuggestCity(suggestionCities);
516
//                    } else {
517
////                        ToastUtil.show(PoiKeywordSearchActivity.this,
518
////                                R.string.no_result);
519
//                    }
520
                }
506
                }
521
            } else {
507
            } else {
522
//                ToastUtil.show(PoiKeywordSearchActivity.this,
523
//                        R.string.no_result);
508
//                ToastUtil.show(PoiKeywordSearchActivity.this, R.string.no_result);
524
            }
509
            }
525
        } else {
510
        } else {
526
//            ToastUtil.showerror(this, rCode);
511
//            ToastUtil.showerror(this, rCode);
560
        public View getView(int position, View convertView, ViewGroup parent) {
545
        public View getView(int position, View convertView, ViewGroup parent) {
561
            ViewHolder viewHolder = null;
546
            ViewHolder viewHolder = null;
562
            if (convertView == null) {
547
            if (convertView == null) {
563
                convertView = LayoutInflater.from(context).inflate(
564
                        R.layout.item_search, null);
548
                convertView = LayoutInflater.from(context).inflate(R.layout.item_route_search, null);
565
                viewHolder = new ViewHolder();
549
                viewHolder = new ViewHolder();
566
                viewHolder.name = (TextView) convertView
567
                        .findViewById(R.id.search_name);
568
                viewHolder.address = (TextView) convertView
569
                        .findViewById(R.id.search_address);
570
                viewHolder.zhan = (ImageView) convertView
571
                        .findViewById(R.id.search_zhan);
550
                viewHolder.name = (TextView) convertView.findViewById(R.id.search_name);
551
                viewHolder.address = (TextView) convertView.findViewById(R.id.search_address);
552
                viewHolder.zhan = (ImageView) convertView.findViewById(R.id.search_zhan);
572
                convertView.setTag(viewHolder);
553
                convertView.setTag(viewHolder);
573
            } else {
554
            } else {
574
                viewHolder = (ViewHolder) convertView.getTag();
555
                viewHolder = (ViewHolder) convertView.getTag();
581
            } else {
562
            } else {
582
                viewHolder.zhan.setVisibility(View.VISIBLE);
563
                viewHolder.zhan.setVisibility(View.VISIBLE);
583
                if (!TextUtils.isEmpty(list.get(position).get("url"))) {
564
                if (!TextUtils.isEmpty(list.get(position).get("url"))) {
584
                    ImageLoader.getInstance().init(
585
                            ImageLoaderConfiguration
586
                                    .createDefault(RoutePlanSelectAddressActivity.this));
565
                    ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(RoutePlanSelectAddressActivity.this));
587
                    DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
566
                    DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
588
                    builder.cacheInMemory(true);
567
                    builder.cacheInMemory(true);
589
                    builder.cacheOnDisc(true);
568
                    builder.cacheOnDisc(true);
591
                    builder.showImageForEmptyUri(R.drawable.image_default);
570
                    builder.showImageForEmptyUri(R.drawable.image_default);
592
                    builder.showImageOnFail(R.drawable.image_default);
571
                    builder.showImageOnFail(R.drawable.image_default);
593
                    builder.displayer(new RoundedBitmapDisplayer(0));
572
                    builder.displayer(new RoundedBitmapDisplayer(0));
594
                    ImageLoader.getInstance().displayImage(
595
                            list.get(position).get("url"), viewHolder.zhan,
596
                            builder.build());
573
                    ImageLoader.getInstance().displayImage(list.get(position).get("url"), viewHolder.zhan, builder.build());
597
                } else {
574
                } else {
598
                    viewHolder.zhan.setImageResource(R.drawable.image_default);
575
                    viewHolder.zhan.setImageResource(R.drawable.image_default);
599
                }
576
                }

+ 67 - 0
app/src/main/res/layout/item_route_search.xml

1
<?xml version="1.0" encoding="utf-8"?>
2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="match_parent"
4
    android:layout_height="wrap_content"
5
    android:background="@color/white"
6
    android:orientation="vertical" >
7

8
    <RelativeLayout
9
        android:id="@+id/search_real"
10
        android:layout_width="wrap_content"
11
        android:layout_height="wrap_content" >
12

13
        <ImageView
14
            android:id="@+id/search_image"
15
            android:layout_width="wrap_content"
16
            android:layout_height="wrap_content"
17
            android:layout_centerVertical="true"
18
            android:contentDescription="@null"
19
            android:paddingRight="14dp"
20
            android:paddingTop="20dp"
21
            android:paddingBottom="20dp"
22
            android:layout_marginLeft="16dp"
23
            android:src="@drawable/icon_search1117" />
24

25
        <ImageView
26
            android:id="@+id/search_zhan"
27
            android:layout_width="60dp"
28
            android:layout_height="60dp"
29
            android:layout_centerVertical="true"
30
            android:layout_margin="10dp"
31
            android:contentDescription="@null"
32
            android:src="@drawable/image_default"
33
            android:visibility="gone" />
34
    </RelativeLayout>
35

36
    <LinearLayout
37
        android:layout_width="fill_parent"
38
        android:layout_height="wrap_content"
39
        android:layout_centerVertical="true"
40
        android:layout_toRightOf="@id/search_real"
41
        android:gravity="center_vertical"
42
        android:orientation="vertical"
43
        android:paddingBottom="10dp"
44
        android:paddingRight="10dp"
45
        android:paddingTop="10dp" >
46

47
        <TextView
48
            android:id="@+id/search_name"
49
            android:layout_width="fill_parent"
50
            android:layout_height="wrap_content"
51
            android:ellipsize="end"
52
            android:singleLine="true"
53
            android:textColor="@color/title_row"
54
            android:textSize="15sp" />
55

56
        <TextView
57
            android:id="@+id/search_address"
58
            android:layout_width="fill_parent"
59
            android:layout_height="wrap_content"
60
            android:layout_marginTop="2dp"
61
            android:ellipsize="end"
62
            android:maxLines="2"
63
            android:textColor="@color/hintColor"
64
            android:textSize="12sp" />
65
    </LinearLayout>
66

67
</RelativeLayout>