Example usage for android.text TextWatcher TextWatcher

List of usage examples for android.text TextWatcher TextWatcher

Introduction

In this page you can find the example usage for android.text TextWatcher TextWatcher.

Prototype

TextWatcher

Source Link

Usage

From source file:com.application.akscorp.yandextranslator2017.TranslateScreen.java

/**
 * Create custom edittext with right button and Runnable action
 *///from  w w  w  .  j  a  v  a2s. c  om
private void EditTextControl() {
    editTextInputFrazeForTranslate.defineButton(
            new MyPair<Drawable, Runnable>().mp(ResourcesCompat.getDrawable(getActivity().getResources(),
                    R.drawable.ic_volume_up_blue_grey_300_36dp, null), Speech()),
            new MyPair<Drawable, Runnable>().mp(ResourcesCompat.getDrawable(getActivity().getResources(),
                    R.drawable.ic_mic_blue_grey_300_36dp, null), Record()),
            new MyPair<Drawable, Runnable>().mp(ResourcesCompat.getDrawable(getActivity().getResources(),
                    R.drawable.ic_close_blue_grey_300_36dp, null), Clear()));

    editTextInputFrazeForTranslate.getEditText().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) {

        }

        private Timer timer = new Timer();
        private final long DELAY = 1300;

        @Override
        public void afterTextChanged(Editable s) {
            timer.cancel();
            timer = new Timer();
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    if (IsTranslateEnable && myApp.AUTOTRANSLATE_ENABLE) {
                        IsTranslateEnable = false;
                        TranslateWork();

                    }
                }
            }, DELAY);
        }
    });
}

From source file:com.gongpingjia.carplay.activity.chat.ChatActivity.java

/**
 * initView// ww  w. jav a2  s.  c o  m
 */
public void initView() {
    setRightAction(null, R.drawable.icon_group_member, new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent it = new Intent(self, ActiveInformationActivity.class);
            it.putExtra("activityId", activiyId);
            it.putExtra("groupId", toChatUsername);
            startActivity(it);
        }
    });
    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 = (LinearLayout) 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.edit_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:com.fullteem.yueba.app.ui.ChatActivity.java

/**
 * initView//w ww.j  a  va  2 s . c o  m
 */
protected void initView() {

    // ?more
    viewBtnMore = findViewById(R.id.viewMore);
    viewBtnMore.setOnClickListener(this);
    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);

    // ?,
    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.gsma.rcs.ri.messaging.GroupTalkView.java

private void initialize() throws RcsServiceNotAvailableException, RcsGenericException {
    Button sendButton = (Button) findViewById(R.id.send_button);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override// w ww.ja  v  a2 s  . com
        public void onClick(View v) {
            sendText();
        }
    });
    mHandler = new Handler();
    mChatListener = new GroupChatListener() {

        @Override
        public void onMessageStatusChanged(String chatId, String mimeType, String msgId, Content.Status status,
                Content.ReasonCode reasonCode) {
            if (LogUtils.isActive) {
                Log.i(LOGTAG, "onMessageStatusChanged chatId=" + chatId + " mime-type=" + mimeType + " msgId="
                        + msgId + " status=" + status + " reason=" + reasonCode);
            }
        }

        // Callback called when an Is-composing event has been received
        public void onComposingEvent(String chatId, ContactId contact, boolean status) {
            // Discard event if not for current chatId
            if (!chatId.equals(mChatId)) {
                return;
            }
            displayComposingEvent(contact, status);
        }

        @Override
        public void onParticipantStatusChanged(String chatId, ContactId contact, ParticipantStatus status) {
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "onParticipantStatusChanged chatId=" + chatId + " contact=" + contact + " status="
                        + status);
            }
        }

        @Override
        public void onMessageGroupDeliveryInfoChanged(String chatId, ContactId contact, String mimeType,
                String msgId, GroupDeliveryInfo.Status status, GroupDeliveryInfo.ReasonCode reasonCode) {
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "onMessageGroupDeliveryInfoChanged chatId=" + chatId + " contact=" + contact
                        + " msgId=" + msgId + " status=" + status + " reason=" + reasonCode);
            }
        }

        @Override
        public void onStateChanged(String chatId, final GroupChat.State state,
                GroupChat.ReasonCode reasonCode) {
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "onStateChanged chatId=" + chatId + " state=" + state + " reason=" + reasonCode);
            }
            /* Discard event if not for current chatId */
            if (mChatId == null || !mChatId.equals(chatId)) {
                return;
            }
            final String _reasonCode = RiApplication.sGroupChatReasonCodes[reasonCode.toInt()];
            mHandler.post(new Runnable() {
                public void run() {
                    switch (state) {
                    case STARTED:
                        break;

                    case ABORTED:
                        showMessageThenExit(getString(R.string.label_chat_aborted, _reasonCode));
                        break;

                    case REJECTED:
                        showMessageThenExit(getString(R.string.label_chat_rejected, _reasonCode));
                        break;

                    case FAILED:
                        showMessageThenExit(getString(R.string.label_chat_failed, _reasonCode));
                        break;

                    default:
                    }
                }
            });
        }

        @Override
        public void onDeleted(Set<String> chatIds) {
            if (LogUtils.isActive) {
                Log.i(LOGTAG, "onDeleted chatIds=".concat(Arrays.toString(chatIds.toArray())));
            }
        }

        @Override
        public void onMessagesDeleted(String chatId, Set<String> msgIds) {
            if (LogUtils.isActive) {
                Log.i(LOGTAG,
                        "onMessagesDeleted chatId=" + chatId + " msgIds=" + Arrays.toString(msgIds.toArray()));
            }
        }

    };
    mFileTransferListener = new GroupFileTransferListener() {
        @Override
        public void onStateChanged(String chatId, String transferId, FileTransfer.State state,
                FileTransfer.ReasonCode reasonCode) {
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "onStateChanged chatId=" + chatId + " transferId=" + transferId + " state="
                        + state + " reason=" + reasonCode);
            }
            /* Discard event if not for current chatId */
            if (mChatId == null || !mChatId.equals(chatId)) {
                return;
            }
            if (FileTransfer.State.TRANSFERRED == state) {
                try {
                    FileTransfer fileTransfer = mFileTransferService.getFileTransfer(transferId);
                    if (fileTransfer == null) {
                        return;
                    }
                    if (Utils.isAudioType(fileTransfer.getMimeType())
                            && FileTransfer.Disposition.RENDER == fileTransfer.getDisposition()) {
                        Utils.playAudio(GroupTalkView.this, fileTransfer.getFile());
                        mFileTransferService.markFileTransferAsRead(transferId);
                    }
                } catch (RcsPersistentStorageException | RcsServiceNotAvailableException
                        | RcsGenericException e) {
                    showException(e);
                }
            }
        }

        @Override
        public void onDeliveryInfoChanged(String chatId, ContactId contact, String transferId,
                GroupDeliveryInfo.Status status, GroupDeliveryInfo.ReasonCode reasonCode) {
        }

        @Override
        public void onProgressUpdate(String chatId, String transferId, long currentSize, long totalSize) {
        }

        @Override
        public void onDeleted(String chatId, Set<String> transferIds) {
        }

    };
    mChatService = getChatApi();
    mFileTransferService = getFileTransferApi();

    HistoryUriBuilder uriBuilder = new HistoryUriBuilder(HistoryLog.CONTENT_URI);
    uriBuilder.appendProvider(ChatLog.Message.HISTORYLOG_MEMBER_ID);
    uriBuilder.appendProvider(FileTransferLog.HISTORYLOG_MEMBER_ID);
    mUriHistoryProvider = uriBuilder.build();

    mComposeText = (EditText) findViewById(R.id.userText);
    ChatServiceConfiguration configuration = mChatService.getConfiguration();
    // Set max label length
    int maxMsgLength = configuration.getGroupChatMessageMaxLength();
    if (maxMsgLength > 0) {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(maxMsgLength);
        mComposeText.setFilters(filterArray);
    }
    mComposingManager = new IsComposingManager(configuration.getIsComposingTimeout(), getNotifyComposing());
    mComposeText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // Check if the text is not null.
            // we do not wish to consider putting the edit text back to null
            // (like when sending message), is having activity
            if (!TextUtils.isEmpty(s)) {
                // Warn the composing manager that we have some activity
                if (mComposingManager != null) {
                    mComposingManager.hasActivity();
                }
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mAdapter = new TalkCursorAdapter(this, false, mChatService, mFileTransferService);
    ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setAdapter(mAdapter);
    registerForContextMenu(listView);
}

From source file:com.paic.zhifu.wallet.activity.modules.register.PhoneValidationActivity.java

@Override
public void initObserver() {

    listener = new ITaskExpandListener() {

        @Override//from  w w  w  .j  ava 2s  .  c  om
        public <T> void onTaskCompleted(int resultCode, final T result, int connId) {

            switch (connId) {
            case HttpConstants.CONNECTIONID_CHECK_REGISTER_SMS_CODE:

                /***/
                AutoTrackUtil.getInstance().sendLog(PhoneValidationActivity.this, "register", "confirmCodeRsp",
                        resultCode + "");

                if (HttpConstants.RESPONSE_CODE_1000 == resultCode) {
                    jump(StaticVariableTool.ACTIVITY_UPLOADAVATAR);
                } else {
                    ToastShow(StaticVariableTool.getResultMsg(result.toString()));
                }
            case HttpConstants.CONNECTIONID_SMSCODE:
                if (HttpConstants.RESPONSE_CODE_1000 == resultCode) {
                    phoneNumLastSend = phoneNum;
                } else if (HttpConstants.RESPONSE_CODE_1026 == resultCode) {
                    loginId = phoneNum;
                    PhoneValidationActivity.this.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            showLoginDialog();

                        }
                    });
                } else {
                    ToastShow(StaticVariableTool.getResultMsg(result.toString()));
                }

                /***/
                AutoTrackUtil.getInstance().sendLog(PhoneValidationActivity.this, "register", "getCodeRsp",
                        resultCode + "");
                break;
            case HttpConstants.CONNECTIONID_MOACCESS:
                if (HttpConstants.RESPONSE_CODE_1000 == resultCode) {
                    JSONObject object;
                    try {
                        object = new JSONObject(result.toString());
                        moAccessNumber = (String) object.get("moAccessNumber");
                        moPrefix = (String) object.get("moPrefix");
                        /*String buff=new StringBuffer(moPrefix).append(StaticVariableTool.getIMEI(MyApp.getContext())).toString();*/
                        String buff = moPrefix + StaticVariableTool.getIMEI(MyApp.getContext());
                        Log.d("buff", buff + "===========" + moAccessNumber);
                        //sendSMS(moAccessNumber, buff);

                        //????                     
                        phonetypedata.put("clientId", StaticVariableTool.getIMEI(MyApp.getContext()));
                        phonetypedata.put("operationType", StaticVariableTool.OP_REGISTER_QUERY_PHONE_NUMBER);
                        phonetypedata.put("sessionId", StaticVariableTool.getIMEI(MyApp.getContext()));
                        smsControl(phonetypedata);

                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                } else {
                    dismissNoBackProgress();
                    ToastShow(getStringStr(R.string.toast_neterro));
                }
                break;
            case HttpConstants.CONNECTIONID_QUERYPHONENUM:
                JSONObject json;
                try {
                    json = new JSONObject(result.toString());
                    switch (resultCode) {
                    case 1000:
                        ISSMS = true;
                        dismissNoBackProgress();
                        loginId = (String) json.get("mobilePhoneNum");
                        jump(StaticVariableTool.ACTIVITY_UPLOADAVATAR);
                        break;
                    case 1026:
                        ISSMS = true;
                        dismissNoBackProgress();
                        loginId = (String) json.get("mobilePhoneNum");
                        PhoneValidationActivity.this.runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                showLoginDialog();

                            }
                        });
                        break;
                    case 1020:
                        if (progressDialog.isShowing()) {
                            if (LOOP_FLAG) {
                                smsControl(phonetypedata);
                            } else {
                                dismissNoBackProgress();
                                ToastShow(getStringStr(R.string.network_timeout));
                            }
                        }
                        break;
                    default:
                        PhoneValidationActivity.this.runOnUiThread(new Runnable() {
                            public void run() {
                                dismissNoBackProgress();
                                ToastShow(StaticVariableTool.getResultMsg(result.toString()));
                            }
                        });
                        break;
                    }
                    /*if(HttpConstants.RESPONSE_CODE_1000== resultCode){   
                       progressDialog.cancel();
                       loginId=(String) json.get("mobilePhoneNum");
                       jump(StaticVariableTool.ACTIVITY_UPLOADAVATAR);
                       return;
                    }else if(1026==resultCode){
                       progressDialog.cancel();
                       showLoginDialog();
                       return;
                    }else if(progressDialog.isShowing()){
                       smsControl(phonetypedata);
                       return;
                    }*/
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                break;
            }

        }

        @Override
        public void onTaskError(int resultCode, int conId, String msg) {
            LOOP_FLAG = true;
            dismissNoBackProgress();
            ToastShow(msg);
        }

        @Override
        public void onTaskCanceled() {
            // TODO Auto-generated method stub

        }
    };
    sendcaptcha_btn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (isSendVaildate)
                return;

            if (!canSendSms)
                return;
            captcha_edt.setEnabled(true);
            captcha_edt.requestFocus();
            phoneNum = phoneNum_edt.getText().toString();
            HashMap<String, String> params_data = new HashMap<String, String>();
            params_data.put("clientId", StaticVariableTool.getIMEI(MyApp.getContext()));
            params_data.put("operationType",
                    ServerConnect.getOperationType(HttpConstants.CONNECTIONID_SMSCODE));
            params_data.put("useType", "1");
            params_data.put("phoneNum", phoneNum);
            ServerConnect.getInstance().requestToServer(PhoneValidationActivity.this, listener,
                    HttpConstants.CONNECTIONID_SMSCODE, params_data);
            startCountDown();

            /***/
            AutoTrackUtil.getInstance().sendLog(PhoneValidationActivity.this, "register", "getCodeReq",
                    phoneNum);
        }
    });

    phoneNum_edt.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) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            checkAndChangeNextBtnState();
            // ?
            if (!isSendVaildate) {
                if (!phoneNum_edt.getText().toString().equals(phoneNumLastSend)) {
                    sendcaptcha_btn.setText(getResources().getString(R.string.Button_openpay_smsSend));
                } else {
                    sendcaptcha_btn.setText(getString(R.string.Button_openpay_smsSend_again));
                }
            }
        }
    });

    captcha_edt.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) {
            checkAndChangeNextBtnState();

        }
    });

    checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            checkAndChangeNextBtnState();

        }
    });

    headTitle.setBackPressedListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (FromActivity != null) {
                jump(StaticVariableTool.ACTIVITY_LOGIN);
            } else {
                jump(StaticVariableTool.ACTIVITY_LOGIN3);
            }
        }
    });

    /*checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
               
       @Override
       public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if(flag){
       next.setBackgroundResource(R.drawable.graybtn);
       next.setTextColor(getResources().getColor(R.color.textgray));
       flag=false;
    }else{
       next.setBackgroundResource(R.drawable.normal_btn);
       next.setTextColor(getResources().getColor(R.color.white));
       flag=true;
    }            
       }
    });*/

    next.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!checkPhoneNum()) {
                ToastShow("??");
                return;
            }
            if (phoneNumLastSend == null) {
                ToastShow("????");
                return;
            }
            if (!phoneNumLastSend.equals(phoneNum_edt.getText().toString())) {
                ToastShow("?????????");
                return;
            }
            if (!checkSMSCode()) {
                ToastShow("??6?");
                return;
            }
            if (!checkLicense()) {
                ToastShow(getString(R.string.TextView_activity_openpay2_agreement_str_agree));
                return;
            }

            HashMap<String, String> params = new HashMap<String, String>();
            params.put("clientId", StaticVariableTool.getIMEI(MyApp.getContext()));
            params.put("operationType", "op_check_register_sms_code");
            params.put("phoneNum", phoneNum_edt.getText().toString());
            params.put("smsCode", captcha_edt.getText().toString());
            ServerConnect.getInstance().requestToServer(PhoneValidationActivity.this, listener,
                    HttpConstants.CONNECTIONID_CHECK_REGISTER_SMS_CODE, params);

            /***/
            AutoTrackUtil.getInstance().sendLog(PhoneValidationActivity.this, "register", "confirmCodeReq", "");
            /*
            if(!ISSMS){  //??
               showNoBackProgress(PhoneValidationActivity.this);                  
               smsAction(phonetypedata);
            }else if(telephonyManager.getSimState()==TelephonyManager.SIM_STATE_READY){
               registerdata.put("clientId",  StaticVariableTool.getIMEI(MyApp.getContext()));
               registerdata.put("operationType", StaticVariableTool.OP_QUERY_REG_MO_ACCESS_NUM);
               registerdata.put("sessionId", StaticVariableTool.getIMEI(MyApp.getContext()));
               registerdata.put("plmn", telephonyManager.getSimOperator());
               Log.d("plmn", telephonyManager.getSimOperator());
               showNoBackProgress(PhoneValidationActivity.this);
               ServerConnect.getInstance().requestToServer(PhoneValidationActivity.this, listener, HttpConstants.CONNECTIONID_MOACCESS, registerdata);
            }else{
               ToastShow(getStringStr(R.string.toast_intosim));
            }*/
            //}                     
        }
    });

    agreement.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            jump(StaticVariableTool.ACTIVITY_AGREEMENT);

        }
    });
}

From source file:com.klinker.android.twitter.ui.compose.Compose.java

public void setUpSimilar() {
    attachImage[0] = (ImageView) findViewById(R.id.picture1);
    attachImage[1] = (ImageView) findViewById(R.id.picture2);
    attachImage[2] = (ImageView) findViewById(R.id.picture3);
    attachImage[3] = (ImageView) findViewById(R.id.picture4);
    attachButton = (ImageButton) findViewById(R.id.attach);
    emojiButton = (ImageButton) findViewById(R.id.emoji);
    emojiKeyboard = (EmojiKeyboard) findViewById(R.id.emojiKeyboard);
    reply = (EditText) findViewById(R.id.tweet_content);
    charRemaining = (TextView) findViewById(R.id.char_remaining);

    findViewById(R.id.prompt_pos).setOnClickListener(new View.OnClickListener() {
        @Override/* ww w  . j  av a2s .  c  om*/
        public void onClick(View v) {
            Log.v("talon_input", "clicked the view");
            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(reply,
                    InputMethodManager.SHOW_FORCED);
        }
    });

    NetworkedCacheableImageView pic = (NetworkedCacheableImageView) findViewById(R.id.profile_pic);
    HoloTextView currentName = (HoloTextView) findViewById(R.id.current_name);

    if (settings.roundContactImages) {
        pic.loadImage(settings.myProfilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE);
    } else {
        pic.loadImage(settings.myProfilePicUrl, false, null);
    }
    currentName.setText("@" + settings.myScreenName);

    //numberAttached.setText("0 " + getString(R.string.attached_images));

    charRemaining.setText(140 - reply.getText().length() + "");

    reply.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) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            countHandler.removeCallbacks(getCount);
            countHandler.postDelayed(getCount, 300);
        }
    });
}

From source file:com.commonsware.cwac.crossport.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");
    }/*from w w  w. j  a  v  a 2  s.  co m*/

    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)) {
        // Save the hint so it can be restored on dispatchProvideAutofillStructure();
        mOriginalHint = mEditText.getHint();
        setHint(mOriginalHint);
        // 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:com.klinker.android.twitter.activities.compose.Compose.java

public void setUpSimilar() {
    attachImage[0] = (ImageView) findViewById(R.id.picture1);
    attachImage[1] = (ImageView) findViewById(R.id.picture2);
    attachImage[2] = (ImageView) findViewById(R.id.picture3);
    attachImage[3] = (ImageView) findViewById(R.id.picture4);
    attachButton = (ImageButton) findViewById(R.id.attach);
    gifButton = (ImageButton) findViewById(R.id.gif);
    emojiButton = (ImageButton) findViewById(R.id.emoji);
    emojiKeyboard = (EmojiKeyboard) findViewById(R.id.emojiKeyboard);
    reply = (EditText) findViewById(R.id.tweet_content);
    charRemaining = (TextView) findViewById(R.id.char_remaining);

    findViewById(R.id.prompt_pos).setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  ww  .j  a va  2s .  c  o  m*/
        public void onClick(View v) {
            Log.v("talon_input", "clicked the view");
            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(reply,
                    InputMethodManager.SHOW_FORCED);
        }
    });

    NetworkedCacheableImageView pic = (NetworkedCacheableImageView) findViewById(R.id.profile_pic);
    HoloTextView currentName = (HoloTextView) findViewById(R.id.current_name);

    if (settings.roundContactImages) {
        pic.loadImage(settings.myProfilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE);
    } else {
        pic.loadImage(settings.myProfilePicUrl, false, null);
    }
    currentName.setText("@" + settings.myScreenName);

    //numberAttached.setText("0 " + getString(R.string.attached_images));

    charRemaining.setText(140 - reply.getText().length() + "");

    reply.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) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            countHandler.removeCallbacks(getCount);
            countHandler.postDelayed(getCount, 300);
        }
    });
}

From source file:com.insthub.O2OMobile.Activity.D1_OrderActivity.java

private void showOrderPriceDialog() {
    LayoutInflater inflater = LayoutInflater.from(D1_OrderActivity.this);
    View view = inflater.inflate(R.layout.d1_order_price_dialog, null);
    mPriceDialog = new Dialog(D1_OrderActivity.this, R.style.dialog);
    mPriceDialog.setContentView(view);// w  w  w. jav a 2  s . com
    mPriceDialog.setCanceledOnTouchOutside(false);
    mPriceDialog.show();

    mOrderPriceDialogPrice = (TextView) view.findViewById(R.id.order_price_dialog_price);
    mOrderPriceDialogChangePrice = (EditText) view.findViewById(R.id.order_price_dialog_change_price);
    mOrderPriceDialogOk = (Button) view.findViewById(R.id.order_price_dialog_ok);
    mOrderPriceDialogCancel = (Button) view.findViewById(R.id.order_price_dialog_cancel);

    if (mOrderInfoModel.publicOrder.offer_price != null) {
        mOrderPriceDialogPrice.setText(Utils.formatBalance(mOrderInfoModel.publicOrder.offer_price) + "");
    }

    mOrderPriceDialogChangePrice.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            if (s.toString().length() > 0) {
                if (s.toString().substring(0, 1).equals(".")) {
                    s = s.toString().substring(1, s.length());
                    mOrderPriceDialogChangePrice.setText(s);
                }
            }
            if (s.toString().length() > 1) {
                if (s.toString().substring(0, 1).equals("0")) {
                    if (!s.toString().substring(1, 2).equals(".")) {
                        s = s.toString().substring(1, s.length());
                        mOrderPriceDialogChangePrice.setText(s);
                        CharSequence charSequencePirce = mOrderPriceDialogChangePrice.getText();
                        if (charSequencePirce instanceof Spannable) {
                            Spannable spanText = (Spannable) charSequencePirce;
                            Selection.setSelection(spanText, charSequencePirce.length());
                        }
                    }
                }
            }
            boolean flag = false;
            for (int i = 0; i < s.toString().length() - 1; i++) {
                String getstr = s.toString().substring(i, i + 1);
                if (getstr.equals(".")) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                int i = s.toString().indexOf(".");
                if (s.toString().length() - 3 > i) {
                    String getstr = s.toString().substring(0, i + 3);
                    mOrderPriceDialogChangePrice.setText(getstr);
                    CharSequence charSequencePirce = mOrderPriceDialogChangePrice.getText();
                    if (charSequencePirce instanceof Spannable) {
                        Spannable spanText = (Spannable) charSequencePirce;
                        Selection.setSelection(spanText, charSequencePirce.length());
                    }
                }
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
        }
    });

    mOrderPriceDialogCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mPriceDialog.dismiss();
        }
    });

    mOrderPriceDialogOk.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mOrderInfoModel.done(mOrderId, mOrderPriceDialogChangePrice.getText().toString());
            mPriceDialog.dismiss();
        }
    });

}