Android Open Source - Bussan Find Bus Stop By Name Activity






From Project

Back to project page Bussan.

License

The source code is released under:

Copyright 2011 Kristian Bendiksen. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project Bussan listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package no.kriben.bussan;
// w w  w  . j av  a 2s. c  o  m
import java.util.List;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import no.kriben.busstopstrondheim.model.BusStop;

public class FindBusStopByNameActivity extends BusStopListActivity {

    private EditText filterText_ = null;

    private BusStopAdapter adapter_ = null;

    private TextWatcher filterTextWatcher = new TextWatcher() {
        public void afterTextChanged(Editable s) {}

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            synchronized(adapter_) {
                if (adapter_ != null) {
                    adapter_.getFilter().filter(s);
                    adapter_.notifyDataSetChanged();
                }
            }
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.bus_stop_by_name_list);
        super.onCreate(savedInstanceState);

        adapter_ = new BusStopAdapter(getBaseContext(), R.layout.bus_stop_list_item, R.id.busstop_name);
        setListAdapter(adapter_);

        filterText_ = (EditText) findViewById(R.id.search_box);
        filterText_.addTextChangedListener(filterTextWatcher);

        startDownloadBusStopTask();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        filterText_.removeTextChangedListener(filterTextWatcher);
    }


    @Override
    protected void refreshBusStopListView() {}

    @Override
    protected void refreshBusStopListView(List<BusStop> busStops) {
        synchronized(adapter_) {
            if (busStops != null) {
                adapter_.setNotifyOnChange(false);
                adapter_.clear();
                for (BusStop b : busStops) {
                    adapter_.add(b);
                }
                adapter_.notifyDataSetChanged();
            }
        }
    }
}




Java Source Code List

no.kriben.bussan.AndroidFileStringCache.java
no.kriben.bussan.BusDepartureDetailActivity.java
no.kriben.bussan.BusStopAdapter.java
no.kriben.bussan.BusStopArrayAdapter.java
no.kriben.bussan.BusStopListActivity.java
no.kriben.bussan.BusStopMenuHandler.java
no.kriben.bussan.BusStopNameFormatter.java
no.kriben.bussan.BusStopWithDistance.java
no.kriben.bussan.BussanApplication.java
no.kriben.bussan.BussanAsyncTask.java
no.kriben.bussan.ConnectivityChecker.java
no.kriben.bussan.FindBusStopByDistanceActivity.java
no.kriben.bussan.FindBusStopByNameActivity.java
no.kriben.bussan.FrontpageActivity.java
no.kriben.bussan.PreferencesUtil.java
no.kriben.bussan.RealTimeActivity.java