浏览代码

bug修改

huyuguo 4 年之前
父节点
当前提交
da0cd49130

+ 17 - 10
app/src/main/java/com/electric/chargingpile/activity/MainMapActivity.java

@ -1606,6 +1606,15 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
1606 1606
    protected void onResume() {
1607 1607
        super.onResume();
1608 1608
1609
        String search_address = ProfileManager.getInstance().getSearchAddress(this);
1610
        if (search_address.equals("")) {
1611
            tv_search.setText("请输入地址/关键字");
1612
            iv_clear_address.setVisibility(View.INVISIBLE);
1613
        } else {
1614
            tv_search.setText(search_address);
1615
            iv_clear_address.setVisibility(View.VISIBLE);
1616
        }
1617
1609 1618
        String from = getIntent().getStringExtra("from");
1610 1619
        if ("search_from_activity".equals(from)) {
1611 1620
            searchAll();
@ -1644,16 +1653,6 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
1644 1653
        }
1645 1654
        mapView.onResume();
1646 1655
1647
1648
        String search_address = ProfileManager.getInstance().getSearchAddress(this);
1649
        if (search_address.equals("")) {
1650
            tv_search.setText("请输入地址/关键字");
1651
            iv_clear_address.setVisibility(View.INVISIBLE);
1652
        } else {
1653
            tv_search.setText(search_address);
1654
            iv_clear_address.setVisibility(View.VISIBLE);
1655
        }
1656
1657 1656
        if (againPoint.equals("1") && back.equals("1")) {
1658 1657
            if (!isFirstLoc) {
1659 1658
                isFirstLoc = true;
@ -1674,6 +1673,14 @@ public class MainMapActivity extends Activity implements LocationSource, AMapLoc
1674 1673
    }
1675 1674
1676 1675
    private void searchAll() {
1676
1677
        if ("请输入地址/关键字".equals(tv_search.getText().toString())) {
1678
            if (search_marker != null) {
1679
                search_marker.remove();
1680
            }
1681
            return;
1682
        }
1683
1677 1684
        double jing = Double.valueOf(getIntent().getStringExtra("jing"));
1678 1685
        double wei = Double.valueOf(getIntent().getStringExtra("wei"));
1679 1686
        MainApplication.search_jing = jing;

+ 3 - 1
app/src/main/java/com/electric/chargingpile/activity/SearchActivity.java

@ -306,6 +306,7 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
306 306
                db.del(addressList.get(position).get("name"), addressList.get(position).get("address"));
307 307
                db.insert(values);
308 308

309

309 310
                Cursor c = db.query();
310 311
                if (c.getCount() <= 0) {
311 312
                    return;
@ -313,6 +314,8 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
313 314
                String[] from = {"keyword", "type"};
314 315
                int[] to = {R.id.search_name, R.id.search_address};
315 316
                SimpleCursorAdapter historyAdapter = new SimpleCursorAdapter(SearchActivity.this, R.layout.history_item, c, from, to, 0);
317

318
                db.close();
316 319
                historyList.setAdapter(historyAdapter);
317 320
                Intent intent = new Intent();
318 321
                intent.putExtra("from", "search_from_activity");
@ -325,7 +328,6 @@ public class SearchActivity extends Activity implements OnClickListener, Inputti
325 328
                if (v != null) {
326 329
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
327 330
                }
328
                db.close();
329 331
                finish();
330 332
            }
331 333
        });

+ 13 - 0
app/src/main/java/com/electric/chargingpile/activity/SearchAllActivity.java

@ -2,6 +2,7 @@ package com.electric.chargingpile.activity;
2 2
3 3
import androidx.appcompat.app.AppCompatActivity;
4 4
5
import android.content.ContentValues;
5 6
import android.content.Context;
6 7
import android.content.Intent;
7 8
import android.content.pm.PackageInfo;
@ -29,6 +30,7 @@ import com.electric.chargingpile.application.MainApplication;
29 30
import com.electric.chargingpile.data.PileData;
30 31
import com.electric.chargingpile.data.RecommendZhan;
31 32
import com.electric.chargingpile.manager.ProfileManager;
33
import com.electric.chargingpile.util.DBOpenHandler;
32 34
import com.electric.chargingpile.util.JsonUtils;
33 35
34 36
import java.net.URISyntaxException;
@ -82,6 +84,17 @@ public class SearchAllActivity extends AppCompatActivity {
82 84
        lv_search_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
83 85
            @Override
84 86
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
87
                DBOpenHandler db = new DBOpenHandler(SearchAllActivity.this, "");
88
                ContentValues values = new ContentValues();
89
                values.put("time", System.currentTimeMillis());
90
                values.put("keyword", addressAllList.get(position).get("name"));
91
                values.put("type", addressAllList.get(position).get("address"));
92
                values.put("jing", addressAllList.get(position).get("jing"));
93
                values.put("wei", addressAllList.get(position).get("wei"));
94
                db.del(addressAllList.get(position).get("name"), addressAllList.get(position).get("address"));
95
                db.insert(values);
96
97
85 98
                Intent intent = new Intent();
86 99
                intent.setClass(getApplicationContext(), MainMapActivity.class);
87 100
                intent.putExtra("from", "search_from_activity");