List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.nbossard.packlist.gui.TripDetailFragment.java
/** * Disable the "Add item" button if item text is empty. * @param parMButton button to be disabled *///from w ww.ja v a 2 s .c o m private void disableButtonIfEmptyText(final Button parMButton) { EditText newItem = (EditText) mRootView.findViewById(R.id.trip_detail__new_item__edit); newItem.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { } @Override public void afterTextChanged(final Editable s) { parMButton.setEnabled(s.length() > 0); } }); }
From source file:com.cssweb.android.trade.stock.StockTrading.java
@Override public void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); sc = new ServiceControl(this);//?? ////www . j a v a 2 s . c om HandlerThread mHandlerThread = new HandlerThread("CSSWEB_THREAD"); mHandlerThread.start(); priceHandler = new PriceDataHandler(mHandlerThread.getLooper()); setContentView(com.cssweb.android.main.R.layout.zr_trade_stock_trade); Bundle bundle = getIntent().getExtras(); type = bundle.getInt("type"); bsname = bundle.getString("bsname"); String stockCode = bundle.getString("stkcode"); initTitle(R.drawable.njzq_title_left_back, 0, bsname); LinearLayout localLinearLayout = (LinearLayout) findViewById(R.id.zrtradelayout); localLinearLayout.setOnFocusChangeListener(setOnEditFocusListener); this.m_vklayout = localLinearLayout; View localView1 = this.m_vklayout; localView1.setOnFocusChangeListener(setOnEditFocusListener); View localView2 = this.m_vklayout; localView2.setOnClickListener(setOnEditClickListener); viewFlipper = (ViewFlipper) this.findViewById(R.id.ViewFlipper01); preView = (ImageView) findViewById(R.id.previous_screen); leftIn = AnimationUtils.loadAnimation(this, R.anim.push_left_in_layout); leftOut = AnimationUtils.loadAnimation(this, R.anim.push_left_out_layout); rightIn = AnimationUtils.loadAnimation(this, R.anim.push_right_in_layout); rightOut = AnimationUtils.loadAnimation(this, R.anim.push_right_out_layout); priceView = (PriceMini) findViewById(R.id.zrviewprice); trendView = (TrendView) findViewById(R.id.zrviewtrend); trendView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }); klineView = (KlineMini) findViewById(R.id.zrviewkline); klineView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }); financeView = (FinanceMini) findViewById(R.id.zrviewfinance); stockHolder = (Spinner) findViewById(R.id.zrtxtaccount); queryMethod = (Spinner) findViewById(R.id.zrtxtbsflag); // availableNum = (SeekBar) findViewById(R.id.zrcanbs); // lblMaxNumber = (TextView)findViewById(R.id.txtMaxNumber); stkcode = (EditText) findViewById(R.id.zredtstockcode); stkname = (TextView) findViewById(R.id.zrtxtstockname); price = (EditText) findViewById(R.id.zredtprice); number = (EditText) findViewById(R.id.zredtcount); lblNumberUnit = (TextView) findViewById(R.id.lblNumberUnit); btn0 = (ShadowButton) findViewById(R.id.zr_surebutton); btn0.setOnClickListener(myShowProgreeBar); layoutprice0 = (LinearLayout) findViewById(R.id.LinearLayout03); layoutprice = (LinearLayout) findViewById(R.id.LinearLayout11); //layoutAvaiNumber = (LinearLayout)findViewById(R.id.LinearLayout04); //layoutAvaiAsset = (LinearLayout)findViewById(R.id.LinearLayout06); lblAvaiAsset = (TextView) findViewById(R.id.lblAvaiAsset); AvaiAsset = (TextView) findViewById(R.id.AvaiAsset); lblPrice = (TextView) findViewById(R.id.lblPrice); lblPrice1 = (TextView) findViewById(R.id.lblPrice1); lblNumber = (TextView) findViewById(R.id.lblNumber); avaiAsset = (TextView) findViewById(R.id.AvaiAsset); lblNumberUnit = (TextView) findViewById(R.id.lblNumberUnit); setDynamic(); adjustDownPrice = (ImageView) findViewById(R.id.AdjustDownPrice); adjustDownPrice.setTag(0); adjustDownPrice.setOnClickListener(adjustIconListener); adjustUpPrice = (ImageView) findViewById(R.id.AdjustUpPrice); adjustUpPrice.setTag(1); adjustUpPrice.setOnClickListener(adjustIconListener); adjustDownNumber = (ImageView) findViewById(R.id.AdjustDownNumber); adjustDownNumber.setTag(2); adjustDownNumber.setOnClickListener(adjustIconListener); adjustUpNumber = (ImageView) findViewById(R.id.AdjustUpNumber); adjustUpNumber.setTag(3); adjustUpNumber.setOnClickListener(adjustIconListener); stkcode.setText(stockCode); if (stkcode.getText().length() == 6) { showProgress(); } stkcode.setInputType(InputType.TYPE_NULL); stkcode.setFocusable(true); stkcode.setTag("STOCK"); stkcode.setOnClickListener(setOnEditClickListener); stkcode.setOnFocusChangeListener(setOnEditFocusListener); price.setInputType(InputType.TYPE_NULL); price.setFocusable(true); price.setTag("NUMDOT"); price.setOnClickListener(setOnEditClickListener); price.setOnFocusChangeListener(setOnEditFocusListener); number.setInputType(InputType.TYPE_NULL); number.setFocusable(true); number.setTag(""); number.setOnClickListener(setOnEditClickListener); number.setOnFocusChangeListener(setOnEditFocusListener); stkcode.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable arg0) { //queryStock(queryCode.getText()); OnTextChanged(arg0); } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); holder = TradeUser.getInstance().getHolder(); stockHolderAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, (String[]) holder.toArray(new String[holder.size()])); stockHolderAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); stockHolder.setAdapter(stockHolderAdapter); String[] arrayOfString = getResources().getStringArray(R.array.other_market_bs_methods); for (int i = 0; i < arrayOfString.length; i++) { Log.e("arrayOfString", arrayOfString[i]); } queryMethodAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, arrayOfString); queryMethodAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); queryMethod.setAdapter(queryMethodAdapter); queryMethod.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position != 0) { layoutprice0.setVisibility(View.GONE); layoutprice.setVisibility(View.VISIBLE); } else { layoutprice0.setVisibility(View.VISIBLE); layoutprice.setVisibility(View.GONE); } } public void onNothingSelected(AdapterView<?> arg0) { } }); int h = R.drawable.forminput; Resources localResources = getResources(); Drawable localDrawable = null; localDrawable = localResources.getDrawable(h); int spinnerheight = localDrawable.getIntrinsicHeight() - 4; // Log.e("<<<<<<<<<<<<<<<<<<<eeeeeeeeeeeeeeeeeeeeeeeeeee>>>>>>>>>>>>>>", String.valueOf(spinnerheight)); LinearLayout.LayoutParams linearParams1 = (LinearLayout.LayoutParams) stockHolder.getLayoutParams();//?stockHolder? linearParams1.height = spinnerheight;//?? stockHolder.setLayoutParams(linearParams1); LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) queryMethod.getLayoutParams();//?queryMethod? linearParams.height = spinnerheight;//?? queryMethod.setLayoutParams(linearParams); }
From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Random r=new Random(); // int uniqueNumber =(r.nextInt(999) + 100); // uniqueId = Integer.toString(uniqueNumber); // ?uniqueId//from w w w .j a va 2 s.c om UUID uuid = UUID.randomUUID(); uniqueId = uuid.toString(); this.inflater = inflater; rootView = inflater.inflate(R.layout.fragment_car_check_basic_info, container, false); // <editor-fold defaultstate="collapsed" desc="??View?"> tableLayout = (TableLayout) rootView.findViewById(R.id.bi_content_table); contentLayout = (LinearLayout) rootView.findViewById(R.id.brand_input); Button vinButton = (Button) rootView.findViewById(R.id.bi_vin_button); vinButton.setOnClickListener(this); brandOkButton = (Button) rootView.findViewById(R.id.bi_brand_ok_button); brandOkButton.setEnabled(false); brandOkButton.setOnClickListener(this); brandSelectButton = (Button) rootView.findViewById(R.id.bi_brand_select_button); brandSelectButton.setEnabled(false); brandSelectButton.setOnClickListener(this); // ?? sketchPhotoEntities = new ArrayList<PhotoEntity>(); // Button matchButton = (Button) rootView.findViewById(R.id.ct_licencePhotoMatch_button); matchButton.setOnClickListener(this); // vin??? InputFilter alphaNumericFilter = new InputFilter() { @Override public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) { for (int k = arg1; k < arg2; k++) { if (!Character.isLetterOrDigit(arg0.charAt(k))) { return ""; } } return null; } }; vin_edit = (EditText) rootView.findViewById(R.id.bi_vin_edit); vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps() }); brandEdit = (EditText) rootView.findViewById(R.id.bi_brand_edit); displacementEdit = (EditText) rootView.findViewById(R.id.csi_displacement_edit); transmissionEdit = (EditText) rootView.findViewById(R.id.csi_transmission_edit); runEdit = (EditText) rootView.findViewById(R.id.bi_mileage_edit); // // transmissionSpinner = (Spinner)rootView.findViewById(R.id.csi_transmission_spinner); // transmissionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { // @Override // public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { // transmissionEdit.setText(adapterView.getSelectedItem().toString()); // } // // @Override // public void onNothingSelected(AdapterView<?> adapterView) { // // } // }); // ?????? ScrollView view = (ScrollView) rootView.findViewById(R.id.root); view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); view.setFocusable(true); view.setFocusableInTouchMode(true); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.requestFocusFromTouch(); return false; } }); // ????????2? runEdit.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable edt) { String temp = edt.toString(); if (temp.contains(".")) { int posDot = temp.indexOf("."); if (posDot <= 0) return; if (temp.length() - posDot - 1 > 2) { edt.delete(posDot + 3, posDot + 4); } } else { if (temp.length() > 2) { edt.clear(); edt.append(temp.substring(0, 2)); } } } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); licencePhotoMatchEdit = (EditText) rootView.findViewById(R.id.ct_licencePhotoMatch_edit); licencePhotoMatchEdit.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { licencePhotoMatchEdit.setError(null); } @Override public void afterTextChanged(Editable editable) { licencePhotoMatchEdit.setError(null); } }); // ?? carNumberEdit = (EditText) rootView.findViewById(R.id.ci_plateNumber_edit); carNumberEdit.setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) }); // ? portedProcedureRow = (TableRow) rootView.findViewById(R.id.ct_ported_procedure); // ?Spinner setRegLocationSpinner(); setCarColorSpinner(); setFirstLogTimeSpinner(); setManufactureTimeSpinner(); setTransferCountSpinner(); setLastTransferTimeSpinner(); setYearlyCheckAvailableDateSpinner(); setAvailableDateYearSpinner(); setBusinessInsuranceAvailableDateYearSpinner(); setOtherSpinners(); // </editor-fold> mCarSettings = new CarSettings(); // ??xml if (vehicleModel == null) { mProgressDialog = ProgressDialog.show(rootView.getContext(), null, "?..", false, false); Thread thread = new Thread(new Runnable() { @Override public void run() { try { ParseXml(); // jsonData?? if (!jsonData.equals("")) { modifyMode = true; letsEnterModifyMode(); } } catch (Exception e) { e.printStackTrace(); } } }); thread.start(); } return rootView; }
From source file:com.bisonswap.bisonswap.Chat.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mUsername = ANONYMOUS;// w w w .j av a 2 s .c o 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, SignIn.class)); finish(); return; } else { mUsername = mFirebaseUser.getDisplayName(); mPhotoUrl = mFirebaseUser.getPhotoUrl().toString(); } userEmail = mFirebaseUser.getEmail().replaceAll("\\.", "("); ownerEmail = getIntent().getStringExtra("ownerEmail").replaceAll("\\.", "("); // ownerEmail = "test@mail(lipscomb(edu"; //getIntent().getStringExtra(ownerEmail).replaceAll("\\.", "("); chatID = (ownerEmail.compareTo(userEmail) < 0 ? ownerEmail : userEmail) + "_BISONSWAP_" + (ownerEmail.compareTo(userEmail) > 0 ? ownerEmail : userEmail); 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).child(chatID)) { @Override protected FriendlyMessage parseSnapshot(DataSnapshot snapshot) { FriendlyMessage friendlyMessage = super.parseSnapshot(snapshot); if (friendlyMessage != null) { friendlyMessage.setId(snapshot.getKey()); } return friendlyMessage; } @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(Chat.this, R.drawable.ic_account_circle_black_36dp)); } else { Glide.with(Chat.this).load(friendlyMessage.getPhotoUrl()).into(viewHolder.messengerImageView); } // write this message to the on-device index FirebaseAppIndex.getInstance().update(getMessageIndexable(friendlyMessage)); // log a view action on it FirebaseUserActions.getInstance().end(getMessageViewAction(friendlyMessage)); } }; 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 and request AdMob ad. mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); // 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).child(chatID).push().setValue(friendlyMessage); mMessageEditText.setText(""); mFirebaseAnalytics.logEvent(MESSAGE_SENT_EVENT, null); } }); }
From source file:com.bisonswap.bisonswap.ChatList.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mUsername = ANONYMOUS;/* w w w . j ava2s. c o 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, SignIn.class)); finish(); return; } else { mUsername = mFirebaseUser.getDisplayName(); mPhotoUrl = mFirebaseUser.getPhotoUrl().toString(); } userEmail = mFirebaseUser.getEmail().replaceAll("\\.", "("); //ownerEmail = getIntent().getStringExtra("ownerEmail").replaceAll("\\.", "("); ownerEmail = "fischerpl@mail(lipscomb(edu"; //getIntent().getStringExtra(ownerEmail).replaceAll("\\.", "("); //chatID = (ownerEmail.compareTo(userEmail)<0?ownerEmail:userEmail) + "_BISONSWAP_" + (ownerEmail.compareTo(userEmail)>0?ownerEmail:userEmail); 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).child(chatID)) { @Override protected FriendlyMessage parseSnapshot(DataSnapshot snapshot) { FriendlyMessage friendlyMessage = super.parseSnapshot(snapshot); if (friendlyMessage != null) { friendlyMessage.setId(snapshot.getKey()); } return friendlyMessage; } @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(ChatList.this, R.drawable.ic_account_circle_black_36dp)); } else { Glide.with(ChatList.this).load(friendlyMessage.getPhotoUrl()) .into(viewHolder.messengerImageView); } // write this message to the on-device index FirebaseAppIndex.getInstance().update(getMessageIndexable(friendlyMessage)); // log a view action on it FirebaseUserActions.getInstance().end(getMessageViewAction(friendlyMessage)); } }; 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 and request AdMob ad. mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); // 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).child(chatID).push().setValue(friendlyMessage); mMessageEditText.setText(""); mFirebaseAnalytics.logEvent(MESSAGE_SENT_EVENT, null); } }); }
From source file:br.com.GUI.avaliacoes.SituacaoCoronaria.java
public void adicionarPersistencia() { //Objetivo do Treinamento rdObjetivoDoTreinamento.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override//w w w . jav a 2s.com public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.rdEmagrecimento: editor.putString("objetivoDoTreinamento", "Emagrecimento"); break; case R.id.rdHipertrofiaMuscular: editor.putString("objetivoDoTreinamento", "Hipertrofia Muscular"); break; case R.id.rdAumentoDaQualidadeDeVida: editor.putString("objetivoDoTreinamento", "Aumento da qualidade de vida"); break; } editor.commit(); } }); txtPressaoSistolicaMaxima.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { int valor = 0; try { valor = Integer.parseInt(s.toString()); } catch (Exception e) { } editor.putInt("pressaoSistolicaMaxima", valor); editor.commit(); } }); txtPressaoDiastolicaMaxima.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { int valor = 0; try { valor = Integer.parseInt(s.toString()); } catch (Exception e) { } editor.putInt("pressaoDiastolicaMaxima", valor); editor.commit(); } }); txtPressaoSistolicaDeRepouso.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { int valor = 0; try { valor = Integer.parseInt(s.toString()); } catch (Exception e) { } editor.putInt("pressaoSistolicaDeRepouso", valor); editor.commit(); } }); txtPressaoDiastolicaDeRepouso.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { int valor = 0; try { valor = Integer.parseInt(s.toString()); } catch (Exception e) { } editor.putInt("pressaoDiastolicaDeRepouso", valor); editor.commit(); } }); }
From source file:com.cloudant.todo.TodoActivity.java
public Dialog createNewTaskDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View v = this.getLayoutInflater().inflate(R.layout.dialog_new_task, null); final EditText description = (EditText) v.findViewById(R.id.new_task_desc); // Check description is present, if so add a task otherwise show an error DialogInterface.OnClickListener positiveClick = new DialogInterface.OnClickListener() { @Override//from w ww .ja va2 s . com public void onClick(DialogInterface dialog, int id) { if (description.getText().length() > 0) { createNewTask(description.getText().toString()); description.getText().clear(); } else { Toast.makeText(getApplicationContext(), R.string.task_not_created, Toast.LENGTH_LONG).show(); } } }; DialogInterface.OnClickListener negativeClick = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }; builder.setView(v).setTitle(R.string.new_task).setPositiveButton(R.string.create, positiveClick) .setNegativeButton(R.string.cancel, negativeClick); final AlertDialog d = builder.create(); // Enable "Create" button when the description has some characters final TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { final Button b = d.getButton(DialogInterface.BUTTON_POSITIVE); b.setEnabled(description.getText().length() > 0); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }; d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { final Button b = d.getButton(DialogInterface.BUTTON_POSITIVE); b.setEnabled(description.getText().length() > 0); description.addTextChangedListener(textWatcher); } }); return d; }
From source file:com.example.health_connect.MySampleFragment5.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.sample_fragment5, container, false); Parse.initialize(mView.getContext(), "e0FVFRBMAWJi5shg4XF8zL3SIuRwDIufww3338so", "toTJmlHTEF43u7PoAFT4fedwqfhoWiSajj1Se7FT"); final ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { listPicName.clear();/*from w w w. j ava2 s . c o m*/ listPicEmail.clear(); listPicAddress.clear(); listPicLic.clear(); listPicDegree.clear(); listPicSchool.clear(); listPicStart.clear(); listPicSpec.clear(); listPicDrawable.clear(); listPicId.clear(); try { ParseQuery<ParseUser> query = ParseUser.getQuery(); query.whereEqualTo("Type", "Doctor"); objects = query.find(); Log.d("Check", "here it is"); for (ParseUser r : objects) { listPicId.add((String) r.getObjectId()); listPicName.add((String) r.get("username")); listPicEmail.add((String) r.get("email")); listPicAddress.add((String) r.get("Address")); listPicLic.add((String) r.get("LicenseNo")); listPicDegree.add((String) r.get("Degree")); listPicSchool.add((String) r.get("Medical_School")); listPicSpec.add((String) r.get("Primary_speciality")); listPicStart.add((String) r.get("Start_Practice")); listPicDrawable.add(R.drawable.process2); Log.d("Check", "in for parse user"); } } catch (ParseException e) { Log.d("Error", "Oh nooo.."); } } Log.d("Error", "lists added"); fliper = (ViewFlipper) mView.findViewById(R.id.viewFlipper1); listview = (ListView) mView.findViewById(R.id.listView1); listPic.clear(); for (int i = 0; i < listPicName.size(); i++) { Log.d("Error", "for loop"); Picture pic = new Picture(listPicName.get(i), listPicEmail.get(i), listPicDrawable.get(i), listPicAddress.get(i), listPicLic.get(i), listPicDegree.get(i), listPicSchool.get(i), listPicSpec.get(i), listPicStart.get(i), listPicId.get(i)); Log.d("Error", "pic added"); listPic.add(pic); } Log.d("Error", "for exited"); if (adapter == null) adapter = new PicListAdapter(getActivity().getBaseContext(), listPic); Log.d("Error", "returned from adapter"); listview.setAdapter(adapter); Log.d("Error", "in adapter"); listview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, final int position, long id) { Sliding.slideFromRightToLeft(VIEW_PIC_SCREEN, fliper); viewpic.setImageResource(listPic.get(position).getPicSource()); viewname.setText(listPic.get(position).getPicName()); viewadd.setText(listPic.get(position).getPicAdd()); viewemail.setText(listPic.get(position).getPicType()); viewlic.setText(listPic.get(position).getPicLic()); viewdegree.setText(listPic.get(position).getPicDegree()); viewschool.setText(listPic.get(position).getPicSchool()); viewspec.setText(listPic.get(position).getPicSpec()); viewstart.setText(listPic.get(position).getPicStart()); Button cbtn = (Button) mView.findViewById(R.id.cht); cbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(mView.getContext(), Chat.class); intent.putExtra("Id", listPic.get(position).getPicId()); intent.putExtra("name", listPic.get(position).getPicName()); startActivity(intent); } }); Button btn = (Button) mView.findViewById(R.id.button1); Log.d("Error", "Button click"); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // ParseObject add_doctor=new ParseObject("AddDoctor"); // Log.d("Error","Built object"); // add_doctor.put("patient_id",currentUser.getObjectId()); // Log.d("Error","Added patient ID"); String x = listPic.get(position).getPicType(); Log.d("Error", "Got Email"); ParseQuery<ParseUser> query1 = ParseUser.getQuery(); query1.whereEqualTo("Type", "Doctor"); query1.whereEqualTo("email", x); Log.d("Error", "Query done"); try { obj = query1.find(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("Error", "Query found"); ParseQuery<ParseObject> query4 = new ParseQuery<ParseObject>("AddDoctor"); query4.whereEqualTo("patient_id", currentUser.getObjectId()); try { doc = query4.find(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } for (ParseObject t : doc) { for (ParseUser r : obj) { if (((String) t.get("doctor_id")).equalsIgnoreCase(r.getObjectId())) flag = false; Log.d("Checkurvashi", flag + " "); } } if (flag == true) { ParseObject add_doctor = new ParseObject("AddDoctor"); Log.d("Error", "Built object"); add_doctor.put("patient_id", currentUser.getObjectId()); Log.d("Error", "Added patient ID"); for (ParseUser r : obj) { String docid = r.getObjectId(); add_doctor.put("doctor_id", docid); } // for(ParseUser r : obj) // { // String docid=r.getObjectId(); // add_doctor.put("doctor_id",docid); // } Log.d("Error", "Doc added"); add_doctor.saveInBackground(); // // TextView txt=(TextView)mView.findViewById(R.id.textView8); // // txt.setText("Doctor successfully added"); MessageBox("Doctor successfully added"); } else { MessageBox("Doctor already added"); } } }); Log.d("Error", "in adapter hereee!!!!!!!"); } }); Log.d("Error", "exited adapter"); searchEdt = (EditText) mView.findViewById(R.id.serach_edt); Log.d("Error", "here6"); searchEdt.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { String text = searchEdt.getText().toString().toLowerCase(); adapter.filter(text); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); viewpic = (ImageView) mView.findViewById(R.id.pic3); viewadd = (TextView) mView.findViewById(R.id.docadd); viewname = (TextView) mView.findViewById(R.id.pname); viewspec = (TextView) mView.findViewById(R.id.pbg); viewdegree = (TextView) mView.findViewById(R.id.pnation); viewschool = (TextView) mView.findViewById(R.id.pwt); viewlic = (TextView) mView.findViewById(R.id.pht); viewemail = (TextView) mView.findViewById(R.id.pemail); viewstart = (TextView) mView.findViewById(R.id.pdob); return mView; }
From source file:co.taqat.call.ChatFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); final View view = inflater.inflate(R.layout.chat, container, false); LinphoneManager.addListener(this); // Retain the fragment across configuration changes setRetainInstance(true);// ww w.j a v a2s. c om this.inflater = inflater; if (getArguments() == null || getArguments().getString("SipUri") == null) { newChatConversation = true; } else { //Retrieve parameter from intent sipUri = getArguments().getString("SipUri"); } //Initialize UI defaultBitmap = BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.chat_picture_over); contactName = (TextView) view.findViewById(R.id.contact_name); messagesList = (ListView) view.findViewById(R.id.chat_message_list); searchContactField = (EditText) view.findViewById(R.id.search_contact_field); resultContactsSearch = (ListView) view.findViewById(R.id.result_contacts); editList = (LinearLayout) view.findViewById(R.id.edit_list); topBar = (LinearLayout) view.findViewById(R.id.top_bar); sendMessage = (ImageView) view.findViewById(R.id.send_message); sendMessage.setOnClickListener(this); remoteComposing = (TextView) view.findViewById(R.id.remote_composing); remoteComposing.setVisibility(View.GONE); cancel = (ImageView) view.findViewById(R.id.cancel); cancel.setOnClickListener(this); edit = (ImageView) view.findViewById(R.id.edit); edit.setOnClickListener(this); startCall = (ImageView) view.findViewById(R.id.start_call); startCall.setOnClickListener(this); backToCall = (ImageView) view.findViewById(R.id.back_to_call); backToCall.setOnClickListener(this); selectAll = (ImageView) view.findViewById(R.id.select_all); selectAll.setOnClickListener(this); deselectAll = (ImageView) view.findViewById(R.id.deselect_all); deselectAll.setOnClickListener(this); delete = (ImageView) view.findViewById(R.id.delete); delete.setOnClickListener(this); if (newChatConversation) { initNewChatConversation(); } message = (EditText) view.findViewById(R.id.message); sendImage = (ImageView) view.findViewById(R.id.send_picture); if (!getResources().getBoolean(R.bool.disable_chat_send_file)) { sendImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pickImage(); LinphoneActivity.instance().checkAndRequestPermissionsToSendImage(); } }); //registerForContextMenu(sendImage); } else { sendImage.setEnabled(false); } back = (ImageView) view.findViewById(R.id.back); if (getResources().getBoolean(R.bool.isTablet)) { back.setVisibility(View.INVISIBLE); } else { back.setOnClickListener(this); } mListener = new LinphoneCoreListenerBase() { @Override public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { LinphoneAddress from = cr.getPeerAddress(); if (from.asStringUriOnly().equals(sipUri)) { LinphoneService.instance().removeMessageNotification(); cr.markAsRead(); LinphoneActivity.instance().updateMissedChatCount(); adapter.addMessage(cr.getHistory(1)[0]); String externalBodyUrl = message.getExternalBodyUrl(); LinphoneContent fileTransferContent = message.getFileTransferInformation(); if (externalBodyUrl != null || fileTransferContent != null) { LinphoneActivity.instance().checkAndRequestExternalStoragePermission(); } } } @Override public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom room) { if (chatRoom != null && room != null && chatRoom.getPeerAddress().asStringUriOnly() .equals(room.getPeerAddress().asStringUriOnly())) { remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE); } } }; 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 { if (chatRoom != null) chatRoom.compose(); sendMessage.setEnabled(true); } } }; return view; }
From source file:com.nbossard.packlist.gui.NewTripFragment.java
/** * Disable the "Add item" button if item text is empty. *//*from w w w.j a v a 2 s .com*/ private void disableSubmitButtonIfEmptyText() { mSubmitButton.setEnabled(mNameTV.length() > 0); mNameTV.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { } @Override public void afterTextChanged(final Editable s) { mSubmitButton.setEnabled(s.length() > 0); } }); }