FileDocCategorySizeDatePackage
TimeZonePickerView.javaAPI DocAndroid 5.1 API6959Thu Mar 12 22:22:54 GMT 2015com.android.timezonepicker

TimeZonePickerView

public class TimeZonePickerView extends android.widget.LinearLayout implements android.widget.AdapterView.OnItemClickListener, android.text.TextWatcher, android.view.View.OnClickListener

Fields Summary
private static final String
TAG
private android.content.Context
mContext
private android.widget.AutoCompleteTextView
mAutoCompleteTextView
private TimeZoneFilterTypeAdapter
mFilterAdapter
private boolean
mHideFilterSearchOnStart
private boolean
mFirstTime
TimeZoneResultAdapter
mResultAdapter
private android.widget.ImageButton
mClearButton
Constructors Summary
public TimeZonePickerView(android.content.Context context, android.util.AttributeSet attrs, String timeZone, long timeMillis, OnTimeZoneSetListener l, boolean hideFilterSearch)


       
          
    

        
                 
              
        super(context, attrs);
        mContext = context;
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.timezonepickerview, this, true);

        mHideFilterSearchOnStart = hideFilterSearch;

        TimeZoneData tzd = new TimeZoneData(mContext, timeZone, timeMillis);

        mResultAdapter = new TimeZoneResultAdapter(mContext, tzd, l);
        ListView timeZoneList = (ListView) findViewById(R.id.timezonelist);
        timeZoneList.setAdapter(mResultAdapter);
        timeZoneList.setOnItemClickListener(mResultAdapter);

        mFilterAdapter = new TimeZoneFilterTypeAdapter(mContext, tzd, mResultAdapter);

        mAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.searchBox);
        mAutoCompleteTextView.addTextChangedListener(this);
        mAutoCompleteTextView.setOnItemClickListener(this);
        mAutoCompleteTextView.setOnClickListener(this);

        updateHint(R.string.hint_time_zone_search, R.drawable.ic_search_holo_light);
        mClearButton = (ImageButton) findViewById(R.id.clear_search);
        mClearButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mAutoCompleteTextView.getEditableText().clear();
            }
        });
    
Methods Summary
public voidafterTextChanged(android.text.Editable s)

        if (mClearButton != null) {
            mClearButton.setVisibility(s.length() > 0 ? View.VISIBLE : View.GONE);
        }
    
public voidbeforeTextChanged(java.lang.CharSequence s, int start, int count, int after)

    
private voidfilterOnString(java.lang.String string)

        if (mAutoCompleteTextView.getAdapter() == null) {
            mAutoCompleteTextView.setAdapter(mFilterAdapter);
        }
        mHideFilterSearchOnStart = false;
        mFilterAdapter.getFilter().filter(string);
    
public booleangetHideFilterSearchOnStart()

        return mHideFilterSearchOnStart;
    
public java.lang.StringgetLastFilterString()

        return mResultAdapter != null ? mResultAdapter.getLastFilterString() : null;
    
public intgetLastFilterTime()

        return mResultAdapter != null ? mResultAdapter.getLastFilterType() : -1;
    
public intgetLastFilterType()

        return mResultAdapter != null ? mResultAdapter.getLastFilterType() : -1;
    
public booleanhasResults()

        return mResultAdapter != null && mResultAdapter.hasResults();
    
public voidonClick(android.view.View v)

        if (mAutoCompleteTextView != null && !mAutoCompleteTextView.isPopupShowing()) {
            filterOnString(mAutoCompleteTextView.getText().toString());
        }
    
public voidonItemClick(android.widget.AdapterView parent, android.view.View view, int position, long id)

        // Hide the keyboard since the user explicitly selected an item.
        InputMethodManager manager =
                (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.hideSoftInputFromWindow(mAutoCompleteTextView.getWindowToken(), 0);
        // An onClickListener for the view item because I haven't figured out a
        // way to update the AutoCompleteTextView without causing an infinite loop.
        mHideFilterSearchOnStart = true;
        mFilterAdapter.onClick(view);
    
public voidonTextChanged(java.lang.CharSequence s, int start, int before, int count)

        if (mFirstTime && mHideFilterSearchOnStart) {
            mFirstTime = false;
            return;
        }
        filterOnString(s.toString());
    
public voidshowFilterResults(int type, java.lang.String string, int time)

        if (mResultAdapter != null) {
            mResultAdapter.onSetFilter(type, string, time);
        }
    
private voidupdateHint(int hintTextId, int imageDrawableId)

        String hintText = getResources().getString(hintTextId);
        Drawable searchIcon = getResources().getDrawable(imageDrawableId);

        SpannableStringBuilder ssb = new SpannableStringBuilder("   "); // for the icon
        ssb.append(hintText);
        int textSize = (int) (mAutoCompleteTextView.getTextSize() * 1.25);
        searchIcon.setBounds(0, 0, textSize, textSize);
        ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        mAutoCompleteTextView.setHint(ssb);