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:color.kidpaint.com.kidpaintcolor.dialog.TextToolDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new CustomAlertDialogBuilder(mContext);
    builder.setTitle(R.string.text_tool_dialog_title);
    final View view = inflater.inflate(R.layout.dialog_text_tool, null);

    mTextEditText = (EditText) view.findViewById(R.id.text_tool_dialog_input_text);
    mTextEditText.addTextChangedListener(new TextWatcher() {
        @Override/*from   w  ww  .  j  a  v  a  2s.  c  om*/
        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) {
            String text = mTextEditText.getText().toString();
            mOnTextToolDialogChangedListener.setText(text);
            mText = text;
        }
    });

    mFontSpinner = (Spinner) view.findViewById(R.id.text_tool_dialog_spinner_font);
    ArrayAdapter<CharSequence> fontAdapter = ArrayAdapter.createFromResource(mContext,
            R.array.text_tool_font_array, android.R.layout.simple_spinner_item);
    fontAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mFontSpinner.setAdapter(fontAdapter);

    mFontSpinner.setBackgroundColor(Color.GRAY);
    mFontSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String font = parent.getItemAtPosition(position).toString();
            mOnTextToolDialogChangedListener.setFont(font);
            mFontIndex = position;
            if (mFontSpinnerInitialized)
                hideKeyboard();
            else
                mFontSpinnerInitialized = true;
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    mUnderlinedToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_underlined);
    mUnderlinedToggleButton.setTextOn(Html
            .fromHtml("<u>" + getResources().getString(R.string.text_tool_dialog_underline_shortcut) + "</u>"));
    mUnderlinedToggleButton.setOnClickListener(new ToggleButton.OnClickListener() {
        @Override
        public void onClick(View v) {
            boolean underlined = mUnderlinedToggleButton.isChecked();
            mOnTextToolDialogChangedListener.setUnderlined(underlined);
            mUnderlined = underlined;
            hideKeyboard();
        }
    });

    mItalicToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_italic);
    mItalicToggleButton.setTextOn(Html
            .fromHtml("<i>" + getResources().getString(R.string.text_tool_dialog_italic_shortcut) + "</i>"));
    mItalicToggleButton.setOnClickListener(new ToggleButton.OnClickListener() {
        @Override
        public void onClick(View v) {
            boolean italic = mItalicToggleButton.isChecked();
            mOnTextToolDialogChangedListener.setItalic(italic);
            mItalic = italic;
            hideKeyboard();
        }
    });

    mBoldToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_bold);
    mBoldToggleButton.setTextOn(
            Html.fromHtml("<b>" + getResources().getString(R.string.text_tool_dialog_bold_shortcut) + "</b>"));
    mBoldToggleButton.setOnClickListener(new ToggleButton.OnClickListener() {
        @Override
        public void onClick(View v) {
            boolean bold = mBoldToggleButton.isChecked();
            mOnTextToolDialogChangedListener.setBold(bold);
            mBold = bold;
            hideKeyboard();
        }
    });

    mTextSizeSpinner = (Spinner) view.findViewById(R.id.text_tool_dialog_spinner_text_size);
    ArrayAdapter<CharSequence> textSizeAdapter = ArrayAdapter.createFromResource(mContext,
            R.array.text_tool_size_array, android.R.layout.simple_spinner_item);
    textSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mTextSizeSpinner.setAdapter(textSizeAdapter);

    mTextSizeSpinner.setBackgroundColor(Color.GRAY);
    mTextSizeSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            int size = Integer.parseInt(parent.getItemAtPosition(position).toString());
            mOnTextToolDialogChangedListener.setTextSize(size);
            mTextSizeIndex = position;
            if (mTextSizeSpinnerInitialized)
                hideKeyboard();
            else
                mTextSizeSpinnerInitialized = true;
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    builder.setView(view);
    builder.setNeutralButton(R.string.done, this);

    Dialog textDialog = builder.create();
    WindowManager.LayoutParams window_params = textDialog.getWindow().getAttributes();
    textDialog.getWindow().setDimAmount(0.0f);
    textDialog.getWindow().setAttributes(window_params);

    return textDialog;
}

From source file:com.adkdevelopment.simpleflashlightadfree.ui.MorseFragment.java

@Nullable
@Override/*from   w ww .j  a  va2 s . c  om*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_morse, container, false);

    mUnbinder = ButterKnife.bind(this, rootView);

    // check status and use correct image
    Utility.setSwitchColor(mStatusText, mButtonImage, status);

    mButtonImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Start service on click
            if (status == FlashlightService.STATUS_OFF) {
                status = FlashlightService.STATUS_MORSE;
            } else {
                status = FlashlightService.STATUS_OFF;
            }

            // Set button drawable
            Utility.setSwitchColor(mStatusText, mButtonImage, status);

            startService();
        }
    });

    mMorseInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            beforeChangeMorse = s.toString();
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            morseCode = s.toString();
            mCurrentText.setText(Utility.getMorseMessage(morseCode));

            if (s.length() > 0 || beforeChangeMorse.length() > 0) {
                startService();
            }
        }
    });

    mImageIncrease.setOnClickListener(mSpeedListener);
    mImageDecrease.setOnClickListener(mSpeedListener);
    mTextSpeed.setText(getString(R.string.morse_speed, FlashlightService.getDot()));

    return rootView;
}

From source file:com.ame.armymax.SearchActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);

    context = this;
    DataUser.context = context;/*from ww w .j  a v  a  2  s . com*/
    aq = new AQuery(this);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setTitle("");

    query = getIntent().getStringExtra("query");

    searchBox = (BootstrapEditText) findViewById(R.id.room_name);
    searchBox.setText(query);

    searchButton = (Button) findViewById(R.id.search_button);
    searchButton.setVisibility(View.GONE);

    intent = new Intent(this, ProfileActivity.class);

    searchButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            query = searchBox.getEditableText().toString();

            if (!query.equals("")) {
                String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query
                        + "&startPoint=0&sizePage=50";
                ProgressDialog dialog = new ProgressDialog(context);
                dialog.setIndeterminate(true);
                dialog.setCancelable(true);
                dialog.setInverseBackgroundForced(false);
                dialog.setCanceledOnTouchOutside(true);
                dialog.setTitle("Finding ...");
                Log.e("searchurl", resultUrl);
                newSearch = true;
                aq.progress(dialog).ajax(resultUrl, JSONObject.class, context, "newSearchResultCb");

            }

        }
    });

    searchBox.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            query = searchBox.getEditableText().toString();

            if (!query.equals("")) {
                String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query
                        + "&startPoint=0&sizePage=20";

                ProgressDialog dialog = new ProgressDialog(context);
                dialog.setIndeterminate(true);
                dialog.setCancelable(true);
                dialog.setInverseBackgroundForced(false);
                dialog.setCanceledOnTouchOutside(true);
                dialog.setTitle("Finding ...");
                newSearch = true;
                Log.e("q", query);
                aq.ajax(resultUrl, JSONObject.class, context, "newSearchResultCb");
            }

        }

        @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

        }
    });

    String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query + "&startPoint=0&sizePage=50";
    aq.ajax(resultUrl, JSONObject.class, this, "searchResultCb");

}

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

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.c4_edit_intro);
    mTitle = (TextView) findViewById(R.id.top_view_title);
    mTitle.setText(getString(R.string.edit_brief));
    mBack = (ImageView) findViewById(R.id.top_view_back);
    mBrief = (EditText) findViewById(R.id.et_brief);
    mTextNum = (TextView) findViewById(R.id.text_num);
    mSave = (Button) findViewById(R.id.btn_save);
    mTopViewRightImage = (ImageView) findViewById(R.id.top_view_right_image);
    mTopViewRightImage.setVisibility(View.INVISIBLE);
    mShared = getSharedPreferences(O2OMobileAppConst.USERINFO, 0);
    String userStr = mShared.getString("user", "");
    try {//from   w  ww .j  a  v  a  2  s .c o m
        if (userStr != null) {
            JSONObject userJson = new JSONObject(userStr);
            USER user = new USER();
            user.fromJson(userJson);
            mBrief.setText(user.brief);
            mTextNum.setText(mTotalSize - mBrief.getText().length() + "");
            mBrief.setSelection(user.brief.length());
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    mUserModel = new UserModel(this);
    mUserModel.addResponseListener(this);
    mSave = (Button) findViewById(R.id.btn_save);
    mBack.setOnClickListener(this);
    mSave.setOnClickListener(this);
    //??
    mBrief.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) {
            mTextNum.setText(mTotalSize - mBrief.getText().length() + "");

        }
    });
}

From source file:com.kunze.androidlocaltodo.TaskActivityFragment.java

private void InitializeView(final View rootView) {
    final View activityView = rootView;
    TextWatcher textWatcher = new TextWatcher() {
        @Override//from w  ww  . java  2s .  co  m
        public void afterTextChanged(Editable s) {
        }

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

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            TaskChanged(activityView);
        }
    };
    final EditText nameEdit = (EditText) rootView.findViewById(R.id.task_name_edit);
    final TextView nameStatic = (TextView) rootView.findViewById(R.id.task_name_static);
    nameStatic.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            nameEdit.setVisibility(View.VISIBLE);
            nameStatic.setVisibility(View.INVISIBLE);
        }
    });
    nameEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                nameEdit.setVisibility(View.INVISIBLE);
                nameStatic.setVisibility(View.VISIBLE);
            }
        }
    });
    nameEdit.addTextChangedListener(textWatcher);
    final TextView descriptionEdit = (TextView) rootView.findViewById(R.id.task_description_edit);
    descriptionEdit.addTextChangedListener(textWatcher);

    final TextView dueDateView = (TextView) rootView.findViewById(R.id.due_date_text);
    final DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.due_date_calendar);
    datePicker.init(0, 0, 0, new DatePicker.OnDateChangedListener() {
        @Override
        public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(year, monthOfYear, dayOfMonth, 0, 0, 0);
            SetFriendlyDueDateText(dueDateView, calendar);
            TaskChanged(activityView);
        }
    });

    Button todayButton = (Button) rootView.findViewById(R.id.today_button);
    todayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            datePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
                    now.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, now);
        }
    });
    Button plusDayButton = (Button) rootView.findViewById(R.id.plus_day_button);
    plusDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
            calendar.add(Calendar.DATE, 1);
            datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, calendar);
        }
    });
    Button thisWeekendButton = (Button) rootView.findViewById(R.id.this_weekend_button);
    thisWeekendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar weekend = Calendar.getInstance();
            while (weekend.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                weekend.add(Calendar.DATE, 1);
            }
            datePicker.updateDate(weekend.get(Calendar.YEAR), weekend.get(Calendar.MONTH),
                    weekend.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, weekend);
        }
    });
    Button plusWeekButton = (Button) rootView.findViewById(R.id.plus_week_button);
    plusWeekButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
            calendar.add(Calendar.DATE, 7);
            datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, calendar);
        }
    });

    final CheckBox repeatCheck = (CheckBox) rootView.findViewById(R.id.repeat);
    repeatCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            View dialog = (View) buttonView.getParent();
            SetRepeatVisibility(dialog, isChecked);
            TaskChanged(activityView);
        }
    });

    final EditText repeatTimeEdit = (EditText) rootView.findViewById(R.id.repeat_time);
    repeatTimeEdit.addTextChangedListener(textWatcher);

    final Spinner repeatUnitSpinner = (Spinner) rootView.findViewById(R.id.repeat_unit);
    String[] repeatUnits = { "Days", "Weeks", "Months", "Years" };
    repeatUnitSpinner.setAdapter(
            new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, repeatUnits));
    repeatUnitSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (mRow != -1 && mRow != id) {
                TaskChanged(activityView);
            }
            mRow = id;
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            TaskChanged(activityView);
        }

        private long mRow = -1;
    });

    final RadioButton repeatFromComplete = (RadioButton) rootView.findViewById(R.id.repeat_from_complete);
    final RadioButton repeatFromDue = (RadioButton) rootView.findViewById(R.id.repeat_from_due);
    Button revertButton = (Button) rootView.findViewById(R.id.revert_button);
    Button acceptButton = (Button) rootView.findViewById(R.id.accept_button);
    final Button doneButton = (Button) rootView.findViewById(R.id.done_button);
    Button deleteButton = (Button) rootView.findViewById(R.id.delete_button);
    revertButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNewTask = new Task(mOriginalTask);
            mProgrammaticChange = true;
            InitializeViewFields(activityView, mOriginalTask);
            mProgrammaticChange = false;
            TaskReverted(activityView);
        }
    });
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(doneButton.getContext());
            builder.setTitle("Done?");
            builder.setMessage("Mark task \"" + mNewTask.mName + "\" as done?");
            builder.setNegativeButton("No", null);
            builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mNewTask.Done();
                    TaskDatabase db = new TaskDatabase(getActivity());
                    db.SaveTask(mNewTask);
                    InitializeViewFields(rootView, mNewTask);
                }
            });
            builder.show();
        }
    });
}

From source file:com.layer.atlas.AtlasMessageComposer.java

/**
 * Prepares this AtlasMessageComposer for use.
 *
 * @return this AtlasMessageComposer.//  w  w w . j ava  2s  . c o  m
 */
public AtlasMessageComposer init(LayerClient layerClient, ParticipantProvider participantProvider) {
    LayoutInflater.from(getContext()).inflate(R.layout.atlas_message_composer, this);

    mLayerClient = layerClient;
    mParticipantProvider = participantProvider;

    mAttachButton = (ImageView) findViewById(R.id.attachment);
    mAttachButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mAttachmentMenu.isShowing()) {
                mAttachmentMenu.dismiss();
            } else {
                LinearLayout menu = (LinearLayout) mAttachmentMenu.getContentView();
                menu.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                        MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
                mAttachmentMenu.showAsDropDown(v, 0, -menu.getMeasuredHeight() - v.getHeight());
            }
        }
    });

    mMessageEditText = (EditText) findViewById(R.id.message_edit_text);
    mMessageEditText.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 (mConversation == null || mConversation.isDeleted())
                return;
            if (s.length() > 0) {
                mSendButton.setEnabled(isEnabled());
                mConversation.send(LayerTypingIndicatorListener.TypingIndicator.STARTED);
            } else {
                mSendButton.setEnabled(false);
                mConversation.send(LayerTypingIndicatorListener.TypingIndicator.FINISHED);
            }
        }
    });

    mSendButton = (Button) findViewById(R.id.send_button);
    mSendButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (!mTextSender.requestSend(mMessageEditText.getText().toString()))
                return;
            mMessageEditText.setText("");
            mSendButton.setEnabled(false);
        }
    });
    applyStyle();
    return this;
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.c12_edit_signature);
    mTitle = (TextView) findViewById(R.id.top_view_title);
    mTitle.setText(getString(R.string.edit_signature));
    mBack = (ImageView) findViewById(R.id.top_view_back);
    mSignture = (EditText) findViewById(R.id.et_signature);
    mTextNum = (TextView) findViewById(R.id.text_num);
    mSave = (Button) findViewById(R.id.btn_save);
    mTopViewRightImage = (ImageView) findViewById(R.id.top_view_right_image);
    mTopViewRightImage.setVisibility(View.INVISIBLE);
    mShared = getSharedPreferences(O2OMobileAppConst.USERINFO, 0);
    String userStr = mShared.getString("user", "");
    try {/*from   ww  w  .  j ava  2s.  co  m*/
        if (userStr != null) {
            JSONObject userJson = new JSONObject(userStr);
            USER user = new USER();
            user.fromJson(userJson);
            mSignture.setText(user.signature);
            mTextNum.setText(mTotalSize - mSignture.getText().length() + "");
            mSignture.setSelection(user.signature.length());
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    mUserModel = new UserModel(this);
    mUserModel.addResponseListener(this);
    mSave = (Button) findViewById(R.id.btn_save);
    mBack.setOnClickListener(this);
    mSave.setOnClickListener(this);
    //??
    mSignture.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) {
            mTextNum.setText(mTotalSize - mSignture.getText().length() + "");

        }
    });
}

From source file:com.master.metehan.filtereagle.ActivityPro.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "Create");
    Util.setTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pro);//from   w  w  w . java2  s .  c  om

    getSupportActionBar().setTitle(R.string.title_pro);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    // Initial state
    updateState();

    TextView tvLogTitle = (TextView) findViewById(R.id.tvLogTitle);
    TextView tvFilterTitle = (TextView) findViewById(R.id.tvFilterTitle);
    TextView tvNotifyTitle = (TextView) findViewById(R.id.tvNotifyTitle);
    TextView tvSpeedTitle = (TextView) findViewById(R.id.tvSpeedTitle);
    TextView tvThemeTitle = (TextView) findViewById(R.id.tvThemeTitle);
    TextView tvAllTitle = (TextView) findViewById(R.id.tvAllTitle);

    Linkify.TransformFilter filter = new Linkify.TransformFilter() {
        @Override
        public String transformUrl(Matcher match, String url) {
            return "";
        }
    };

    Linkify.addLinks(tvLogTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_LOG, null, filter);
    Linkify.addLinks(tvFilterTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_FILTER, null,
            filter);
    Linkify.addLinks(tvNotifyTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_NOTIFY, null,
            filter);
    Linkify.addLinks(tvSpeedTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SPEED, null, filter);
    Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_THEME, null, filter);
    Linkify.addLinks(tvAllTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_PRO1, null, filter);

    // Challenge
    TextView tvChallenge = (TextView) findViewById(R.id.tvChallenge);
    tvChallenge.setText(Build.SERIAL);

    // Response
    try {
        final String response = Util.md5(Build.SERIAL, "FilterEagle");
        EditText etResponse = (EditText) findViewById(R.id.etResponse);
        etResponse.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // Do nothing
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // Do nothing
            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (response.equals(editable.toString().toUpperCase())) {
                    IAB.setBought(SKU_DONATION, ActivityPro.this);
                    updateState();
                }
            }
        });
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }

    try {
        iab = new IAB(new IAB.Delegate() {
            @Override
            public void onReady(final IAB iab) {
                Log.i(TAG, "IAB ready");
                try {
                    iab.updatePurchases();
                    updateState();

                    final Button btnLog = (Button) findViewById(R.id.btnLog);
                    final Button btnFilter = (Button) findViewById(R.id.btnFilter);
                    final Button btnNotify = (Button) findViewById(R.id.btnNotify);
                    final Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
                    final Button btnTheme = (Button) findViewById(R.id.btnTheme);
                    final Button btnAll = (Button) findViewById(R.id.btnAll);

                    View.OnClickListener listener = new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            try {
                                PendingIntent pi = null;
                                if (view == btnLog)
                                    pi = iab.getBuyIntent(SKU_LOG);
                                else if (view == btnFilter)
                                    pi = iab.getBuyIntent(SKU_FILTER);
                                else if (view == btnNotify)
                                    pi = iab.getBuyIntent(SKU_NOTIFY);
                                else if (view == btnSpeed)
                                    pi = iab.getBuyIntent(SKU_SPEED);
                                else if (view == btnTheme)
                                    pi = iab.getBuyIntent(SKU_THEME);
                                else if (view == btnAll)
                                    pi = iab.getBuyIntent(SKU_PRO1);

                                if (pi != null)
                                    startIntentSenderForResult(pi.getIntentSender(), view.getId(), new Intent(),
                                            0, 0, 0);
                            } catch (Throwable ex) {
                                Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                                Util.sendCrashReport(ex, ActivityPro.this);
                            }
                        }
                    };

                    btnLog.setOnClickListener(listener);
                    btnFilter.setOnClickListener(listener);
                    btnNotify.setOnClickListener(listener);
                    btnSpeed.setOnClickListener(listener);
                    btnTheme.setOnClickListener(listener);
                    btnAll.setOnClickListener(listener);

                    btnLog.setEnabled(true);
                    btnFilter.setEnabled(true);
                    btnNotify.setEnabled(true);
                    btnSpeed.setEnabled(true);
                    btnTheme.setEnabled(true);
                    btnAll.setEnabled(true);

                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
            }
        }, this);
        iab.bind();
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }
}

From source file:com.ccxt.whl.activity.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    usernameEditText = (EditText) findViewById(R.id.username);
    usernameEditText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);//??
    passwordEditText = (EditText) findViewById(R.id.password);
    // ????//from  w w  w.j a  va  2 s .c o  m
    //      if (DemoApplication.getInstance().getUserName() != null && DemoApplication.getInstance().getPassword() != null) {
    if (DemoApplication.getInstance().getUser() != null
            && DemoApplication.getInstance().getPassword() != null) {
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }
    // ????
    usernameEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            passwordEditText.setText(null);
        }

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

        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
    mAuthorization = Frontia.getAuthorization();//

    DeviceUuidFactory uuid = new DeviceUuidFactory(this);
    uid = uuid.getDeviceUuid().toString();
}

From source file:eu.codeplumbers.cosi.wizards.firstrun.ConnectFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mUrl.addTextChangedListener(new TextWatcher() {
        @Override/*from   www. j  a  v a2  s  .co m*/
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            mPage.getData().putString(ConnectPage.URL_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

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

        }

        @Override
        public void afterTextChanged(Editable editable) {
            mPage.getData().putString(ConnectPage.USERNAME_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

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

        }

        @Override
        public void afterTextChanged(Editable editable) {
            mPage.getData().putString(ConnectPage.PASSWORD_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

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

        }

        @Override
        public void afterTextChanged(Editable editable) {
            mPage.getData().putString(ConnectPage.DEVICE_NAME_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

    btnRegisterDevice.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean mUrlOk = true;
            boolean mPasswordOk = true;

            if (mUrl.getText().toString().isEmpty()) {
                mUrl.setError("Cozy URL can not be empty!");
                mUrlOk = false;
            }
            if (mPassword.getText().toString().isEmpty()) {
                mPassword.setError("Your password can not be empty!");
                mPasswordOk = false;
            }

            if (mPasswordOk && mPasswordOk) {
                if (!mUrl.getText().toString().startsWith(Constants.HTTPS)) {
                    mUrl.setText(Constants.HTTPS + mUrl.getText().toString());
                }

                btnRegisterDevice.setEnabled(false);
                registerDevice();
            }
        }
    });
}