Android Open Source - PhoneAsTablet My Text Watcher






From Project

Back to project page PhoneAsTablet.

License

The source code is released under:

GNU General Public License

If you think the Android project PhoneAsTablet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2013  Tsapalos Vasilios
 * //from  ww  w.ja v  a 2  s . c o  m
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package info.bits.phoneastablet.listeners;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.CheckBox;
import android.widget.EditText;

/**
 * @author LiTTle
 *         This is a listener for any text change at any text field.
 */
public class MyTextWatcher implements TextWatcher {

    private final EditText transmitter, receiver;
    private final CheckBox condition;

    /**
     * Constructs a new watcher for the text fields
     */
    public MyTextWatcher(CheckBox condition, EditText... pair) {
        this.condition = condition;
        transmitter = pair[0];
        receiver = pair[1];
    }

    /**
     * Enhances the behavior of the initial listener by mirroring the changes for one
     * text field to another.
     *
     * @see android.view.View.OnKeyListener#onKey(android.view.View, int, android.view.KeyEvent)
     */
    @Override
    public void afterTextChanged(Editable s) {
        if (condition.isChecked())
            receiver.setText(transmitter.getText().toString());
    }

    /**
     * @see android.text.TextWatcher#beforeTextChanged(java.lang.CharSequence, int, int, int)
     */
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
                                  int after) {
        // TODO Auto-generated method stub

    }

    /**
     * @see android.text.TextWatcher#onTextChanged(java.lang.CharSequence, int, int, int)
     */
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        // TODO Auto-generated method stub

    }

}




Java Source Code List

info.bits.phoneastablet.ApplicationTest.java
info.bits.phoneastablet.Resolution.java
info.bits.phoneastablet.listeners.MyOnCheckedListener.java
info.bits.phoneastablet.listeners.MyTextWatcher.java
info.bits.phoneastablet.listeners.package-info.java
info.bits.phoneastablet.receivers.BootCompletedReceiver.java
info.bits.phoneastablet.receivers.OrientationReceiver.java
info.bits.phoneastablet.receivers.package-info.java
info.bits.phoneastablet.services.OrientationService.java
info.bits.phoneastablet.services.package-info.java
info.bits.phoneastablet.utils.DatabaseHandler.java
info.bits.phoneastablet.utils.NotificationButtonsHandler.java
info.bits.phoneastablet.utils.NotificationHandler.java
info.bits.phoneastablet.utils.SuCommands.java
info.bits.phoneastablet.utils.package-info.java