List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.meetingninja.csse.user.UserListFragment.java
private void setUpListView(View v) { mContactAdapter = new ContactArrayAdapter(getActivity(), R.layout.list_item_user, contacts); l = (EnhancedListView) v.findViewById(R.id.contacts_list); l.setAdapter(mContactAdapter);/*from w w w . j av a 2s.c o m*/ l.setEmptyView(v.findViewById(android.R.id.empty)); final EditText input = (EditText) v.findViewById(R.id.my_autocomplete); input.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { String text = input.getText().toString().toLowerCase(); mContactAdapter.getFilter().filter(text); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } }); l.setDismissCallback(new de.timroes.android.listview.EnhancedListView.OnDismissCallback() { @Override public EnhancedListView.Undoable onDismiss(EnhancedListView listView, final int position) { final Contact item = (Contact) mContactAdapter.getItem(position); tempDeletedContacts.add(item); contacts.remove(item); // for(int i=0;i<contacts.size();i++){ // System.out.println("this one: "+contacts.get(i).getContact().getDisplayName()); // } mContactAdapter.remove(item); return new EnhancedListView.Undoable() { @Override public void undo() { // mContactAdapter.insert(item, position); contacts.add(item); tempDeletedContacts.remove(item); mContactAdapter.notifyDataSetChanged(); } @Override public String getTitle() { return "Member deleted"; } @Override public void discard() { deleteContact(item); tempDeletedContacts.remove(item); } }; } }); l.setUndoHideDelay(5000); l.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long id) { User clicked = mContactAdapter.getItem(position).getContact(); Intent profileIntent = new Intent(v.getContext(), ProfileActivity.class); profileIntent.putExtra(Keys.User.PARCEL, new UserParcel(clicked)); startActivity(profileIntent); } }); l.enableSwipeToDismiss(); l.setSwipingLayout(R.id.list_group_item_frame_1); l.setSwipeDirection(EnhancedListView.SwipeDirection.BOTH); }
From source file:com.commonsdroid.fragmentdialog.NumberPickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.number_picker, null); Bundle b = getArguments();// www .j a va 2 s.c om if (mLowerRange >= mUpperRange) { Toast.makeText(getActivity(), "Lower Range Can Not be Greater than or Equal To Upper Range", Toast.LENGTH_LONG).show(); } else { if (b.getInt(UPPER_RANGE) % b.getInt(INTERVAL) != 0) { Toast.makeText(getActivity(), "Interval Not Correct. Interval set to 1", Toast.LENGTH_LONG).show(); mInterval = 1; } mSeparatorView = (View) v.findViewById(R.id.headSeparate); if (isTitleBarVisible) { mSeparatorView.setVisibility(View.VISIBLE); getDialog().setTitle(b.getInt(TITLE)); } else { mSeparatorView.setVisibility(View.INVISIBLE); getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); } getDialog().getWindow().setBackgroundDrawableResource(R.drawable.dialog_full_holo_dark); int defaultValue = b.getInt(DEFAULT_VALUE); if (defaultValue < mLowerRange) { defaultValue = mLowerRange; } else if (defaultValue > mUpperRange) { defaultValue = mUpperRange; } else if (defaultValue % mInterval != 0) { defaultValue += (defaultValue % mInterval); } mDefaultValue = defaultValue; btnSet = (Button) v.findViewById(R.id.btnSet); btnSet.setOnClickListener(this); btnCancel = (Button) v.findViewById(R.id.btnCancel); btnCancel.setOnClickListener(this); ibtnNext = (ImageButton) v.findViewById(R.id.ibtnNext); ibtnNext.setOnClickListener(this); ibtnPrev = (ImageButton) v.findViewById(R.id.ibtnPrev); ibtnPrev.setOnClickListener(this); edtSelectedValue = (EditText) v.findViewById(R.id.edtSelectedValue); lblHeaderText = (TextView) v.findViewById(R.id.lblHeaderMessage); String text = b.getString(HEADER); if (text != null) lblHeaderText.setText(text); else lblHeaderText.setText(""); edtSelectedValue.setText("" + defaultValue); lblPrevValue = (TextView) v.findViewById(R.id.lblPrevValue); if (defaultValue == mLowerRange) { lblPrevValue.setText(""); } else { lblPrevValue.setText("" + (defaultValue - mInterval)); } lblNextValue = (TextView) v.findViewById(R.id.lblNextValue); if (defaultValue == mUpperRange) { lblNextValue.setText(""); } else { lblNextValue.setText("" + (defaultValue + mInterval)); } if (defaultValue == mLowerRange) { ibtnPrev.setEnabled(false); } if (defaultValue == mUpperRange) { ibtnNext.setEnabled(false); } } if (mBackground != 0) { getDialog().getWindow().setBackgroundDrawableResource(mBackground); } if (mTextColor != 0) { lblHeaderText.setTextColor(mTextColor); lblNextValue.setTextColor(mTextColor); lblPrevValue.setTextColor(mTextColor); edtSelectedValue.setTextColor(mTextColor); } if (mButtonTextColor != 0) { btnCancel.setTextColor(mButtonTextColor); btnSet.setTextColor(mButtonTextColor); } if (mButtonArrowUp != 0 && mButtonArrowDown != 0) { ibtnNext.setImageResource(mButtonArrowDown); ibtnPrev.setImageResource(mButtonArrowUp); } if (mButtonBackground != 0) { btnCancel.setBackgroundResource(mButtonBackground); btnSet.setBackgroundResource(mButtonBackground); } edtSelectedValue.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (edtSelectedValue.getText().toString().equals("")) { } else { int newValue = Integer.parseInt(edtSelectedValue.getText().toString()); if (newValue < mLowerRange || newValue > mUpperRange) { edtSelectedValue.setText("" + mPrevValue); } else if (newValue % mInterval != 0) { } else { if (newValue != mLowerRange) lblPrevValue.setText("" + (newValue - mInterval)); else lblPrevValue.setText(""); if (newValue != mUpperRange) lblNextValue.setText("" + (newValue + mInterval)); else lblNextValue.setText(""); } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (!edtSelectedValue.getText().toString().equals("")) { mPrevValue = edtSelectedValue.getText().toString(); } } @Override public void afterTextChanged(Editable s) { } }); return v; }
From source file:com.google.firebase.codelab.friendlych.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mUsername = ANONYMOUS;/*ww w . j ava 2 s .co m*/ // Initialize Firebase Auth mFirebaseAuth = FirebaseAuth.getInstance(); mFirebaseUser = mFirebaseAuth.getCurrentUser(); if (mFirebaseUser == null) { // Not signed in, launch the Sign In activity startActivity(new Intent(this, SignInActivity.class)); finish(); return; } else { mUsername = mFirebaseUser.getDisplayName(); mPhotoUrl = mFirebaseUser.getPhotoUrl().toString(); } mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API).build(); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setStackFromEnd(true); mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference(); mFirebaseAdapter = new FirebaseRecyclerAdapter<FriendlyMessage, MessageViewHolder>(FriendlyMessage.class, R.layout.item_message, MessageViewHolder.class, mFirebaseDatabaseReference.child(MESSAGES_CHILD)) { @Override protected void populateViewHolder(MessageViewHolder viewHolder, FriendlyMessage friendlyMessage, int position) { mProgressBar.setVisibility(ProgressBar.INVISIBLE); viewHolder.messageTextView.setText(friendlyMessage.getText()); viewHolder.messengerTextView.setText(friendlyMessage.getName()); if (friendlyMessage.getPhotoUrl() == null) { viewHolder.messengerImageView.setImageDrawable( ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_account_circle_black_36dp)); } else { Glide.with(MainActivity.this).load(friendlyMessage.getPhotoUrl()) .into(viewHolder.messengerImageView); } } }; mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeInserted(int positionStart, int itemCount) { super.onItemRangeInserted(positionStart, itemCount); int friendlyMessageCount = mFirebaseAdapter.getItemCount(); int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition(); // If the recycler view is initially being loaded or the user is at the bottom of the list, scroll // to the bottom of the list to show the newly added message. if (lastVisiblePosition == -1 || (positionStart >= (friendlyMessageCount - 1) && lastVisiblePosition == (positionStart - 1))) { mMessageRecyclerView.scrollToPosition(positionStart); } } }); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mMessageRecyclerView.setAdapter(mFirebaseAdapter); // Initialize Firebase Measurement. mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); // Initialize Firebase Remote Config. mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); // Define Firebase Remote Config Settings. FirebaseRemoteConfigSettings firebaseRemoteConfigSettings = new FirebaseRemoteConfigSettings.Builder() .setDeveloperModeEnabled(true).build(); // Define default config values. Defaults are used when fetched config values are not // available. Eg: if an error occurred fetching values from the server. Map<String, Object> defaultConfigMap = new HashMap<>(); defaultConfigMap.put("friendly_msg_length", 10L); // Apply config settings and default values. mFirebaseRemoteConfig.setConfigSettings(firebaseRemoteConfigSettings); mFirebaseRemoteConfig.setDefaults(defaultConfigMap); // Fetch remote config. fetchConfig(); mMessageEditText = (EditText) findViewById(R.id.messageEditText); mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter( mSharedPreferences.getInt(CodelabPreferences.FRIENDLY_MSG_LENGTH, DEFAULT_MSG_LENGTH_LIMIT)) }); mMessageEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (charSequence.toString().trim().length() > 0) { mSendButton.setEnabled(true); } else { mSendButton.setEnabled(false); } } @Override public void afterTextChanged(Editable editable) { } }); mSendButton = (Button) findViewById(R.id.sendButton); mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { FriendlyMessage friendlyMessage = new FriendlyMessage(mMessageEditText.getText().toString(), mUsername, mPhotoUrl); mFirebaseDatabaseReference.child(MESSAGES_CHILD).push().setValue(friendlyMessage); mMessageEditText.setText(""); mFirebaseAnalytics.logEvent(MESSAGE_SENT_EVENT, null); } }); }
From source file:com.cesquerr.becky.app.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Init variables mBleManager = BleManager.getInstance(this); restoreRetainedDataFragment();/*from w w w . j a va 2s . com*/ mPeripheralList = new PeripheralList(); // UI mScannedDevicesListView = (ExpandableHeightExpandableListView) findViewById(R.id.scannedDevicesListView); mScannedDevicesAdapter = new ExpandableListAdapter(); mScannedDevicesListView.setAdapter(mScannedDevicesAdapter); mScannedDevicesListView.setExpanded(true); mScannedDevicesListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { } }); mScanButton = (Button) findViewById(R.id.scanButton); mNoDevicesTextView = (TextView) findViewById(R.id.nodevicesTextView); mDevicesScrollView = (ScrollView) findViewById(R.id.devicesScrollView); mDevicesScrollView.setVisibility(View.GONE); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); mSwipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { mScannedDevices.clear(); startScan(null); mSwipeRefreshLayout.postDelayed(new Runnable() { @Override public void run() { mSwipeRefreshLayout.setRefreshing(false); } }, 500); } }); mFiltersPanelView = findViewById(R.id.filtersExpansionView); mFiltersExpandImageView = (ImageView) findViewById(R.id.filtersExpandImageView); mFiltersClearButton = (ImageButton) findViewById(R.id.filtersClearButton); mFiltersTitleTextView = (TextView) findViewById(R.id.filtersTitleTextView); mFiltersNameEditText = (EditText) findViewById(R.id.filtersNameEditText); mFiltersNameEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { String text = s.toString(); mPeripheralList.setFilterName(text); updateFilters(); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); mFiltersRssiSeekBar = (SeekBar) findViewById(R.id.filtersRssiSeekBar); mFiltersRssiSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { int rssiValue = -seekBar.getProgress(); mPeripheralList.setFilterRssiValue(rssiValue); updateRssiValue(); updateFilters(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mFiltersRssiValueTextView = (TextView) findViewById(R.id.filtersRssiValueTextView); mFiltersUnnamedCheckBox = (CheckBox) findViewById(R.id.filtersUnnamedCheckBox); mFiltersUnnamedCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mPeripheralList.setFilterUnnamedEnabled(isChecked); updateFilters(); } }); mFiltersUartCheckBox = (CheckBox) findViewById(R.id.filtersUartCheckBox); mFiltersUartCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mPeripheralList.setFilterOnlyUartEnabled(isChecked); updateFilters(); } }); // Filters SharedPreferences preferences = getSharedPreferences(kPreferences, MODE_PRIVATE); boolean filtersIsPanelOpen = preferences.getBoolean(kPreferences_filtersPanelOpen, false); openFiltersPanel(filtersIsPanelOpen, false); updateFiltersTitle(); mFiltersNameEditText.setText(mPeripheralList.getFilterName()); setRssiSliderValue(mPeripheralList.getFilterRssiValue()); mFiltersUnnamedCheckBox.setChecked(mPeripheralList.isFilterUnnamedEnabled()); mFiltersUartCheckBox.setChecked(mPeripheralList.isFilterOnlyUartEnabled()); // Setup when activity is created for the first time if (savedInstanceState == null) { // Read preferences SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean autoResetBluetoothOnStart = sharedPreferences.getBoolean("pref_resetble", false); boolean disableWifi = sharedPreferences.getBoolean("pref_disableWifi", false); boolean updatesEnabled = sharedPreferences.getBoolean("pref_updatesenabled", true); // Update SoftwareUpdateManager if (updatesEnabled) { mFirmwareUpdater = new FirmwareUpdater(this, this); mFirmwareUpdater.refreshSoftwareUpdatesDatabase(); } // Turn off wifi if (disableWifi) { final boolean isWifiEnabled = BleUtils.isWifiEnabled(this); if (isWifiEnabled) { BleUtils.enableWifi(false, this); mShouldEnableWifiOnQuit = true; } } // Check if bluetooth adapter is available final boolean wasBluetoothEnabled = manageBluetoothAvailability(); final boolean areLocationServicesReadyForScanning = manageLocationServiceAvailabilityForScanning(); // Reset bluetooth if (autoResetBluetoothOnStart && wasBluetoothEnabled && areLocationServicesReadyForScanning) { BleUtils.resetBluetoothAdapter(this, this); } } // Request Bluetooth scanning permissions requestLocationPermissionIfNeeded(); }
From source file:com.iyaa.richat.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mUsername = ANONYMOUS;/*from ww w . j av a 2 s .c om*/ // Initialize Firebase Auth mFirebaseAuth = FirebaseAuth.getInstance(); mFirebaseUser = mFirebaseAuth.getCurrentUser(); if (mFirebaseUser == null) { // Not signed in, launch the Sign In activity startActivity(new Intent(this, SignInActivity.class)); finish(); return; } else { mUsername = mFirebaseUser.getDisplayName(); if (mFirebaseUser.getPhotoUrl() != null) { mPhotoUrl = mFirebaseUser.getPhotoUrl().toString(); } } mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API).build(); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setStackFromEnd(true); mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference(); mFirebaseAdapter = new FirebaseRecyclerAdapter<FriendlyMessage, MessageViewHolder>(FriendlyMessage.class, R.layout.item_message, MessageViewHolder.class, mFirebaseDatabaseReference.child(MESSAGES_CHILD)) { @Override protected void populateViewHolder(MessageViewHolder viewHolder, FriendlyMessage friendlyMessage, int position) { mProgressBar.setVisibility(ProgressBar.INVISIBLE); viewHolder.messageTextView.setText(friendlyMessage.getText()); viewHolder.messengerTextView.setText(friendlyMessage.getName()); if (friendlyMessage.getPhotoUrl() == null) { viewHolder.messengerImageView.setImageDrawable( ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_account_circle_black_36dp)); } else { Glide.with(MainActivity.this).load(friendlyMessage.getPhotoUrl()) .into(viewHolder.messengerImageView); } } }; mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeInserted(int positionStart, int itemCount) { super.onItemRangeInserted(positionStart, itemCount); int friendlyMessageCount = mFirebaseAdapter.getItemCount(); int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition(); // If the recycler view is initially being loaded or the user is at the bottom of the list, scroll // to the bottom of the list to show the newly added message. if (lastVisiblePosition == -1 || (positionStart >= (friendlyMessageCount - 1) && lastVisiblePosition == (positionStart - 1))) { mMessageRecyclerView.scrollToPosition(positionStart); } } }); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mMessageRecyclerView.setAdapter(mFirebaseAdapter); // Initialize Firebase Measurement. mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); // Initialize Firebase Remote Config. mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); // Define Firebase Remote Config Settings. FirebaseRemoteConfigSettings firebaseRemoteConfigSettings = new FirebaseRemoteConfigSettings.Builder() .setDeveloperModeEnabled(true).build(); // Define default config values. Defaults are used when fetched config values are not // available. Eg: if an error occurred fetching values from the server. Map<String, Object> defaultConfigMap = new HashMap<>(); defaultConfigMap.put("friendly_msg_length", 80L); // Apply config settings and default values. mFirebaseRemoteConfig.setConfigSettings(firebaseRemoteConfigSettings); mFirebaseRemoteConfig.setDefaults(defaultConfigMap); // Fetch remote config. fetchConfig(); mMessageEditText = (EditText) findViewById(R.id.messageEditText); mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter( mSharedPreferences.getInt(CodelabPreferences.FRIENDLY_MSG_LENGTH, DEFAULT_MSG_LENGTH_LIMIT)) }); mMessageEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (charSequence.toString().trim().length() > 0) { mSendButton.setEnabled(true); } else { mSendButton.setEnabled(false); } } @Override public void afterTextChanged(Editable editable) { } }); mSendButton = (Button) findViewById(R.id.sendButton); mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { FriendlyMessage friendlyMessage = new FriendlyMessage(mMessageEditText.getText().toString(), mUsername, mPhotoUrl); mFirebaseDatabaseReference.child(MESSAGES_CHILD).push().setValue(friendlyMessage); mMessageEditText.setText(""); mFirebaseAnalytics.logEvent(MESSAGE_SENT_EVENT, null); } }); }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentSearch.java
private void InitiateSearch() { card_search.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override// www .j a va2 s .com public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); InitiateSearch.handleToolBar(getActivity(), card_search, view_search, listView, edit_text_search, line_divider); } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { LogQuickSearch logQuickSearch = logQuickSearchAdapter.getItem(position); edit_text_search.setText(logQuickSearch.getName()); listView.setVisibility(View.GONE); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(edit_text_search.getWindowToken(), 0); searchFood(logQuickSearch.getName(), 0); } }); edit_text_search.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (edit_text_search.getText().toString().length() == 0) { logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all()); listView.setAdapter(logQuickSearchAdapter); clearSearch.setImageResource(R.mipmap.ic_keyboard_voice); IsAdapterEmpty(); } else { logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.FilterByName(edit_text_search.getText().toString())); listView.setAdapter(logQuickSearchAdapter); clearSearch.setImageResource(R.mipmap.ic_close); IsAdapterEmpty(); } } @Override public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (edit_text_search.getText().toString().length() != 0) { edit_text_search.setText(""); searchBack.setVisibility(View.GONE); listView.setVisibility(View.VISIBLE); clearItems(); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); IsAdapterEmpty(); } else { promptSpeechInput(edit_text_search); } } }); }
From source file:com.goftagram.telegram.ui.PasscodeActivity.java
@Override public View createView(Context context) { if (type != 3) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); }// ww w . jav a 2 s. co m actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } else if (id == pin_item) { currentPasswordType = 0; updateDropDownTextView(); } else if (id == password_item) { currentPasswordType = 1; updateDropDownTextView(); } } }); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; if (type != 0) { ActionBarMenu menu = actionBar.createMenu(); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); titleTextView = new TextView(context); titleTextView.setTextColor(0xff757575); if (type == 1) { if (UserConfig.passcodeHash.length() != 0) { titleTextView .setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode)); } else { titleTextView.setText( LocaleController.getString("EnterNewFirstPasscode", R.string.EnterNewFirstPasscode)); } } else { titleTextView .setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode)); } titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); frameLayout.addView(titleTextView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); passwordEditText.setTextColor(0xff000000); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); if (type == 1) { passcodeSetStep = 0; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); } else { passcodeSetStep = 1; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); } passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setTypeface(Typeface.DEFAULT); AndroidUtilities.clearCursorDrawable(passwordEditText); frameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(90); layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(40); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (passcodeSetStep == 0) { processNext(); return true; } else if (passcodeSetStep == 1) { processDone(); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4) { if (type == 2 && UserConfig.passcodeType == 0) { processDone(); } else if (type == 1 && currentPasswordType == 0) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } } } }); if (android.os.Build.VERSION.SDK_INT < 11) { passwordEditText.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.clear(); } }); } else { passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); } if (type == 1) { dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector); dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0); dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0); actionBar.addView(dropDownContainer); layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; dropDownContainer.setLayoutParams(layoutParams); dropDownContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dropDownContainer.toggleSubMenu(); } }); dropDown = new TextView(context); dropDown.setGravity(Gravity.LEFT); dropDown.setSingleLine(true); dropDown.setLines(1); dropDown.setMaxLines(1); dropDown.setEllipsize(TextUtils.TruncateAt.END); dropDown.setTextColor(0xffffffff); dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0); dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4)); dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0); dropDownContainer.addView(dropDown); layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.bottomMargin = AndroidUtilities.dp(1); dropDown.setLayoutParams(layoutParams); } else { actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); } updateDropDownTextView(); } else { actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); frameLayout.setBackgroundColor(0xfff0f0f0); listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == changePasscodeRow) { presentFragment(new PasscodeActivity(1)); } else if (i == passcodeRow) { TextCheckCell cell = (TextCheckCell) view; if (UserConfig.passcodeHash.length() != 0) { UserConfig.passcodeHash = ""; UserConfig.appLocked = false; UserConfig.saveConfig(false); int count = listView.getChildCount(); for (int a = 0; a < count; a++) { View child = listView.getChildAt(a); if (child instanceof TextSettingsCell) { TextSettingsCell textCell = (TextSettingsCell) child; textCell.setTextColor(0xffc6c6c6); break; } } cell.setChecked(UserConfig.passcodeHash.length() != 0); NotificationCenter.getInstance() .postNotificationName(NotificationCenter.didSetPasscode); } else { presentFragment(new PasscodeActivity(1)); } } else if (i == autoLockRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock)); final NumberPicker numberPicker = new NumberPicker(getParentActivity()); numberPicker.setMinValue(0); numberPicker.setMaxValue(4); if (UserConfig.autoLockIn == 0) { numberPicker.setValue(0); } else if (UserConfig.autoLockIn == 60) { numberPicker.setValue(1); } else if (UserConfig.autoLockIn == 60 * 5) { numberPicker.setValue(2); } else if (UserConfig.autoLockIn == 60 * 60) { numberPicker.setValue(3); } else if (UserConfig.autoLockIn == 60 * 60 * 5) { numberPicker.setValue(4); } numberPicker.setFormatter(new NumberPicker.Formatter() { @Override public String format(int value) { if (value == 0) { return LocaleController.getString("Disabled", R.string.Disabled); } else if (value == 1) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1)); } else if (value == 2) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5)); } else if (value == 3) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1)); } else if (value == 4) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5)); } return ""; } }); builder.setView(numberPicker); builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { which = numberPicker.getValue(); if (which == 0) { UserConfig.autoLockIn = 0; } else if (which == 1) { UserConfig.autoLockIn = 60; } else if (which == 2) { UserConfig.autoLockIn = 60 * 5; } else if (which == 3) { UserConfig.autoLockIn = 60 * 60; } else if (which == 4) { UserConfig.autoLockIn = 60 * 60 * 5; } listView.invalidateViews(); UserConfig.saveConfig(false); } }); showDialog(builder.create()); } else if (i == fingerprintRow) { UserConfig.useFingerprint = !UserConfig.useFingerprint; UserConfig.saveConfig(false); ((TextCheckCell) view).setChecked(UserConfig.useFingerprint); } } }); } return fragmentView; }
From source file:com.lchtime.safetyexpress.ui.chat.hx.activity.AddContactActivity.java
private void initListener() { editText.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { // conversationListView.filter(s); if (s.length() > 0) { // clearSearch.setVisibility(View.VISIBLE); mRlSearchButton.setVisibility(View.VISIBLE); } else { // clearSearch.setVisibility(View.INVISIBLE); mRlSearchButton.setVisibility(View.GONE); mSearchResult.setVisibility(View.GONE); searchedUserLayout.setVisibility(View.VISIBLE); }/*from w w w. ja v a2 s .co m*/ mTvSearchContent.setText(s); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); mRlSearchButton.setOnClickListener(this); }
From source file:org.xingjitong.ChatFragment.java
@SuppressLint("Recycle") @SuppressWarnings("static-access") @Override/* ww w .j a v a 2s . c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SharedPreferences share = PreferenceManager.getDefaultSharedPreferences(getActivity()); if (share.getInt(getString(R.string.setting_reg_uid), 0) == 0) { Toast.makeText(getActivity(), "!?,?!", Toast.LENGTH_LONG).show(); getActivity().getSupportFragmentManager().popBackStack(); } String displayName = getArguments().getString("DisplayName"); String pictureUri = getArguments().getString("PictureUri"); sipUri = getArguments().getString("SipUri"); sipUri = sipUri.substring(sipUri.indexOf(":") + 1, sipUri.indexOf("@")); try { LinphoneAddress address = LinphoneManager.getInstance().getLc().interpretUrl(sipUri); sipUri = address.asString(); sipUri = sipUri.replace("<", "").replace(">", ""); } catch (LinphoneCoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } view = inflater.inflate(R.layout.chat, container, false); contactName = (TextView) view.findViewById(R.id.contactName); contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); sendMessage = (TextView) view.findViewById(R.id.sendMessage); sendMessage.setOnClickListener(this); message = (EditText) view.findViewById(R.id.message); if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) { message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE); message.setMaxLines(1); } uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout); textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout); messagesLayout = (RelativeLayout) view.findViewById(R.id.messages); messagesScrollView = (ScrollView) view.findViewById(R.id.chatScrollView); progressBar = (ProgressBar) view.findViewById(R.id.progressbar); sendImage = (TextView) view.findViewById(R.id.sendPicture); registerForContextMenu(sendImage); sendImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pickImage(); } }); cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload); cancelUpload.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { uploadThread.interrupt(); uploadLayout.setVisibility(View.GONE); textLayout.setVisibility(View.VISIBLE); progressBar.setProgress(0); } }); displayChat(displayName, pictureUri); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { chatRoom = lc.createChatRoom(sipUri); } // SharedPreferences prefs = // PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance()); // uploadServerUri = // prefs.getString(getString(R.string.pref_image_sharing_server_key), // getString(R.string.pref_image_sharing_server_default)); uploadServerUri = getString(R.string.pref_image_sharing_server_default); textWatcher = new TextWatcher() { public void afterTextChanged(Editable arg0) { } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { if (message.getText().toString().equals("")) { sendMessage.setEnabled(false); } else { sendMessage.setEnabled(true); } } }; // Force hide keyboard if (LinphoneActivity.isInstanciated()) { InputMethodManager imm = (InputMethodManager) LinphoneActivity.instance() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } // Workaround for SGS3 issue if (savedInstanceState != null) { fileToUploadPath = savedInstanceState.getString("fileToUploadPath"); imageToUpload = savedInstanceState.getParcelable("imageToUpload"); } if (fileToUploadPath != null || imageToUpload != null) { sendImage.post(new Runnable() { @Override public void run() { sendImage.showContextMenu(); } }); } return view; }