package cgeo.geocaching;

import cgeo.geocaching.activity.AbstractListActivity;
import cgeo.geocaching.ui.AddressListAdapter;

import org.apache.commons.collections.CollectionUtils;

import android.app.ProgressDialog;
import android.location.Address;
import android.location.Geocoder;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

import java.util.List;
import java.util.Locale;

public class AdressListActivity extends AbstractListActivity {
    private String keyword = null;
    private ProgressDialog waitDialog = null;
    private AddressListAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setTheme();
        setContentView(R.layout.addresses);
        setTitle(res.getString(R.string.search_address_result));

        // get parameters
        Bundle extras = getIntent().getExtras();

        // try to get data from extras
        if (extras != null) {
            keyword = extras.getString("keyword");
        }

        if (keyword == null) {
            showToast(res.getString(R.string.err_search_address_forgot));
            finish();
            return;
        }

        adapter = new AddressListAdapter(this);
        setListAdapter(adapter);

        waitDialog = ProgressDialog.show(this, res.getString(R.string.search_address_started), keyword, true);
        waitDialog.setCancelable(true);

        new AsyncTask<Void, Void, List<Address>>() {

            @Override
            protected List<Address> doInBackground(Void... params) {
                final Geocoder geocoder = new Geocoder(AdressListActivity.this, Locale.getDefault());
                try {
                    return geocoder.getFromLocationName(keyword, 20);
                } catch (Exception e) {
                    Log.e(Settings.tag, "AdressListActivity.doInBackground", e);
                    return null;
                }
            }

            @Override
            protected void onPostExecute(final List<Address> addresses) {
                waitDialog.dismiss();
                try {
                    if (CollectionUtils.isEmpty(addresses)) {
                        showToast(res.getString(R.string.err_search_address_no_match));
                        finish();
                        return;
                    } else {
                        for (Address address : addresses) {
                            adapter.add(address); // don't use addAll, it's only available with API >= 11
                        }
                    }
                } catch (Exception e) {
                    Log.e(Settings.tag, "AdressListActivity.onPostExecute", e);
                }
            }

        }.execute();
    }
}
@@ -474,129 +474,8 @@
 ty %7B
-%0A    private String keyword = null;%0A    private ProgressDialog waitDialog = null;%0A    private AddressListAdapter adapter;
 %0A%0A  
@@ -753,157 +753,57 @@
     
-Bundle extras = getIntent().getExtras();%0A%0A        // try to get data from extras%0A        if (extras != null) %7B%0A            keyword = extras.getString
+final String keyword = getIntent().getStringExtra
 (%22ke
@@ -810,26 +810,16 @@
 yword%22);
-%0A        %7D
 %0A%0A      
@@ -974,24 +974,49 @@
  %7D%0A%0A        
+final AddressListAdapter 
 adapter = ne
@@ -1089,20 +1089,57 @@
     
-waitDialog =
+final ProgressDialog waitDialog =%0A               
  Pro

use local variables instead of fields when appropriate