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;
}
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;
}
}
});
}
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);
}
});
}
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);
}
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);
// }
// });
}
}
}
}
}
}
Aggregations