Search in sources :

Example 86 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project LibreraReader by foobnix.

the class SearchFragment2 method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_search2, container, false);
    NO_SERIES = " (" + getString(R.string.without_series) + ")";
    handler = new Handler();
    secondTopPanel = view.findViewById(R.id.secondTopPanel);
    countBooks = (TextView) view.findViewById(R.id.countBooks);
    onRefresh = view.findViewById(R.id.onRefresh);
    onRefresh.setActivated(true);
    cleanFilter = (ImageView) view.findViewById(R.id.cleanFilter);
    sortBy = (TextView) view.findViewById(R.id.sortBy);
    sortOrder = (ImageView) view.findViewById(R.id.sortOrder);
    myAutoCompleteImage = (ImageView) view.findViewById(R.id.myAutoCompleteImage);
    searchEditText = (AutoCompleteTextView) view.findViewById(R.id.filterLine);
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    myAutoCompleteImage.setVisibility(View.GONE);
    ((FastScrollRecyclerView) recyclerView).setFastScrollStateChangeListener(new FastScrollStateChangeListener() {

        @Override
        public void onFastScrollStop() {
            ImageLoader.getInstance().resume();
            LOG.d("ImageLoader resume");
        }

        @Override
        public void onFastScrollStart() {
            LOG.d("ImageLoader pause");
            ImageLoader.getInstance().pause();
        }
    });
    searchEditText.addTextChangedListener(filterTextWatcher);
    searchEditText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    EditTextHelper.enableKeyboardSearch(searchEditText, new Runnable() {

        @Override
        public void run() {
            Keyboards.close(searchEditText);
            Keyboards.hideNavigation(getActivity());
        }
    });
    searchAdapter = new FileMetaAdapter();
    authorsAdapter = new AuthorsAdapter2();
    onGridlList = (ImageView) view.findViewById(R.id.onGridList);
    onGridlList.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            popupMenu(onGridlList);
        }
    });
    onRefresh.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!onRefresh.isActivated()) {
                Toast.makeText(getActivity(), R.string.extracting_information_from_books, Toast.LENGTH_LONG).show();
                return;
            }
            PrefDialogs.chooseFolderDialog(getActivity(), new Runnable() {

                @Override
                public void run() {
                    AppState.get().searchPaths = AppState.get().searchPaths.replace("//", "/");
                }
            }, new Runnable() {

                @Override
                public void run() {
                    recyclerView.scrollToPosition(0);
                    seachAll();
                }
            });
        }
    });
    cleanFilter.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            searchEditText.setText("");
            recyclerView.scrollToPosition(0);
            searchAndOrderAsync();
        }
    });
    sortBy.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            sortByPopup(v);
        }
    });
    sortOrder.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            AppState.get().isSortAsc = !AppState.get().isSortAsc;
            searchAndOrderAsync();
        }
    });
    bindAdapter(searchAdapter);
    searchAdapter.setOnAuthorClickListener(onAuthorClick);
    searchAdapter.setOnSeriesClickListener(onSeriesClick);
    authorsAdapter.setOnItemClickListener(onAuthorSeriesClick);
    onGridList();
    if (AppDB.get().getCount() == 0) {
        seachAll();
    } else {
        checkForDeleteBooks();
        searchAndOrderAsync();
    }
    initAutocomplition();
    onTintChanged();
    recyclerView.addOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
        }
    });
    myAutoCompleteImage.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            showAutoCompleteDialog();
        }
    });
    return view;
}
Also used : AuthorsAdapter2(com.foobnix.ui2.adapter.AuthorsAdapter2) FastScrollRecyclerView(com.foobnix.ui2.fast.FastScrollRecyclerView) OnScrollListener(android.support.v7.widget.RecyclerView.OnScrollListener) Handler(android.os.Handler) OnClickListener(android.view.View.OnClickListener) FastScrollRecyclerView(com.foobnix.ui2.fast.FastScrollRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) FastScrollStateChangeListener(com.foobnix.ui2.fast.FastScrollStateChangeListener) FastScrollRecyclerView(com.foobnix.ui2.fast.FastScrollRecyclerView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView) RecyclerView(android.support.v7.widget.RecyclerView) FileMetaAdapter(com.foobnix.ui2.adapter.FileMetaAdapter)

Example 87 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project BORED by invent2017.

the class MapsActivityCurrentPlace method initialiseSearch.

private void initialiseSearch(final AutoCompleteTextView searchView) {
    searchView.setHint("Search hashtags...                     ");
    searchView.setInputType(TYPE_CLASS_TEXT);
    searchView.setImeOptions(IME_ACTION_SEARCH);
    searchView.setMaxLines(1);
    mDataRef.child("hashtags").addListenerForSingleValueEvent(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            final ArrayList<String> popularHashtags = new ArrayList<>();
            for (DataSnapshot ds : dataSnapshot.getChildren()) {
                if (ds.getChildrenCount() >= 2) {
                    popularHashtags.add(ds.getKey());
                }
            }
            searchView.setAdapter(new ArrayAdapter<>(MapsActivityCurrentPlace.this, R.layout.suggestion_row, popularHashtags));
            searchView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                    String query = popularHashtags.get(i);
                    searchHashtags(view, query);
                }
            });
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
    searchView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if (i == KEYCODE_SEARCH || i == KEYCODE_ENTER) {
                String query = searchView.getText().toString();
                if (!query.equals("")) {
                    if (query.contains("#")) {
                        query = query.substring(1);
                    }
                    searchHashtags(view, query);
                }
                return true;
            } else {
                return false;
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) DataSnapshot(com.google.firebase.database.DataSnapshot) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView) KeyEvent(android.view.KeyEvent) DatabaseError(com.google.firebase.database.DatabaseError) AdapterView(android.widget.AdapterView) ValueEventListener(com.google.firebase.database.ValueEventListener) ArrayAdapter(android.widget.ArrayAdapter)

Example 88 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project Pix-Art-Messenger by kriztan.

the class StartConversationActivity method showJoinConferenceDialog.

@SuppressLint("InflateParams")
protected void showJoinConferenceDialog(final String prefilledJid) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.join_conference);
    final View dialogView = getLayoutInflater().inflate(R.layout.join_conference_dialog, null);
    final TextView yourAccount = dialogView.findViewById(R.id.your_account);
    final Spinner spinner = dialogView.findViewById(R.id.account);
    final AutoCompleteTextView jid = dialogView.findViewById(R.id.jid);
    DelayedHintHelper.setHint(R.string.conference_address_example, jid);
    jid.setAdapter(new KnownHostsAdapter(this, R.layout.simple_list_item, mKnownConferenceHosts));
    if (prefilledJid != null) {
        jid.append(prefilledJid);
    }
    if (xmppConnectionService.multipleAccounts()) {
        yourAccount.setVisibility(View.VISIBLE);
        spinner.setVisibility(View.VISIBLE);
    } else {
        yourAccount.setVisibility(View.GONE);
        spinner.setVisibility(View.GONE);
    }
    populateAccountSpinner(this, mActivatedAccounts, spinner);
    final Checkable bookmarkCheckBox = (CheckBox) dialogView.findViewById(R.id.bookmark);
    builder.setView(dialogView);
    builder.setNegativeButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.join, null);
    final AlertDialog dialog = builder.create();
    dialog.show();
    mCurrentDialog = dialog;
    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
        if (!xmppConnectionServiceBound) {
            return;
        }
        final Account account = getSelectedAccount(spinner);
        if (account == null) {
            return;
        }
        final Jid conferenceJid;
        try {
            conferenceJid = Jid.fromString(jid.getText().toString());
        } catch (final InvalidJidException e) {
            jid.setError(getString(R.string.invalid_jid));
            return;
        }
        if (bookmarkCheckBox.isChecked()) {
            if (account.hasBookmarkFor(conferenceJid)) {
                jid.setError(getString(R.string.bookmark_already_exists));
            } else {
                final Bookmark bookmark = new Bookmark(account, conferenceJid.toBareJid());
                bookmark.setAutojoin(getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin)));
                String nick = conferenceJid.getResourcepart();
                if (nick != null && !nick.isEmpty()) {
                    bookmark.setNick(nick);
                }
                account.getBookmarks().add(bookmark);
                xmppConnectionService.pushBookmarks(account);
                final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, conferenceJid, true, true, true);
                bookmark.setConversation(conversation);
                dialog.dismiss();
                mCurrentDialog = null;
                switchToConversation(conversation);
            }
        } else {
            final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, conferenceJid, true, true, true);
            dialog.dismiss();
            mCurrentDialog = null;
            switchToConversation(conversation);
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) KnownHostsAdapter(de.pixart.messenger.ui.adapter.KnownHostsAdapter) Account(de.pixart.messenger.entities.Account) Jid(de.pixart.messenger.xmpp.jid.Jid) Spinner(android.widget.Spinner) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException) Conversation(de.pixart.messenger.entities.Conversation) SpannableString(android.text.SpannableString) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView) Bookmark(de.pixart.messenger.entities.Bookmark) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) AutoCompleteTextView(android.widget.AutoCompleteTextView) Checkable(android.widget.Checkable) AutoCompleteTextView(android.widget.AutoCompleteTextView) SuppressLint(android.annotation.SuppressLint)

Example 89 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project Open-Weather-App by ardovic.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    cityCountryName = sharedPreferences.getString(CITY_COUNTRY_NAME, "");
    actvCityCountryName.setText(cityCountryName);
    mFetchThreadData = new FetchThreadData<>(mHandler);
    mFetchThreadData.start();
    mFetchThreadData.getLooper();
    initServerResponse();
    if (database.isOpen()) {
        checkDatabaseState();
    } else {
        database = databaseHelper.getReadableDatabase();
        checkDatabaseState();
    }
    // Create a SimpleCursorAdapter for the State Name field.
    mAdapter = new SimpleCursorAdapter(this, R.layout.dropdown_text, null, new String[] { CITY_COUNTRY_NAME }, new int[] { R.id.text }, 0);
    mAdapter.setFilterQueryProvider(new FilterQueryProvider() {

        @Override
        public Cursor runQuery(CharSequence constraint) {
            if (constraint != null) {
                if (constraint.length() >= 3 && !TextUtils.isEmpty(constraint)) {
                    Bundle bundle = new Bundle();
                    String query = charArrayUpperCaser(constraint);
                    bundle.putString(CITY_ARGS, query);
                    getLoaderManager().restartLoader(0, bundle, MainActivity.this).forceLoad();
                }
            }
            return null;
        }
    });
    // Set an OnItemClickListener, to update dependent fields when
    // a choice is made in the AutoCompleteTextView.
    actvCityCountryName.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> listView, View view, int position, long id) {
            // Get the cursor, positioned to the corresponding row in the
            // result set
            Cursor cursor = (Cursor) listView.getItemAtPosition(position);
            // Get the state's capital from this row in the database.
            cityCountryName = cursor.getString(cursor.getColumnIndexOrThrow(CITY_COUNTRY_NAME));
            // Update the parent class's TextView
            actvCityCountryName.setText(cityCountryName);
            mFetchThreadData.queueResponce(position, cityCountryName);
            // JSONWeatherTask task = new JSONWeatherTask();
            // task.execute(new String[]{cityCountryName});
            hideKeyboard();
        }
    });
    actvCityCountryName.setAdapter(mAdapter);
}
Also used : Bundle(android.os.Bundle) Cursor(android.database.Cursor) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) FilterQueryProvider(android.widget.FilterQueryProvider) SimpleCursorAdapter(android.widget.SimpleCursorAdapter) AdapterView(android.widget.AdapterView)

Example 90 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project actor-platform by actorapp.

the class ActorToolbar method doColorizing.

public static void doColorizing(View v, final ColorFilter colorFilter, int toolbarIconsColor) {
    if (v instanceof ImageButton) {
        ((ImageButton) v).getDrawable().setAlpha(255);
        ((ImageButton) v).getDrawable().setColorFilter(colorFilter);
    }
    if (v instanceof ImageView && !(v instanceof AvatarView)) {
        ((ImageView) v).getDrawable().setAlpha(255);
        ((ImageView) v).getDrawable().setColorFilter(colorFilter);
    }
    if (v instanceof AutoCompleteTextView) {
        ((AutoCompleteTextView) v).setTextColor(toolbarIconsColor);
    }
    if (v instanceof TextView) {
        ((TextView) v).setTextColor(toolbarIconsColor);
    }
    if (v instanceof EditText) {
        ((EditText) v).setTextColor(toolbarIconsColor);
    }
    if (v instanceof ViewGroup) {
        for (int lli = 0; lli < ((ViewGroup) v).getChildCount(); lli++) {
            doColorizing(((ViewGroup) v).getChildAt(lli), colorFilter, toolbarIconsColor);
        }
    }
    if (v instanceof ActionMenuView) {
        for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) {
            // Step 2: Changing the color of any ActionMenuViews - icons that
            // are not back button, nor text, nor overflow menu icon.
            final View innerView = ((ActionMenuView) v).getChildAt(j);
            if (innerView instanceof ActionMenuItemView) {
                int drawablesCount = ((ActionMenuItemView) innerView).getCompoundDrawables().length;
                for (int k = 0; k < drawablesCount; k++) {
                    if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                        final int finalK = k;
                        // Important to set the color filter in seperate thread,
                        // by adding it to the message queue
                        // Won't work otherwise.
                        // Works fine for my case but needs more testing
                        ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                    // innerView.post(new Runnable() {
                    // @Override
                    // public void run() {
                    // ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                    // }
                    // });
                    }
                }
            }
        }
    }
}
Also used : EditText(android.widget.EditText) ImageButton(android.widget.ImageButton) AvatarView(im.actor.sdk.view.avatar.AvatarView) ViewGroup(android.view.ViewGroup) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ActionMenuView(android.support.v7.widget.ActionMenuView) ImageView(android.widget.ImageView) AutoCompleteTextView(android.widget.AutoCompleteTextView) ActionMenuView(android.support.v7.widget.ActionMenuView) TextView(android.widget.TextView) ActionMenuItemView(android.support.v7.view.menu.ActionMenuItemView) AvatarView(im.actor.sdk.view.avatar.AvatarView) View(android.view.View) ActionMenuItemView(android.support.v7.view.menu.ActionMenuItemView) 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