use of android.widget.AutoCompleteTextView in project Lightning-Browser by anthonycr.
the class BrowserActivity method initializeSearchSuggestions.
/**
* method to generate search suggestions for the AutoCompleteTextView from
* previously searched URLs
*/
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) {
mSuggestionsAdapter = new SuggestionsAdapter(this, mDarkTheme, isIncognito());
getUrl.setThreshold(1);
getUrl.setDropDownWidth(-1);
getUrl.setDropDownAnchor(R.id.toolbar_layout);
getUrl.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
String url = null;
CharSequence urlString = ((TextView) view.findViewById(R.id.url)).getText();
if (urlString != null) {
url = urlString.toString();
}
if (url == null || url.startsWith(getString(R.string.suggestion))) {
CharSequence searchString = ((TextView) view.findViewById(R.id.title)).getText();
if (searchString != null) {
url = searchString.toString();
}
}
if (url == null) {
return;
}
getUrl.setText(url);
searchTheWeb(url);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
mPresenter.onAutoCompleteItemPressed();
}
});
getUrl.setSelectAllOnFocus(true);
getUrl.setAdapter(mSuggestionsAdapter);
}
use of android.widget.AutoCompleteTextView in project AndroidUIAdapter by cheng2016.
the class LoginActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// Set up the login form.
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
populateAutoComplete();
mPasswordView = (EditText) findViewById(R.id.password);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
attemptLogin();
}
});
mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress);
}
use of android.widget.AutoCompleteTextView in project LiveLessons by douglascraigschmidt.
the class Options method getUrlLists.
/**
* Gets the list of lists of URLs from which we want to download
* images.
*/
public List<List<URL>> getUrlLists(Context context, LinearLayout listUrlGroups, InputSource source) {
List<List<URL>> variableNumberOfInputURLs = new ArrayList<>();
try {
switch(source) {
// default list of remote URL lists.
case DEFAULT:
variableNumberOfInputURLs = getDefaultUrlList(context, false);
break;
// default list of local URL lists.
case DEFAULT_LOCAL:
variableNumberOfInputURLs = getDefaultUrlList(context, true);
break;
// Take input from the Android UI.
case USER:
// Iterate over the children of the LinearLayout that
// holds the list of URL lists.
int numChildViews = listUrlGroups.getChildCount();
for (int i = 0; i < numChildViews; ++i) {
AutoCompleteTextView child = (AutoCompleteTextView) listUrlGroups.getChildAt(i);
// Convert the input string into a list of URLs
// and add it to the main list.
variableNumberOfInputURLs.add(convertStringToUrls(child.getText().toString()));
}
break;
default:
UiUtils.showToast(context, "Invalid Source");
return null;
}
} catch (MalformedURLException e) {
UiUtils.showToast(context, "Invalid URL");
return null;
}
return variableNumberOfInputURLs;
}
use of android.widget.AutoCompleteTextView in project LiveLessons by douglascraigschmidt.
the class MainActivity method addURLs.
/**
* Adds a List of URLs to the ListView to allow for variable
* number of URL Lists to process (i.e., variable number of
* iteration cycles by the ImageStreamGang).
*/
@SuppressLint("InflateParams")
public int addURLs(View view) {
// Create the new list from R.layout.list_item.
AutoCompleteTextView newList = (AutoCompleteTextView) LayoutInflater.from(this).inflate(R.layout.list_item, null);
// Generate id for view so that it can be referenced later
newList.setId(View.generateViewId());
// Set the adapter to the given suggestions.
newList.setAdapter(mSuggestions);
// Add the view and invalidate it so that the layout is
// redrawn by the framework.
mListUrlGroups.addView(newList);
mListUrlGroups.invalidate();
// Return the id
return newList.getId();
}
use of android.widget.AutoCompleteTextView in project LiveLessons by douglascraigschmidt.
the class PlatformStrategyAndroid method getUrlIterator.
/**
* Gets an iterator over a list of lists of URLs from which
* we want to download images.
*/
public Iterator<List<URL>> getUrlIterator(InputSource source) {
List<List<URL>> variableNumberOfInputURLs = new ArrayList<List<URL>>();
try {
switch(source) {
// and Android platforms
case DEFAULT:
variableNumberOfInputURLs = super.getDefaultUrlList();
break;
// Take input from the Android UI
case USER:
// Check if the Activity still exists
if (mOuterClass.get() != null) {
// Iterate over the children of the LinearLayout
// that holds the list of URL lists
int numChildViews = mOuterClass.get().mListUrlGroups.getChildCount();
for (int i = 0; i < numChildViews; ++i) {
AutoCompleteTextView child = (AutoCompleteTextView) mOuterClass.get().mListUrlGroups.getChildAt(i);
// Create a new URL list and add each URL
// separated by commas to the list
List<URL> urls = new ArrayList<URL>();
StringTokenizer tokenizer = new StringTokenizer(child.getText().toString(), ", ");
while (tokenizer.hasMoreTokens()) {
urls.add(new URL(tokenizer.nextToken().trim()));
}
// Add the list of URLs to the main list
variableNumberOfInputURLs.add(urls);
}
}
break;
default:
if (mOuterClass.get() != null)
mOuterClass.get().showToast("Invalid Source");
return null;
}
} catch (MalformedURLException e) {
if (mOuterClass.get() != null)
mOuterClass.get().showToast("Invalid URL");
return null;
}
// Return an iterator over the list of URL lists
return variableNumberOfInputURLs.iterator();
}
Aggregations