auto import from //depot/cupcake/@137055
This commit is contained in:
1 parent
233a0136ea
commit
b28e1b7d95
35 files changed
+657
-141
No files matched your search
@@ -57,8 +57,6 @@ import android.widget.TextView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Search extends LinearLayout implements OnClickListener, OnKeyListener,
|
||||
OnLongClickListener, TextWatcher, OnItemClickListener, OnItemSelectedListener {
|
||||
|
||||
@@ -81,6 +79,7 @@ public class Search extends LinearLayout implements OnClickListener, OnKeyListen
|
||||
private Intent mVoiceSearchIntent;
|
||||
|
||||
private Rect mTempRect = new Rect();
|
||||
private boolean mRestoreFocus = false;
|
||||
|
||||
/**
|
||||
* Used to inflate the Workspace from XML.
|
||||
@@ -170,7 +169,26 @@ public class Search extends LinearLayout implements OnClickListener, OnKeyListen
|
||||
|
||||
getContext().startActivity(launcher);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasWindowFocus) {
|
||||
if (!hasWindowFocus && hasFocus()) {
|
||||
mRestoreFocus = true;
|
||||
}
|
||||
|
||||
super.onWindowFocusChanged(hasWindowFocus);
|
||||
|
||||
if (hasWindowFocus && mRestoreFocus) {
|
||||
if (isInTouchMode()) {
|
||||
final AutoCompleteTextView searchText = mSearchText;
|
||||
searchText.setSelectAllOnFocus(false);
|
||||
searchText.requestFocusFromTouch();
|
||||
searchText.setSelectAllOnFocus(true);
|
||||
}
|
||||
mRestoreFocus = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements TextWatcher (for EditText)
|
||||
*/
|
||||
@@ -370,6 +388,18 @@ public class Search extends LinearLayout implements OnClickListener, OnKeyListen
|
||||
mSearchText.setAdapter(mSuggestionsAdapter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove internal cursor references when detaching from window which
|
||||
* prevents {@link Context} leaks.
|
||||
*/
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
if (mSuggestionsAdapter != null) {
|
||||
mSuggestionsAdapter.changeCursor(null);
|
||||
mSuggestionsAdapter = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements OnItemClickListener
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user