Search in sources :

Example 66 with AutoCompleteTextView

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);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) InputMethodManager(android.view.inputmethod.InputMethodManager) SuggestionsAdapter(acr.browser.lightning.search.SuggestionsAdapter) ImageView(android.widget.ImageView) BookmarksView(acr.browser.lightning.browser.BookmarksView) BrowserView(acr.browser.lightning.browser.BrowserView) SearchView(acr.browser.lightning.view.SearchView) AutoCompleteTextView(android.widget.AutoCompleteTextView) LightningView(acr.browser.lightning.view.LightningView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) VideoView(android.widget.VideoView) TabsView(acr.browser.lightning.browser.TabsView)

Example 67 with AutoCompleteTextView

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);
}
Also used : KeyEvent(android.view.KeyEvent) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView)

Example 68 with AutoCompleteTextView

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 69 with AutoCompleteTextView

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();
}
Also used : AutoCompleteTextView(android.widget.AutoCompleteTextView) SuppressLint(android.annotation.SuppressLint)

Example 70 with AutoCompleteTextView

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();
}
Also used : StringTokenizer(java.util.StringTokenizer) MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) URL(java.net.URL) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Aggregations

AutoCompleteTextView (android.widget.AutoCompleteTextView)106 View (android.view.View)62 TextView (android.widget.TextView)44 ArrayAdapter (android.widget.ArrayAdapter)38 Button (android.widget.Button)27 EditText (android.widget.EditText)21 OnClickListener (android.view.View.OnClickListener)20 KeyEvent (android.view.KeyEvent)19 AdapterView (android.widget.AdapterView)17 Intent (android.content.Intent)16 ImageView (android.widget.ImageView)14 Editable (android.text.Editable)10 TextWatcher (android.text.TextWatcher)10 ArrayList (java.util.ArrayList)9 Dialog (android.app.Dialog)8 ListView (android.widget.ListView)8 Spinner (android.widget.Spinner)8 DialogInterface (android.content.DialogInterface)7 InputMethodManager (android.view.inputmethod.InputMethodManager)7 SuppressLint (android.annotation.SuppressLint)6