List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.ieeton.user.activity.ChatActivity.java
/** * initView/*from w w w . j av a2s . c o m*/ */ protected void initView() { mTvTitle = (TextView) findViewById(R.id.name); recordingContainer = findViewById(R.id.recording_container); micImage = (ImageView) findViewById(R.id.mic_image); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice); buttonSend = findViewById(R.id.btn_send); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(R.id.vPager); emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container); locationImgview = (ImageView) findViewById(R.id.btn_location); iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal); iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); btnMore = (Button) findViewById(R.id.btn_more); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(R.id.more); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); mBtnCall = (ImageView) findViewById(R.id.iv_call); mBtnCall.setOnClickListener(this); if (mUser != null) { if (mUser.getUserType() == 1 || mUser.getUserType() == 2) { mBtnCall.setVisibility(View.VISIBLE); } else { mBtnCall.setVisibility(View.GONE); } } mBackBtn = (LinearLayout) findViewById(R.id.ll_back); mBackBtn.setOnClickListener(this); // ?, micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01), getResources().getDrawable(R.drawable.record_animate_02), getResources().getDrawable(R.drawable.record_animate_03), getResources().getDrawable(R.drawable.record_animate_04), getResources().getDrawable(R.drawable.record_animate_05), getResources().getDrawable(R.drawable.record_animate_06), getResources().getDrawable(R.drawable.record_animate_07), getResources().getDrawable(R.drawable.record_animate_08), getResources().getDrawable(R.drawable.record_animate_09), getResources().getDrawable(R.drawable.record_animate_10), getResources().getDrawable(R.drawable.record_animate_11), getResources().getDrawable(R.drawable.record_animate_12), getResources().getDrawable(R.drawable.record_animate_13), getResources().getDrawable(R.drawable.record_animate_14), }; // list reslist = getExpressionRes(35); // ?viewpager List<View> views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); views.add(gv1); views.add(gv2); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { btnMore.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { btnMore.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); }
From source file:com.app.khclub.base.easeim.activity.ChatActivity.java
/** * initView/* w ww . j ava 2s . c o m*/ */ protected void initView() { recordingContainer = findViewById(R.id.recording_container); micImage = (ImageView) findViewById(R.id.mic_image); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice); buttonSend = findViewById(R.id.btn_send); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(R.id.vPager); emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container); // locationImgview = (ImageView) findViewById(R.id.btn_location); cardImgview = (ImageView) findViewById(R.id.btn_card); iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal); iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); btnMore = (Button) findViewById(R.id.btn_more); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(R.id.more); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); // voiceCallBtn = (ImageView) findViewById(R.id.btn_voice_call); // videoCallBtn = (ImageView) findViewById(R.id.btn_video_call); // ?, micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01), getResources().getDrawable(R.drawable.record_animate_02), getResources().getDrawable(R.drawable.record_animate_03), getResources().getDrawable(R.drawable.record_animate_04), getResources().getDrawable(R.drawable.record_animate_05), getResources().getDrawable(R.drawable.record_animate_06), getResources().getDrawable(R.drawable.record_animate_07), getResources().getDrawable(R.drawable.record_animate_08), getResources().getDrawable(R.drawable.record_animate_09), getResources().getDrawable(R.drawable.record_animate_10), getResources().getDrawable(R.drawable.record_animate_11), getResources().getDrawable(R.drawable.record_animate_12), getResources().getDrawable(R.drawable.record_animate_13), getResources().getDrawable(R.drawable.record_animate_14) }; // list reslist = getExpressionRes(35); // ?viewpager List<View> views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); views.add(gv1); views.add(gv2); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { btnMore.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { btnMore.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout); swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { adapter.notifyDataSetChanged(); adapter.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(ChatActivity.this, getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 1000); } }); }
From source file:cn.gen.superwechat.activity.ChatActivity.java
/** * initView/*from w ww. j a v a 2 s . c om*/ */ protected void initView() { recordingContainer = findViewById(cn.gen.superwechat.R.id.recording_container); micImage = (ImageView) findViewById(cn.gen.superwechat.R.id.mic_image); recordingHint = (TextView) findViewById(cn.gen.superwechat.R.id.recording_hint); listView = (ListView) findViewById(cn.gen.superwechat.R.id.list); mEditTextContent = (PasteEditText) findViewById(cn.gen.superwechat.R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(cn.gen.superwechat.R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(cn.gen.superwechat.R.id.edittext_layout); buttonSetModeVoice = findViewById(cn.gen.superwechat.R.id.btn_set_mode_voice); buttonSend = findViewById(cn.gen.superwechat.R.id.btn_send); buttonPressToSpeak = findViewById(cn.gen.superwechat.R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(cn.gen.superwechat.R.id.vPager); emojiIconContainer = (LinearLayout) findViewById(cn.gen.superwechat.R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(cn.gen.superwechat.R.id.ll_btn_container); locationImgview = (ImageView) findViewById(cn.gen.superwechat.R.id.btn_location); iv_emoticons_normal = (ImageView) findViewById(cn.gen.superwechat.R.id.iv_emoticons_normal); iv_emoticons_checked = (ImageView) findViewById(cn.gen.superwechat.R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(cn.gen.superwechat.R.id.pb_load_more); btnMore = (Button) findViewById(cn.gen.superwechat.R.id.btn_more); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(cn.gen.superwechat.R.id.more); edittext_layout.setBackgroundResource(cn.gen.superwechat.R.drawable.input_bar_bg_normal); voiceCallBtn = (ImageView) findViewById(cn.gen.superwechat.R.id.btn_voice_call); videoCallBtn = (ImageView) findViewById(cn.gen.superwechat.R.id.btn_video_call); // ?, micImages = new Drawable[] { getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_01), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_02), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_03), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_04), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_05), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_06), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_07), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_08), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_09), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_10), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_11), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_12), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_13), getResources().getDrawable(cn.gen.superwechat.R.drawable.record_animate_14) }; // list reslist = getExpressionRes(35); // ?viewpager List<View> views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); views.add(gv1); views.add(gv2); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(cn.gen.superwechat.R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(cn.gen.superwechat.R.drawable.input_bar_bg_normal); } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { edittext_layout.setBackgroundResource(cn.gen.superwechat.R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { btnMore.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { btnMore.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(cn.gen.superwechat.R.id.chat_swipe_layout); swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { adapter.notifyDataSetChanged(); adapter.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(ChatActivity.this, getResources().getString(cn.gen.superwechat.R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 1000); } }); }
From source file:com.igo.SpeechReco.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Set default username is anonymous. mUsername = ANONYMOUS;/*from ww w . ja va2s . 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(); // Initialize ProgressBar and RecyclerView. mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setStackFromEnd(true); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); // New child entries mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference(); mFirebaseAdapter = new FirebaseRecyclerAdapter<FriendlyMessage, RecyclerView.ViewHolder>( FriendlyMessage.class, R.layout.item_message_left, RecyclerView.ViewHolder.class, mFirebaseDatabaseReference.child(MESSAGES_CHILD)) { @Override protected void populateViewHolder(final RecyclerView.ViewHolder viewHolder, final FriendlyMessage friendlyMessage, int position) { mProgressBar.setVisibility(ProgressBar.INVISIBLE); if (friendlyMessage.getName().equals(mUsername)) { MessageViewHolderRight viewHolderR = (MessageViewHolderRight) viewHolder; viewHolderR.messageTextView.setText(friendlyMessage.getText()); viewHolderR.messengerTextView.setText(friendlyMessage.getName()); if (friendlyMessage.getPhotoUrl() == null) { viewHolderR.messengerImageView.setImageDrawable(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_account_circle_black_36dp)); } else { Glide.with(MainActivity.this).load(friendlyMessage.getPhotoUrl()) .into(viewHolderR.messengerImageView); } } else { MessageViewHolderLeft viewHolderL = (MessageViewHolderLeft) viewHolder; viewHolderL.messageTextView.setText(friendlyMessage.getText()); viewHolderL.messengerTextView.setText(friendlyMessage.getName()); if (friendlyMessage.getPhotoUrl() == null) { viewHolderL.messengerImageView.setImageDrawable(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_account_circle_black_36dp)); } else { Glide.with(MainActivity.this).load(friendlyMessage.getPhotoUrl()) .into(viewHolderL.messengerImageView); } } } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { switch (viewType) { case 1: View userType1 = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_left, parent, false); return new MessageViewHolderLeft(userType1); case 2: View userType2 = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_right, parent, false); return new MessageViewHolderRight(userType2); } return super.onCreateViewHolder(parent, viewType); } @Override public int getItemViewType(int position) { FriendlyMessage user = getItem(position); if (user.getName().equals(mUsername)) { return 2; } else { return 1; } } }; 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); 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(""); } }); //******************************************************************************** Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar); setSupportActionBar(myToolbar); /*tts=new TextToSpeech(MainActivity.this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { // TODO Auto-generated method stub if(status == TextToSpeech.SUCCESS){ int result=tts.setLanguage(new Locale("es", "ES")); if(result==TextToSpeech.LANG_MISSING_DATA || result==TextToSpeech.LANG_NOT_SUPPORTED){ Log.e("error", "This Language is not supported"); } else{ ConvertTextToSpeech(); } } else Log.e("error", "Initilization Failed!"); } });*/ //buttonSend = (Button) findViewById(R.id.send); //listView = (ListView) findViewById(R.id.msgview); //chatArrayAdapter = new ChatArrayAdapter(getApplicationContext(), R.layout.right); //listView.setAdapter(chatArrayAdapter); /*chatText = (EditText) findViewById(R.id.msg); chatText.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { ConvertTextToSpeech(); return sendChatMessage(false, chatText.getText().toString()); } return false; } }); buttonSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { ConvertTextToSpeech(); sendChatMessage(false, chatText.getText().toString()); } });*/ //listView.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL); //listView.setAdapter(chatArrayAdapter); //to scroll the list view to bottom on data change /*chatArrayAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); listView.setSelection(chatArrayAdapter.getCount() - 1); } });*/ //this._logText = (EditText) findViewById(R.id.editText1); //this._radioGroup = (RadioGroup)findViewById(R.id.groupMode); //this._buttonSelectMode = (Button)findViewById(R.id.buttonSelectMode); this._startButton = (Button) findViewById(R.id.button1); if (getString(R.string.primaryKey).startsWith("Please")) { new AlertDialog.Builder(this).setTitle(getString(R.string.add_subscription_key_tip_title)) .setMessage(getString(R.string.add_subscription_key_tip)).setCancelable(false).show(); } // setup the buttons final MainActivity This = this; this._startButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { This.StartButton_Click(arg0); } }); /*this._buttonSelectMode.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { This.ShowMenu(This._radioGroup.getVisibility() == View.INVISIBLE); } });*/ /*this._radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup rGroup, int checkedId) { This.RadioButton_Click(rGroup, checkedId); } });*/ //this.ShowMenu(true); }
From source file:com.fa.mastodon.activity.ComposeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); ButterKnife.bind(this); // Setup the toolbar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w w w. jav a 2s . c om ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(null); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); actionBar.setHomeAsUpIndicator(closeIcon); } // Setup the interface buttons. floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSendClicked(); } }); pickBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onMediaPick(); } }); takeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCameraApp(); } }); nsfwBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleNsfw(); } }); visibilityBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showComposeOptions(); } }); /* Initialise all the state, or restore it from a previous run, to determine a "starting" * state. */ SharedPreferences preferences = getPrivatePreferences(); String startingVisibility; boolean startingHideText; String startingContentWarning = null; ArrayList<SavedQueuedMedia> savedMediaQueued = null; if (savedInstanceState != null) { showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive"); startingVisibility = savedInstanceState.getString("statusVisibility"); statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive"); startingHideText = savedInstanceState.getBoolean("statusHideText"); // Keep these until everything needed to put them in the queue is finished initializing. savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued"); // These are for restoring an in-progress commit content operation. InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat .wrap(savedInstanceState.getParcelable("commitContentInputContentInfo")); int previousFlags = savedInstanceState.getInt("commitContentFlags"); if (previousInputContentInfo != null) { onCommitContentInternal(previousInputContentInfo, previousFlags); } } else { showMarkSensitive = false; startingVisibility = preferences.getString("rememberedVisibility", "public"); statusMarkSensitive = false; startingHideText = false; } /* If the composer is started up as a reply to another post, override the "starting" state * based on what the intent from the reply request passes. */ Intent intent = getIntent(); String[] mentionedUsernames = null; inReplyToId = null; if (intent != null) { inReplyToId = intent.getStringExtra("in_reply_to_id"); String replyVisibility = intent.getStringExtra("reply_visibility"); if (replyVisibility != null && startingVisibility != null) { // Lowest possible visibility setting in response if (startingVisibility.equals("private") || replyVisibility.equals("private")) { startingVisibility = "private"; } else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) { startingVisibility = "unlisted"; } else { startingVisibility = replyVisibility; } } mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames"); if (inReplyToId != null) { startingHideText = !intent.getStringExtra("content_warning").equals(""); if (startingHideText) { startingContentWarning = intent.getStringExtra("content_warning"); } } } /* If the currently logged in account is locked, its posts should default to private. This * should override even the reply settings, so this must be done after those are set up. */ if (preferences.getBoolean("loggedInAccountLocked", false)) { startingVisibility = "private"; } // After the starting state is finalised, the interface can be set to reflect this state. setStatusVisibility(startingVisibility); postProgress.setVisibility(View.INVISIBLE); updateNsfwButtonColor(); // Setup the main text field. setEditTextMimeTypes(null); // new String[] { "image/gif", "image/webp" } final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); SpanUtils.highlightSpans(textEditor.getText(), mentionColour); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateVisibleCharactersLeft(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { SpanUtils.highlightSpans(editable, mentionColour); } }); // Add any mentions to the text field when a reply is first composed. if (mentionedUsernames != null) { StringBuilder builder = new StringBuilder(); for (String name : mentionedUsernames) { builder.append('@'); builder.append(name); builder.append(' '); } textEditor.setText(builder); textEditor.setSelection(textEditor.length()); } // Initialise the content warning editor. contentWarningEditor.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) { updateVisibleCharactersLeft(); } @Override public void afterTextChanged(Editable s) { } }); showContentWarning(startingHideText); if (startingContentWarning != null) { contentWarningEditor.setText(startingContentWarning); } // Initialise the empty media queue state. mediaQueued = new ArrayList<>(); waitForMediaLatch = new CountUpDownLatch(); statusAlreadyInFlight = false; // These can only be added after everything affected by the media queue is initialized. if (savedMediaQueued != null) { for (SavedQueuedMedia item : savedMediaQueued) { addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize); } } else if (intent != null && savedInstanceState == null) { /* Get incoming images being sent through a share action from another app. Only do this * when savedInstanceState is null, otherwise both the images from the intent and the * instance state will be re-queued. */ String type = intent.getType(); if (type != null) { if (type.startsWith("image/")) { List<Uri> uriList = new ArrayList<>(); switch (intent.getAction()) { case Intent.ACTION_SEND: { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { uriList.add(uri); } break; } case Intent.ACTION_SEND_MULTIPLE: { ArrayList<Uri> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (list != null) { for (Uri uri : list) { if (uri != null) { uriList.add(uri); } } } break; } } for (Uri uri : uriList) { long mediaSize = getMediaSize(getContentResolver(), uri); pickMedia(uri, mediaSize); } } else if (type.equals("text/plain")) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_SEND)) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); if (text != null) { int start = Math.max(textEditor.getSelectionStart(), 0); int end = Math.max(textEditor.getSelectionEnd(), 0); int left = Math.min(start, end); int right = Math.max(start, end); textEditor.getText().replace(left, right, text, 0, text.length()); } } } } } }
From source file:android.support.design.widget.TextInputLayout.java
private void setEditText(EditText editText) { // If we already have an EditText, throw an exception if (mEditText != null) { throw new IllegalArgumentException("We already have an EditText, can only have one"); }// ww w . j a v a2 s . c om if (!(editText instanceof TextInputEditText)) { Log.i(LOG_TAG, "EditText added is not a TextInputEditText. Please switch to using that" + " class instead."); } mEditText = editText; final boolean hasPasswordTransformation = hasPasswordTransformation(); // Use the EditText's typeface, and it's text size for our expanded text if (!hasPasswordTransformation) { // We don't want a monospace font just because we have a password field mCollapsingTextHelper.setTypefaces(mEditText.getTypeface()); } mCollapsingTextHelper.setExpandedTextSize(mEditText.getTextSize()); final int editTextGravity = mEditText.getGravity(); mCollapsingTextHelper .setCollapsedTextGravity(Gravity.TOP | (editTextGravity & ~Gravity.VERTICAL_GRAVITY_MASK)); mCollapsingTextHelper.setExpandedTextGravity(editTextGravity); // Add a TextWatcher so that we know when the text input has changed mEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { updateLabelState(!mRestoringSavedState); if (mCounterEnabled) { updateCounter(s.length()); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // Use the EditText's hint colors if we don't have one set if (mDefaultTextColor == null) { mDefaultTextColor = mEditText.getHintTextColors(); } // If we do not have a valid hint, try and retrieve it from the EditText, if enabled if (mHintEnabled && TextUtils.isEmpty(mHint)) { setHint(mEditText.getHint()); // Clear the EditText's hint as we will display it ourselves mEditText.setHint(null); } if (mCounterView != null) { updateCounter(mEditText.getText().length()); } if (mIndicatorArea != null) { adjustIndicatorPadding(); } updatePasswordToggleView(); // Update the label visibility with no animation, but force a state change updateLabelState(false, true); }
From source file:cn.scujcc.bug.bitcoinplatformandroid.fragment.BuyAndSellFragment.java
@Nullable @Override/*from w ww . j a va2 s .co m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_actualtransactionbuyandsell, container, false); mButton = (Button) view.findViewById(R.id.fragment_ats_buy_button); mSpinner = (Spinner) view.findViewById(R.id.fragment_actualtransactionbuy_mode); mCountEdit = (TextInputEditText) view.findViewById(R.id.fragment_actualtransactionbuy_count); mUnivalentEdit = (TextInputEditText) view.findViewById(R.id.fragment_actualtransactionbuy_univalent); mCNYTextView = (TextView) view.findViewById(R.id.fragment_ats_buy_account_cnycount); mBTCTextView = (TextView) view.findViewById(R.id.fragment_ats_buy_account_btccount); mFreezedCNYTextView = (TextView) view.findViewById(R.id.fragment_ats_buy_account_freezed_cnycount); mFreezedBTCTextView = (TextView) view.findViewById(R.id.fragment_ats_buy_account_freezed_btccount); //? if (isSell) { //? mButton.setText(R.string.fragment_actualtransactionbuy_sell); } else { // mButton.setText(R.string.fragment_actualtransactionbuy_buy); } mUnivalentEdit.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) { Log.e(TAG, "afterTextChanged" + s); if (s.toString().trim().length() == 0 || s.toString().equals("?")) return; if (!isDecimal(s.toString())) { mUnivalentEdit.setError("???"); } else { double d = Double.parseDouble(s.toString()); if (d < 0.01) { mUnivalentEdit.setError("?0.01"); } } } }); mCountEdit.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 (s.toString().trim().length() == 0 || s.toString().equals("?")) return; if (!isDecimal(s.toString())) { mCountEdit.setError("???"); } else { double d = Double.parseDouble(s.toString()); if (d < 0.01) { mCountEdit.setError("?0.01"); } } } }); isLimit = true; mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { //? isLimit = true; if (isSell) { mUnivalentEdit.setText(""); mUnivalentEdit.setEnabled(true); } else { mCountEdit.setText(""); mCountEdit.setEnabled(true); } } else if (position == 1) { //? isLimit = false; if (isSell) { mUnivalentEdit.setText("?"); mUnivalentEdit.setEnabled(false); } else { mCountEdit.setText("?"); mCountEdit.setEnabled(false); } } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //??? double count = 0; double univalent = 0; /* * 3?, * 1?? * 2,?? * 3?,?? */ Log.e(TAG, "isLimit" + isLimit + "isSell" + isSell); try { if (isLimit) { count = Double.parseDouble(mCountEdit.getText().toString()); univalent = Double.parseDouble(mUnivalentEdit.getText().toString()); if (count < 0.01 || univalent < 0.01) { Toast.makeText(getActivity(), "?0.01", Toast.LENGTH_SHORT).show(); return; } } else if (!isSell) { univalent = Double.parseDouble(mUnivalentEdit.getText().toString()); if (univalent < 0.01) { Toast.makeText(getActivity(), "?0.01", Toast.LENGTH_SHORT).show(); return; } } else if (isSell) { count = Double.parseDouble(mCountEdit.getText().toString()); if (count < 0.01) { Toast.makeText(getActivity(), "?0.01", Toast.LENGTH_SHORT).show(); return; } } } catch (Exception e) { Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT).show(); return; } //?? mDialog = new ProgressDialog(getActivity()); mDialog.setMessage("?,??"); mDialog.setCanceledOnTouchOutside(false); mDialog.setCancelable(false); mDialog.show(); //URL? String type = ""; String price = univalent + ""; String amount = count + ""; if (isSell && isLimit) { //? ? type = "sell"; } else if (isSell && !isLimit) { //? type = "sell_market"; price = ""; } else if (!isSell && isLimit) { // ? type = "buy"; } else if (!isSell && !isLimit) { // type = "buy_market"; amount = ""; } RequestParameter parameter1 = new RequestParameter("api_key", SecurityConfig.USD_ACCESS_KEY); RequestParameter parameter2 = new RequestParameter("secret_key", SecurityConfig.USD_SECRET_KEY); RequestParameter parameter3 = new RequestParameter("type", type); RequestParameter parameter4 = new RequestParameter("price", price); RequestParameter parameter5 = new RequestParameter("amount", amount); List<RequestParameter> list = new ArrayList<>(); list.add(parameter1); list.add(parameter2); list.add(parameter3); list.add(parameter4); list.add(parameter5); // BuyOrSellAsyncTask task = new BuyOrSellAsyncTask(); task.execute(list); } }); //?? updateBalance(); //? return view; }
From source file:ca.etsmtl.applets.etsmobile.ProfileActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.student_profile); handler = new ProfileHandler(this); handlerBandwith = new BandwithHandler(this); btnLogin = (Button) findViewById(R.id.profile_login_btn); btnLogin.setOnClickListener(this); // nav bar// w w w. j av a 2 s. c om navBar = (NavBar) findViewById(R.id.navBar1); navBar.setTitle(R.drawable.navbar_profil_title); navBar.hideRightButton(); navBar.hideLoading(); name = (TextView) findViewById(R.id.student_profile_name); lastname = (TextView) findViewById(R.id.student_profile_lastname); solde = (TextView) findViewById(R.id.student_profile_solde); codeP = (TextView) findViewById(R.id.student_profile_codePermanent); progess = (ProgressBar) findViewById(R.id.bandwith_progress); bandwith_used = (TextView) findViewById(R.id.bandwith_used_lbl); bandwith_max = (TextView) findViewById(R.id.bandwith_max); phase_input = (TextView) findViewById(R.id.bandwith_phase_input); credits_done = (TextView) findViewById(R.id.student_profile_credit_done); credit_failed = (TextView) findViewById(R.id.student_profile_credits_failed); credits_now = (TextView) findViewById(R.id.student_profile_credits_now); programme = (TextView) findViewById(R.id.student_profile_programme); moyenne = (TextView) findViewById(R.id.student_profile_moy); phase_input.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.length() >= 1) { if (appt_input.getText().length() > 4) { getBandwith(s.toString(), appt_input.getText().toString()); } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); appt_input = (TextView) findViewById(R.id.bandwith_appt_input); appt_input.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.length() >= 3) { if (phase_input.getText().length() >= 1) { getBandwith(phase_input.getText().toString(), s.toString()); } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); prefs = PreferenceManager.getDefaultSharedPreferences(this); creds = new UserCredentials(prefs); if (creds.hasBandwithInfo()) { phase_input.setText(creds.getPhase()); appt_input.setText(creds.getAppt()); } doLogin(); }
From source file:com.hanyu.desheng.activity.ChatActivity.java
/** * initView/*from w ww.j ava2 s.c o m*/ */ protected void initView() { recordingContainer = findViewById(R.id.recording_container); micImage = (ImageView) findViewById(R.id.mic_image); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); activity_tv_right = (RelativeLayout) findViewById(R.id.activity_tv_right); buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice); buttonSend = findViewById(R.id.btn_send); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(R.id.vPager); emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container); locationImgview = (ImageView) findViewById(R.id.btn_location); iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal); iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); btnMore = (Button) findViewById(R.id.btn_more); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(R.id.more); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); // ?, micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01), getResources().getDrawable(R.drawable.record_animate_02), getResources().getDrawable(R.drawable.record_animate_03), getResources().getDrawable(R.drawable.record_animate_04), getResources().getDrawable(R.drawable.record_animate_05), getResources().getDrawable(R.drawable.record_animate_06), getResources().getDrawable(R.drawable.record_animate_07), getResources().getDrawable(R.drawable.record_animate_08), getResources().getDrawable(R.drawable.record_animate_09), getResources().getDrawable(R.drawable.record_animate_10), getResources().getDrawable(R.drawable.record_animate_11), getResources().getDrawable(R.drawable.record_animate_12), getResources().getDrawable(R.drawable.record_animate_13), getResources().getDrawable(R.drawable.record_animate_14), }; // list reslist = getExpressionRes(35); // ?viewpager List<View> views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); views.add(gv1); views.add(gv2); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { btnMore.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { btnMore.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); }