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:cl.gisred.android.RepartoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LicenseResult licenseResult = ArcGISRuntime.setClientId(CLIENT_ID);
    LicenseLevel licenseLevel = ArcGISRuntime.License.getLicenseLevel();

    if (licenseResult == LicenseResult.VALID && licenseLevel == LicenseLevel.BASIC) {
        //Toast.makeText(getApplicationContext(), "Licencia bsica vlida", Toast.LENGTH_SHORT).show();
    } else if (licenseResult == LicenseResult.VALID && licenseLevel == LicenseLevel.STANDARD) {
        //Toast.makeText(getApplicationContext(), "Licencia standard vlida", Toast.LENGTH_SHORT).show();
    }/*from w  ww .  j a v  a2s .c  o m*/

    setContentView(R.layout.activity_reparto);

    Toolbar toolbar = (Toolbar) findViewById(R.id.apptool);
    setSupportActionBar(toolbar);

    myMapView = (MapView) findViewById(R.id.map);
    myMapView.enableWrapAround(true);

    /*Get Credenciales String*/
    Bundle bundle = getIntent().getExtras();
    usuar = bundle.getString("usuario");
    passw = bundle.getString("password");
    modulo = bundle.getString("modulo");
    empresa = bundle.getString("empresa");

    //Crea un intervalo entre primer dia del mes y dia actual
    Calendar oCalendarStart = Calendar.getInstance();
    oCalendarStart.set(Calendar.DAY_OF_MONTH, 1);
    oCalendarStart.set(Calendar.HOUR, 6);

    Calendar oCalendarEnd = Calendar.getInstance();
    oCalendarEnd.set(Calendar.HOUR, 23);

    TimeExtent oTimeInterval = new TimeExtent(oCalendarStart, oCalendarEnd);

    //Set Credenciales
    setCredenciales(usuar, passw);

    if (Build.VERSION.SDK_INT >= 23)
        verifPermisos();
    else
        startGPS();

    setLayersURL(this.getResources().getString(R.string.url_Mapabase), "MAPABASE");
    setLayersURL(this.getResources().getString(R.string.url_token), "TOKENSRV");
    setLayersURL(this.getResources().getString(R.string.srv_Repartos), "SRV_REPARTO");

    LyMapabase = new ArcGISDynamicMapServiceLayer(din_urlMapaBase, null, credenciales);
    LyMapabase.setVisible(true);

    LyReparto = new ArcGISFeatureLayer(srv_reparto, ArcGISFeatureLayer.MODE.ONDEMAND, credenciales);
    LyReparto.setDefinitionExpression(String.format("empresa = '%s'", empresa));
    LyReparto.setTimeInterval(oTimeInterval);
    LyReparto.setMinScale(8000);
    LyReparto.setVisible(true);

    myMapView.addLayer(mRoadBaseMaps, 0);
    myMapView.addLayer(LyReparto, 1);

    sqlReparto = new RepartoSQLiteHelper(RepartoActivity.this, dbName, null, 2);

    txtContador = (TextView) findViewById(R.id.tvContador);
    txtContSesion = (TextView) findViewById(R.id.tvContadorSesion);

    txtListen = (EditText) findViewById(R.id.txtListen);
    txtListen.setEnabled(bGpsActive);
    if (!txtListen.hasFocus())
        txtListen.requestFocus();
    txtListen.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().contains("\n") || s.toString().length() == RepartoClass.length_code) {
                guardarRegistro(s.toString().trim());
                s.clear();
            }
        }
    });

    final FloatingActionButton btnGps = (FloatingActionButton) findViewById(R.id.action_gps);
    btnGps.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
            if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                myMapView.setExtent(ldm.getPoint());
                myMapView.setScale(4000, true);
            }
        }
    });

    myMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
        @Override
        public void onStatusChanged(Object o, STATUS status) {
            if (ldm != null) {
                Point oPoint = ldm.getPoint();
                myMapView.centerAndZoom(oPoint.getX(), oPoint.getY(), 0.003f);
                myMapView.zoomin(true);
            }

            if (status == STATUS.LAYER_LOADING_FAILED) {
                // Check if a layer is failed to be loaded due to security
                if ((status.getError()) instanceof EsriSecurityException) {
                    EsriSecurityException securityEx = (EsriSecurityException) status.getError();
                    if (securityEx.getCode() == EsriSecurityException.AUTHENTICATION_FAILED)
                        Toast.makeText(myMapView.getContext(),
                                "Su cuenta tiene permisos limitados, contacte con el administrador para solicitar permisos faltantes",
                                Toast.LENGTH_SHORT).show();
                    else if (securityEx.getCode() == EsriSecurityException.TOKEN_INVALID)
                        Toast.makeText(myMapView.getContext(), "Token invlido! Vuelva a iniciar sesin!",
                                Toast.LENGTH_SHORT).show();
                    else if (securityEx.getCode() == EsriSecurityException.TOKEN_SERVICE_NOT_FOUND)
                        Toast.makeText(myMapView.getContext(),
                                "Servicio token no encontrado! Reintente iniciar sesin!", Toast.LENGTH_SHORT)
                                .show();
                    else if (securityEx.getCode() == EsriSecurityException.UNTRUSTED_SERVER_CERTIFICATE)
                        Toast.makeText(myMapView.getContext(), "Untrusted Host! Resubmit!", Toast.LENGTH_SHORT)
                                .show();

                    if (o instanceof ArcGISFeatureLayer) {
                        // Set user credential through username and password
                        UserCredentials creds = new UserCredentials();
                        creds.setUserAccount(usuar, passw);

                        LyMapabase.reinitializeLayer(creds);
                    }
                }
            }
        }
    });

    readCountData();
    updDashboard();

    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (iContRep > 0) {
                        Toast.makeText(getApplicationContext(), "Sincronizando datos...", Toast.LENGTH_SHORT)
                                .show();
                        readData();
                        enviarDatos();
                    }
                }
            });

        }
    }, 0, 120000);
}

From source file:com.app.khclub.base.easeim.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // T??home???appcrash
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;/*from  w ww . ja  v  a  2 s .  com*/
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);

    // ???
    blackList = EMContactManager.getInstance().getBlackListUsernames();
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();

    // ?
    query = (EditText) getView().findViewById(R.id.query);
    query.setHint(R.string.search);
    clearSearch = (ImageButton) getView().findViewById(R.id.search_clear);
    query.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);

            }
        }

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

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });

    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                User user = ((KHHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else if (Constant.CHAT_ROOM.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class));
            } else if (Constant.CHAT_ROBOT.equals(username)) {
                // // Robot?
                // startActivity(new Intent(getActivity(),
                // RobotsActivity.class));
                // ???
                Intent intentToCardList = new Intent(getActivity(), CollectCardActivity.class);
                startActivity(intentToCardList);
                // ?
                getActivity().overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
            } else {
                // demo??
                // startActivity(new Intent(getActivity(),
                // ChatActivity.class)
                // .putExtra("userId", adapter.getItem(position)
                // .getUsername()));
                // ?
                Intent intent = new Intent(getActivity(), OtherPersonalActivity.class);
                intent.putExtra(OtherPersonalActivity.INTENT_KEY,
                        KHUtils.stringToInt(adapter.getItem(position).getUsername().replace(KHConst.KH, "")));
                startActivity(intent);
                getActivity().overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
            }
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    // ?
    qrImageView = new QRCodePopupMenu(getActivity());
    final ImageView operateMenuView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ???
    operateMenuView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (null == mainMenu) {
                mainMenu = new MainPopupMenu(getActivity());
                mainMenu.setListener(new ClickListener() {

                    @Override
                    public void scanQRcodeClick() {
                        // ???
                        Intent intent = new Intent();
                        intent.setClass(getActivity(), MipcaCaptureActivity.class);
                        startActivityForResult(intent, SCANNIN_GREQUEST_CODE);
                    }

                    @Override
                    public void searchClick() {
                        // ??
                        Intent intentToSearch = new Intent(getActivity(), SearchActivity.class);
                        startActivity(intentToSearch);
                        // ?
                        getActivity().overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
                    }

                    @Override
                    public void createGroupClick() {
                        // ?
                        startActivity(new Intent(getActivity(), NewGroupActivity.class));
                        getActivity().overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
                    }

                    @Override
                    public void userQRShowClick() {
                        // TODO ?
                        qrImageView.setQRcode(false);
                        qrImageView.showPopupWindow((RelativeLayout) getView().findViewById(R.id.title_bar));
                    }
                });
            }
            mainMenu.showPopupWindow(operateMenuView);
            // startActivity(new Intent(getActivity(),
            // AddContactActivity.class));
        }
    });
    registerForContextMenu(listView);

    progressBar = (View) getView().findViewById(R.id.progress_bar);

    contactSyncListener = new HXContactSyncListener();
    HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener);

    blackListSyncListener = new HXBlackListSyncListener();
    HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener);

    contactInfoSyncListener = new HXContactInfoSyncListener();
    ((KHHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager()
            .addSyncContactInfoListener(contactInfoSyncListener);

    if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }
}

From source file:be.brunoparmentier.wifikeyshare.ui.activities.WifiNetworkActivity.java

void showWifiPasswordDialog() {
    final LayoutInflater inflater = getLayoutInflater();
    final View wifiPasswordDialogLayout = inflater.inflate(R.layout.dialog_wifi_password, null);

    final TextInputLayout wifiPasswordWrapper = (TextInputLayout) wifiPasswordDialogLayout
            .findViewById(R.id.wifi_key_wrapper);
    final EditText passwordEditText = (EditText) wifiPasswordDialogLayout.findViewById(R.id.wifi_key);
    //setPasswordRestrictions(passwordEditText);
    final CheckBox showPasswordCheckBox = (CheckBox) wifiPasswordDialogLayout
            .findViewById(R.id.show_password_checkbox);
    showPasswordCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override/*from   ww w.  j  av  a2  s. c  om*/
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            int selectionIndex = passwordEditText.getSelectionStart();
            if (isChecked) {
                passwordEditText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
            } else {
                passwordEditText
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            }
            passwordEditText.setSelection(selectionIndex);
        }
    });

    final AlertDialog wifiPasswordDialog = new AlertDialog.Builder(this)
            .setTitle(getString(R.string.wifi_dialog_password_title))
            .setMessage(String.format(getString(R.string.wifi_dialog_password_msg), wifiNetwork.getSsid()))
            .setView(wifiPasswordDialogLayout)
            .setPositiveButton(getString(R.string.action_ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    // this method gets overriden after we show the dialog
                }
            }).setNegativeButton(getString(R.string.action_cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    finish();
                }
            }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    finish();
                }
            }).create();

    passwordEditText.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) {
            wifiPasswordDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(editable.length() >= 5);
            if (wifiPasswordWrapper.getError() != null) {
                try {
                    if (WifiNetwork.isValidKeyLength(wifiNetwork.getAuthType(), editable.toString())) {
                        wifiPasswordWrapper.setError(null);
                    }
                } catch (final WifiException e) {
                    switch (e.getErrorCode()) {
                    case WifiException.WEP_KEY_LENGTH_ERROR:
                        wifiPasswordWrapper.setError(getString(R.string.error_wep_password_length));
                        break;
                    case WifiException.WPA_KEY_LENGTH_ERROR:
                        wifiPasswordWrapper.setError(getString(R.string.error_wpa_password_length));
                        break;
                    default:
                        wifiPasswordWrapper.setError(e.getMessage());
                        break;
                    }
                }
            }
        }
    });

    wifiPasswordDialog.show();

    wifiPasswordDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false); // disabled by default
    wifiPasswordDialog.getButton(DialogInterface.BUTTON_POSITIVE)
            .setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    try {
                        if (WifiNetwork.isValidKeyLength(wifiNetwork.getAuthType(),
                                passwordEditText.getText().toString())) {

                            wifiPasswordWrapper.setError(null);
                            wifiNetwork.setKey(passwordEditText.getText().toString());

                            // Update QR code image
                            FragmentManager fm = getSupportFragmentManager();
                            QrCodeFragment qrCodeFragment = (QrCodeFragment) fm.getFragments().get(0);
                            qrCodeFragment.updateQrCode(wifiNetwork);

                            WifiKeysDataSource.getInstance().insertWifiKey(wifiNetwork);

                            Intent passwordResultIntent = new Intent();
                            passwordResultIntent.putExtra(KEY_NETWORK_ID, wifiNetworkId);
                            setResult(RESULT_OK, passwordResultIntent);

                            wifiPasswordDialog.dismiss();
                        }
                    } catch (WifiException e) {
                        switch (e.getErrorCode()) {
                        case WifiException.WEP_KEY_LENGTH_ERROR:
                            wifiPasswordWrapper.setError(getString(R.string.error_wep_password_length));
                            break;
                        case WifiException.WPA_KEY_LENGTH_ERROR:
                            wifiPasswordWrapper.setError(getString(R.string.error_wpa_password_length));
                            break;
                        default:
                            wifiPasswordWrapper.setError(null);
                            break;
                        }
                    }
                }
            });
}

From source file:com.appolis.receiving.AcReceiveOptionMove.java

/**
 * function to initial layout//  w  w  w  .ja  va2  s.  c  o m
 */
private void initLayout() {
    linBack = (ImageView) findViewById(R.id.imgHome);
    linBack.setVisibility(View.GONE);
    linScan = (ImageView) findViewById(R.id.img_main_menu_scan_barcode);
    linScan.setOnClickListener(this);
    linScan.setVisibility(View.GONE);
    tvHeader = (TextView) findViewById(R.id.tvHeader);
    tvHeader.setText(
            languagePrefs.getPreferencesString(GlobalParams.RID_LBL_MOVE_KEY, GlobalParams.RID_LBL_MOVE_VALUE));

    tvMoveFunctionTitle = (TextView) findViewById(R.id.textView_move);
    tvMoveFunctionTitle.setText(languagePrefs.getPreferencesString(GlobalParams.MV_MSG_SELECTORSCAN_KEY,
            GlobalParams.MV_MSG_SELECTORSCAN_VALUE));
    tvTitleTransfer = (TextView) findViewById(R.id.tvTitleTransfer);
    tvTitleTransfer.setText(languagePrefs.getPreferencesString(GlobalParams.TRANSFER, GlobalParams.TRANSFER)
            + GlobalParams.VERTICAL_TWO_DOT);
    tvTitleMaxQty = (TextView) findViewById(R.id.tvTitleMaxQty);
    tvTitleMaxQty.setText(
            languagePrefs.getPreferencesString(GlobalParams.MV_LBL_MAXQTY, GlobalParams.DMG_LBL_MAXQTY_VALUE)
                    + ": ");
    tvUOM = (TextView) findViewById(R.id.tvUOM);
    tvUOM.setText(
            languagePrefs.getPreferencesString(GlobalParams.MV_LBL_UOM, GlobalParams.UNIT_OF_MEASURE_VALUE)
                    + GlobalParams.VERTICAL_TWO_DOT);
    tvLot = (TextView) findViewById(R.id.tvLot);
    tvLot.setText(languagePrefs.getPreferencesString(GlobalParams.REST_GRD_LOT_KEY, GlobalParams.LOT)
            + GlobalParams.VERTICAL_TWO_DOT);
    tvFrom = (TextView) findViewById(R.id.tvFrom);
    tvFrom.setText(languagePrefs.getPreferencesString(GlobalParams.MV_LBL_FROM, GlobalParams.FROM)
            + GlobalParams.VERTICAL_TWO_DOT);
    tvQtyView = (TextView) findViewById(R.id.tvQtyView);
    tvQtyView.setText(languagePrefs.getPreferencesString(GlobalParams.RID_GRD_QTY_KEY, GlobalParams.QTY));
    tvTo = (TextView) findViewById(R.id.tvTo);
    tvTo.setText(languagePrefs.getPreferencesString(GlobalParams.MV_LBL_TO, GlobalParams.TO)
            + GlobalParams.VERTICAL_TWO_DOT);

    tvmaxQty = (TextView) findViewById(R.id.tvmaxQty);
    tvItemDescription = (TextView) findViewById(R.id.tvItemDescription);
    tvTransfer = (TextView) findViewById(R.id.tvTransfer);
    spnMoveUOM = (Spinner) findViewById(R.id.spn_Move_UOM);
    edtLotValue = (EditText) findViewById(R.id.edtLotValue);
    edtMoveFrom = (EditText) findViewById(R.id.edt_move_from);

    edtMoveQty = (EditText) findViewById(R.id.et_move_qty);
    edtMoveQty.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (null != s && s.length() == 1 && s.toString().equalsIgnoreCase(".")) {
                edtMoveQty.setText("");
                s = "";
            }
        }

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

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    edtMoveQty.setFilters(
            new InputFilter[] { new DecimalDigitsInputFilter(enPurchaseOrderItemInfo.get_significantDigits()),
                    new InputFilter.LengthFilter(14) });

    edtMoveTo = (EditText) findViewById(R.id.et_move_to);
    btMoveOk = (Button) findViewById(R.id.btnOK);
    btMoveOk.setText(languagePrefs.getPreferencesString(GlobalParams.OK, GlobalParams.OK));
    btMoveOk.setOnClickListener(this);
    btMoveOk.setEnabled(true);
    btMoveCancel = (Button) findViewById(R.id.btnCancel);
    btMoveCancel.setText(languagePrefs.getPreferencesString(GlobalParams.CANCEL, GlobalParams.CANCEL));
    btMoveCancel.setOnClickListener(this);

    edtMoveTo.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                linScan.setVisibility(View.VISIBLE);
                scanFlag = GlobalParams.FLAG_ACTIVE;
            } else {
                linScan.setVisibility(View.GONE);
                scanFlag = GlobalParams.FLAG_INACTIVE;
            }
        }
    });

    if (null != enPurchaseOrderItemInfo) {
        tvTransfer.setText(enPurchaseOrderItemInfo.get_itemNumber());
        tvItemDescription.setText(enPurchaseOrderItemInfo.get_itemDesc());
    }

    if (null != enPurchaseOrderInfo) {
        if (StringUtils.isNotBlank(enPurchaseOrderInfo.get_receivingBinNumber())) {
            edtMoveFrom.setText(enPurchaseOrderInfo.get_receivingBinNumber());
        } else {
            edtMoveFrom.setText("");
        }
        edtMoveFrom.setEnabled(false);
    }

    if (null != listReceiptInfos) {
        if (listReceiptInfos.size() == 1) {
            Log.e("Appolis", "single record was selected from the previous screen");
            EnPurchaseOrderReceiptInfo recipt = listReceiptInfos.get(0);
            maxQty = recipt.get_quantityReceived();
            tvmaxQty.setText(BuManagement.formatDecimal(recipt.get_quantityReceived()).trim());
            edtLotValue.setText(recipt.get_lotNumber());
            edtLotValue.setEnabled(false);
            edtMoveQty.setText(BuManagement.formatDecimal(recipt.get_quantityReceived()).trim());
            edtMoveQty.setEnabled(true);
            spnMoveUOM.setEnabled(true);
            edtMoveTo.requestFocus();

            GetDataAsyncTask getDataAsyncTask = new GetDataAsyncTask(this,
                    enPurchaseOrderItemInfo.get_itemNumber());
            getDataAsyncTask.execute();
        } else {
            Logger.error("Appolis: multiple records have been selected on the previous screen");
            String strlot = "";
            int index = 0;

            for (EnPurchaseOrderReceiptInfo item : listReceiptInfos) {
                maxQty += item.get_quantityReceived();

                if (StringUtils.isNotBlank(item.get_lotNumber())) {
                    if (index == 0) {
                        strlot = strlot + item.get_lotNumber();
                    } else {
                        strlot = strlot + ", " + item.get_lotNumber();
                    }
                    index++;
                }
            }

            tvmaxQty.setText(BuManagement.formatDecimal(maxQty).trim());
            edtMoveTo.requestFocus();
            edtLotValue.setText(strlot);
            edtLotValue.setEnabled(false);
            edtMoveQty.setText(BuManagement.formatDecimal(maxQty).trim());
            edtMoveQty.setEnabled(false);
            spnMoveUOM.setEnabled(false);
            uom = enPurchaseOrderItemInfo.get_uomDesc();
            ArrayList<String> listUom = new ArrayList<String>();
            listUom.add(uom);
            ArrayAdapter<String> uomAdapter = new ArrayAdapter<String>(this, R.layout.custom_spinner_item,
                    listUom);
            spnMoveUOM.setAdapter(uomAdapter);
        }
    }
}

From source file:com.b44t.ui.Components.PasscodeView.java

public PasscodeView(final Context context) {
    super(context);

    setWillNotDraw(false);//from ww w  . j  a  va2  s.  c om
    setVisibility(GONE);

    backgroundFrameLayout = new FrameLayout(context);
    addView(backgroundFrameLayout);
    LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    backgroundFrameLayout.setLayoutParams(layoutParams);

    passwordFrameLayout = new FrameLayout(context);
    addView(passwordFrameLayout);
    layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    passwordFrameLayout.setLayoutParams(layoutParams);

    ImageView imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */);
    passwordFrameLayout.addView(imageView);
    layoutParams = (LayoutParams) imageView.getLayoutParams();
    if (AndroidUtilities.density < 1) {
        layoutParams.width = AndroidUtilities.dp(30);
        layoutParams.height = AndroidUtilities.dp(30);
    } else {
        layoutParams.width = AndroidUtilities.dp(40);
        layoutParams.height = AndroidUtilities.dp(40);
    }
    layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    layoutParams.bottomMargin = AndroidUtilities.dp(100);
    imageView.setLayoutParams(layoutParams);

    passcodeTextView = new TextView(context);
    passcodeTextView.setTextColor(0xffffffff);
    passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordFrameLayout.addView(passcodeTextView);
    layoutParams = (LayoutParams) passcodeTextView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(62);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passcodeTextView.setLayoutParams(layoutParams);

    passwordEditText = new EditText(context);
    passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
    passwordEditText.setTextColor(0xffffffff);
    passwordEditText.setMaxLines(1);
    passwordEditText.setLines(1);
    passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordEditText.setSingleLine(true);
    passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    passwordEditText.setTypeface(Typeface.DEFAULT);
    passwordEditText.setBackgroundDrawable(null);
    AndroidUtilities.clearCursorDrawable(passwordEditText);
    passwordFrameLayout.addView(passwordEditText);
    layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.leftMargin = AndroidUtilities.dp(70);
    layoutParams.rightMargin = AndroidUtilities.dp(70);
    layoutParams.bottomMargin = AndroidUtilities.dp(6);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passwordEditText.setLayoutParams(layoutParams);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                processDone(false);
                return true;
            }
            return false;
        }
    });
    passwordEditText.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 (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) {
                processDone(false);
            }
        }
    });
    passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public void onDestroyActionMode(ActionMode mode) {
        }

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }
    });

    checkImage = new ImageView(context);
    checkImage.setImageResource(R.drawable.passcode_check);
    checkImage.setScaleType(ImageView.ScaleType.CENTER);
    checkImage.setBackgroundResource(R.drawable.bar_selector_lock);
    passwordFrameLayout.addView(checkImage);
    layoutParams = (LayoutParams) checkImage.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(60);
    layoutParams.height = AndroidUtilities.dp(60);
    layoutParams.bottomMargin = AndroidUtilities.dp(4);
    layoutParams.rightMargin = AndroidUtilities.dp(10);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    checkImage.setLayoutParams(layoutParams);
    checkImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            processDone(false);
        }
    });

    FrameLayout lineFrameLayout = new FrameLayout(context);
    lineFrameLayout.setBackgroundColor(0x26ffffff);
    passwordFrameLayout.addView(lineFrameLayout);
    layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(1);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
    layoutParams.leftMargin = AndroidUtilities.dp(20);
    layoutParams.rightMargin = AndroidUtilities.dp(20);
    lineFrameLayout.setLayoutParams(layoutParams);

    numbersFrameLayout = new FrameLayout(context);
    addView(numbersFrameLayout);
    layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    numbersFrameLayout.setLayoutParams(layoutParams);

    lettersTextViews = new ArrayList<>(10);
    numberTextViews = new ArrayList<>(10);
    numberFrameLayouts = new ArrayList<>(10);
    for (int a = 0; a < 10; a++) {
        TextView textView = new TextView(context);
        textView.setTextColor(0xffffffff);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
        textView.setGravity(Gravity.CENTER);
        textView.setText(String.format(Locale.US, "%d", a));
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(50);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        numberTextViews.add(textView);

        textView = new TextView(context);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
        textView.setTextColor(0x7fffffff);
        textView.setGravity(Gravity.CENTER);
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(20);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        switch (a) {
        case 0:
            textView.setText("+");
            break;
        case 2:
            textView.setText("ABC");
            break;
        case 3:
            textView.setText("DEF");
            break;
        case 4:
            textView.setText("GHI");
            break;
        case 5:
            textView.setText("JKL");
            break;
        case 6:
            textView.setText("MNO");
            break;
        case 7:
            textView.setText("PQRS");
            break;
        case 8:
            textView.setText("TUV");
            break;
        case 9:
            textView.setText("WXYZ");
            break;
        default:
            break;
        }
        lettersTextViews.add(textView);
    }
    eraseView = new ImageView(context);
    eraseView.setScaleType(ImageView.ScaleType.CENTER);
    eraseView.setImageResource(R.drawable.passcode_delete);
    numbersFrameLayout.addView(eraseView);
    layoutParams = (LayoutParams) eraseView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(50);
    layoutParams.height = AndroidUtilities.dp(50);
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    eraseView.setLayoutParams(layoutParams);
    for (int a = 0; a < 11; a++) {
        FrameLayout frameLayout = new FrameLayout(context);
        frameLayout.setBackgroundResource(R.drawable.bar_selector_lock);
        frameLayout.setTag(a);
        if (a == 10) {
            frameLayout.setOnLongClickListener(new OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    passwordEditText.setText("");
                    return true;
                }
            });
        }
        frameLayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int tag = (Integer) v.getTag();
                switch (tag) {
                case 0:
                    appendCharacter("0");
                    break;
                case 1:
                    appendCharacter("1");
                    break;
                case 2:
                    appendCharacter("2");
                    break;
                case 3:
                    appendCharacter("3");
                    break;
                case 4:
                    appendCharacter("4");
                    break;
                case 5:
                    appendCharacter("5");
                    break;
                case 6:
                    appendCharacter("6");
                    break;
                case 7:
                    appendCharacter("7");
                    break;
                case 8:
                    appendCharacter("8");
                    break;
                case 9:
                    appendCharacter("9");
                    break;
                case 10:
                    String text = passwordEditText.getText().toString();
                    if (text.length() > 0) {
                        passwordEditText.setText(text.substring(0, text.length() - 1));
                    }
                    break;
                }
                if (passwordEditText.getText().toString().length() == 4) {
                    processDone(false);
                }
            }
        });
        numberFrameLayouts.add(frameLayout);
    }
    for (int a = 10; a >= 0; a--) {
        FrameLayout frameLayout = numberFrameLayouts.get(a);
        numbersFrameLayout.addView(frameLayout);
        layoutParams = (LayoutParams) frameLayout.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(100);
        layoutParams.height = AndroidUtilities.dp(100);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        frameLayout.setLayoutParams(layoutParams);
    }
}

From source file:com.ximai.savingsmore.save.activity.AddGoodsAcitivyt.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_good_activity);
    setCenterTitle("?");
    setLeftBackMenuVisibility(AddGoodsAcitivyt.this, "");
    head_view = (ImageView) findViewById(R.id.head_image);
    my_name = (TextView) findViewById(R.id.name);
    MyImageLoader.displayDefaultImage(URLText.img_url + MyUserInfoUtils.getInstance().myUserInfo.PhotoPath,
            head_view);//from   ww  w. ja v a 2 s .c o m
    if (null != MyUserInfoUtils.getInstance().myUserInfo.UserExtInfo) {
        my_name.setText(MyUserInfoUtils.getInstance().myUserInfo.UserExtInfo.StoreName);
    }
    cuxiaoshuoming = (TextView) findViewById(R.id.cuxiaoshuoming);
    shangpingmiaoshu = (TextView) findViewById(R.id.shangpingmiaoshu);
    horizontalListView = (HorizontalListView) findViewById(R.id.myGridview);
    yijifenlei = (TextView) findViewById(R.id.one_classity);
    erjifenlei = (TextView) findViewById(R.id.two_classity);
    brand = (TextView) findViewById(R.id.brand_name);
    xingshi_item = (LinearLayout) findViewById(R.id.xingshi_item);
    xingshi = (TextView) findViewById(R.id.xingshi);
    yuanyin_item = (LinearLayout) findViewById(R.id.yuanyin_item);
    yuanyin = (TextView) findViewById(R.id.yuanyin);
    dizhi_item = (LinearLayout) findViewById(R.id.dizhi_item);
    dizhi = (TextView) findViewById(R.id.dizhi);
    satrt_item = (LinearLayout) findViewById(R.id.start_time_item);
    start = (TextView) findViewById(R.id.start_time);
    end_item = (LinearLayout) findViewById(R.id.end_time_item);
    end = (TextView) findViewById(R.id.end_time);
    danwei_item = (LinearLayout) findViewById(R.id.danwei_item);
    danwei = (TextView) findViewById(R.id.danwei);
    bizhong_item = (LinearLayout) findViewById(R.id.bizhong_item);
    bizhong = (TextView) findViewById(R.id.bizhong);
    fapiao_item = (LinearLayout) findViewById(R.id.fapiao_item);
    fapiao = (TextView) findViewById(R.id.fapiao);
    yuan_price = (EditText) findViewById(R.id.yuan_price);
    cuxiao_price = (EditText) findViewById(R.id.cuxiao_price);
    cuxiao_text = (TextView) findViewById(R.id.cuxiao_text);
    fabu = (TextView) findViewById(R.id.fabu);
    product_bianhao = (EditText) findViewById(R.id.product_bianhao);
    product_name = (EditText) findViewById(R.id.product_name);
    xiangxi_address = (EditText) findViewById(R.id.xiangxi_address);
    servise = (TextView) findViewById(R.id.servise);
    servise.setOnClickListener(this);
    fabu.setOnClickListener(this);
    yijifenlei.setOnClickListener(this);
    erjifenlei.setOnClickListener(this);
    brand.setOnClickListener(this);
    xingshi_item.setOnClickListener(this);
    yuanyin_item.setOnClickListener(this);
    dizhi_item.setOnClickListener(this);
    satrt_item.setOnClickListener(this);
    end_item.setOnClickListener(this);
    danwei_item.setOnClickListener(this);
    bizhong_item.setOnClickListener(this);
    fapiao_item.setOnClickListener(this);
    yuan_price.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 (null != xingshi_id) {
                if (xingshi_id.equals("2") || xingshi_id.equals("3") || xingshi_id.equals("7")
                        || xingshi_id.equals("12")) {
                    cuxiao_price.setText(s.toString());
                }
            }
        }
    });
    myAdapter = new MyAdapter();
    horizontalListView.setAdapter(myAdapter);
    queryDicNode();
    queryDicNode2();
    explain = (EditText) findViewById(R.id.explain);
    descript = (EditText) findViewById(R.id.decript);
    shuoming_number = explain.getText().length();
    miaoshu_number = descript.getText().length();
    explain.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) {
            shuoming_number = explain.getText().length();
            cuxiaoshuoming.setText("(?" + (200 - shuoming_number) + ")");
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
    descript.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) {
            miaoshu_number = descript.getText().length();
            shangpingmiaoshu.setText("???(?" + (200 - miaoshu_number) + ")");
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    zidingyi_brand = (TextView) findViewById(R.id.zidingyi_brand);
    custom_type = (TextView) findViewById(R.id.custom_type);
    zidingyi_brand.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            classity_dialog = new AlertDialog.Builder(AddGoodsAcitivyt.this).create();
            View view = LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.save_brand, null);
            final TextView queding, quxiao;
            final EditText content;
            queding = (TextView) view.findViewById(R.id.comfirm);
            quxiao = (TextView) view.findViewById(R.id.cannel);
            content = (EditText) view.findViewById(R.id.content);
            queding.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (null != content.getText() && !TextUtils.isEmpty(content.getText())) {
                        save_brand(content.getText().toString());
                    }
                }
            });
            quxiao.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    classity_dialog.dismiss();
                }
            });
            classity_dialog.setView(view);
            classity_dialog.show();
        }
    });
    custom_type.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (oneId != null && !TextUtils.isEmpty(oneId)) {
                brand_dialog = new AlertDialog.Builder(AddGoodsAcitivyt.this).create();
                View view = LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.custom_classfy, null);
                final TextView queding, quxiao;
                final EditText content;
                queding = (TextView) view.findViewById(R.id.comfirm);
                quxiao = (TextView) view.findViewById(R.id.cannel);
                content = (EditText) view.findViewById(R.id.content);
                queding.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (null != content.getText() && !TextUtils.isEmpty(content.getText())) {
                            apply_calssity(content.getText().toString(), oneId);
                        }
                    }
                });
                quxiao.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        brand_dialog.dismiss();
                    }
                });
                brand_dialog.setView(view);
                brand_dialog.show();
            } else {
                Toast.makeText(AddGoodsAcitivyt.this, "", Toast.LENGTH_SHORT).show();
            }
        }
    });
    cuxiao_price.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (cuxiao_text.getText().equals("N?N")) {
                bug_dialog = new AlertDialog.Builder(AddGoodsAcitivyt.this).create();
                View view = LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.bug_give, null);
                final TextView queding, quxiao;
                final EditText number1, number2;
                queding = (TextView) view.findViewById(R.id.comfirm);
                quxiao = (TextView) view.findViewById(R.id.cannel);
                number1 = (EditText) view.findViewById(R.id.number1);
                number2 = (EditText) view.findViewById(R.id.number2);
                queding.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (null != number1.getText() && !TextUtils.isEmpty(number1.getText())
                                && null != number2.getText() && !TextUtils.isEmpty(number2.getText())) {
                            cuxiao_price.setText("" + number1.getText().toString() + "?"
                                    + number2.getText().toString());
                            bug_dialog.dismiss();
                        }
                    }
                });
                quxiao.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        bug_dialog.dismiss();
                    }
                });
                bug_dialog.setView(view);
                bug_dialog.show();
            }
        }
    });
    myProduct = new MyProduct();
    if (null != getIntent().getStringExtra("id")) {
        Id = getIntent().getStringExtra("id");
        getgood_detial(Id);
    }

}

From source file:com.example.android.wizardpager.wizard.ui.CustomerAddressFragment.java

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

    OCR();// w w  w .  j a  v a 2  s . co m

    mAddress1View.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(CustomerAddressPage.ADDRESS1_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

    /*        mEmailView.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(CustomerInfoPage.EMAIL_DATA_KEY,
                (editable != null) ? editable.toString() : null);
        mPage.notifyDataChanged();
    }
            });*/

    mAddress2View.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(CustomerAddressPage.ADDRESS2_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

    mAddress3View.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(CustomerAddressPage.ADDRESS3_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

    mAddress4View.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(CustomerAddressPage.ADDRESS4_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

}

From source file:com.bitants.wally.fragments.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false);
    if (rootView != null) {
        super.onCreateView(rootView);
        quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background);
        quickReturnView = rootView.findViewById(R.id.quick_return_view);
        quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear);
        quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() {
            @Override/*from  ww w  . j a v a2s .  co m*/
            public void onClick(View v) {
                if (quickReturnEditText != null) {
                    query = "";
                    quickReturnEditText.setText("");
                    quickReturnEditText.performClick();
                    showKeyboard(quickReturnEditText);
                }
            }
        });
        quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext);
        quickReturnEditText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                quickReturnEditText.setCursorVisible(true);
                restoreQuickReturnView();
            }
        });
        quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                    return search();
                }
                return false;
            }

        });
        quickReturnEditText.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) {
                if (!TextUtils.isEmpty(s)) {
                    quickReturnEditTextClearButton.setVisibility(View.VISIBLE);
                } else {
                    quickReturnEditTextClearButton.setVisibility(View.GONE);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        gridView.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                float currentTranslationY = quickReturnView.getTranslationY();
                float maxTranslationY = quickReturnHeight;
                float newTranslationY = currentTranslationY + -dy;

                if (newTranslationY > 0) {
                    newTranslationY = 0;
                } else if (newTranslationY < -maxTranslationY) {
                    newTranslationY = -maxTranslationY;
                }
                quickReturnView.setTranslationY(newTranslationY);

                float percent = (-maxTranslationY) / 100.0f;
                float currentPercent = 100 - (newTranslationY / percent);

                quickReturnBackground.setAlpha(currentPercent / 100);
                quickReturnBackground.setTranslationY(newTranslationY);

            }
        });

        colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker);
        colorPickerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();

            }
        });

        colorTagCard = rootView.findViewById(R.id.search_color_card);
        colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview);
        colorTagTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();
            }
        });
        colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear);
        colorTagClearButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                colorTagCard.setVisibility(View.GONE);
                colorPickerButton.setVisibility(View.VISIBLE);
                currentColor = null;
                query = quickReturnEditText.getText().toString();
                gridView.setAdapter(null);
                showLoader();
                getImages(1, query);
            }
        });

        setupAutoSizeGridView();
        if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) {
            query = savedInstanceState.getString(STATE_QUERY, "");
            Message msgObj = uiHandler.obtainMessage();
            msgObj.what = MSG_IMAGES_REQUEST_CREATE;
            msgObj.arg1 = 1;
            msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES);
            uiHandler.sendMessage(msgObj);
            currentColor = savedInstanceState.getString(STATE_COLOR);
            if (currentColor != null) {
                int backgroundColor = Color.parseColor("#" + currentColor);
                int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT);
                colorizeColorTag(backgroundColor, textColor, textColor, currentColor);
                colorTagCard.setVisibility(View.VISIBLE);
                colorPickerButton.setVisibility(View.GONE);
            }
            currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE);
        }
        ((MainActivity) getActivity()).addOnFileChangedListener(this);
        ((MainActivity) getActivity()).addOnFiltersChangedListener(this);
    }
    return rootView;
}

From source file:com.fbartnitzek.tasteemall.addentry.AddLocationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    Log.v(LOG_TAG, "onCreateView, hashCode=" + this.hashCode() + ", " + "inflater = [" + inflater
            + "], container = [" + container + "], savedInstanceState = [" + savedInstanceState + "]");
    mRootView = inflater.inflate(R.layout.fragment_add_location, container, false);

    //        mEditLocationDescription = (EditText) mRootView.findViewById(R.id.location_description);
    mEditLocationDescription = (AutoCompleteTextView) mRootView.findViewById(R.id.location_description);
    mEditLocationDescription.setThreshold(1);
    mLocationDescriptionAdapter = new CompletionLocationDescriptionAdapter(getActivity());
    mEditLocationDescription.setAdapter(mLocationDescriptionAdapter);

    mEditLocationDescription.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override//w  w w  .  j  av  a  2s . co  m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor c = (Cursor) parent.getItemAtPosition(position);
            mLocation_Id = c.getLong(QueryColumns.LocationPart.CompletionQuery.COL__ID);
            mLocationId = c.getString(QueryColumns.LocationPart.CompletionQuery.COL_ID);
            Log.v(LOG_TAG, "editDescription.onItemClick Cursor with locationId=" + mLocationId);

            if (mEditLocation.getText().toString().isEmpty()) {
                String location = c.getString(QueryColumns.LocationPart.CompletionQuery.COL_FORMATTED_ADDRESS);
                if (location != null && !location.isEmpty()) {
                    mEditLocation.setText(location); // TODO: no reloading - should work
                }
            }
        }
    });

    mMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);

    hideMap();
    if (mMapFragment == null) {
        Log.e(LOG_TAG, "onCreateView, MapFragment not found...");
    } else {
        mMapFragment.getMapAsync(this);
    }

    mEditLocation = (LocationAutoCompleteTextView) mRootView.findViewById(R.id.location_location);
    mEditLocation.setThreshold(1);
    mLocationAdapter = new CompletionLocationAdapter(getActivity(), true);
    mEditLocation.setAdapter(mLocationAdapter);
    //        mEditLocation = (EditText) mRootView.findViewById(R.id.location_location);
    mEditLocation.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) {
            // TODO: for now: just show it
            if (s.length() > 1) {
                hideMap();
                if (mOriginalLocationFormatted != null && mOriginalLocationFormatted.length() > 0
                        && mOriginalLocationFormatted.equals(s.toString())) {
                    // workaround: not all searches with formatted_location get address result :-p
                    showMap();
                    focusOnMap();
                    updateAndMoveToMarker();
                } else {
                    mLocationParcelable = null;
                    mLocationInput = s.toString();
                    startGeocodeService(s.toString());
                }
            }
        }
    });

    mEditLocation.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor c = (Cursor) parent.getItemAtPosition(position);
            mLocation_Id = c.getLong(QueryColumns.LocationPart.CompletionQuery.COL__ID);
            mLocationId = c.getString(QueryColumns.LocationPart.CompletionQuery.COL_ID);
            Log.v(LOG_TAG, "editLocation.onItemClick Cursor with locationId=" + mLocationId);

            if (mEditLocationDescription.getText().toString().isEmpty()) {
                String description = c.getString(QueryColumns.LocationPart.CompletionQuery.COL_DESCRIPTION);
                if (description != null && !description.isEmpty()) {
                    mEditLocationDescription.setText(description);
                    mEditLocationDescription.setEnabled(false);
                }
            }
        }
    });

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(STATE_LOCATION_INPUT)) {
            mLocationInput = savedInstanceState.getString(STATE_LOCATION_INPUT);
        }
        if (savedInstanceState.containsKey(STATE_LOCATION_DESCRIPTION)) {
            mLocationDescription = savedInstanceState.getString(STATE_LOCATION_DESCRIPTION);
        }
    }

    if (mLocationInput != null) {
        mEditLocation.setText(mLocationInput);
    }
    if (mLocationDescription != null) {
        mEditLocationDescription.setText(mLocationDescription);
    }

    mRootView.findViewById(R.id.location_here_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.v(LOG_TAG, "here.onClick, hashCode=" + this.hashCode() + ", " + "v = [" + v + "]");
            getCurrentLocation();
        }
    });

    mListView = (ListView) mRootView.findViewById(R.id.listview_locations);
    mListView.setAdapter(mLocationListAdapter);

    if (mLocationAddresses != null && mLocationAddresses.length > 0) {
        mLocationListAdapter.addAll(mLocationAddresses);

        if (ListView.INVALID_POSITION != mPosition) {
            mListView.smoothScrollToPosition(mPosition);
            mListView.setItemChecked(mPosition, true);
        }
    }

    mListView.setOnTouchListener(new OnTouchHideKeyboardListener(this));
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mPosition = position;
            Log.v(LOG_TAG, "listview.onItemClick, hashCode=" + this.hashCode() + ", " + "parent = [" + parent
                    + "], view = [" + view + "], position = [" + position + "], id = [" + id + "]");

            showMap();
            focusOnMap();

            Address address = mLocationListAdapter.getItem(mPosition);
            mLocationParcelable = Utils.getLocationFromAddress(address, mLocationInput, null);

            updateAndMoveToMarker();

            //TODO: if other...? remove mLocationId/_Id
            //TODO if addresses not equal, but nearby (same town, latLng, street ...?): ask, else remove
            // at first: same text
            if (!mLocationInput.equals(mEditLocation.getText().toString())) {
                Log.v(LOG_TAG, "listview.onItemClick, resetting mLocationId");
                mLocationId = null;
            } else {
                Log.v(LOG_TAG, "listview.onItemClick, same text - keep mLocationId");
            }

        }
    });

    createToolbar();

    return mRootView;
}

From source file:com.musenkishi.wally.fragments.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false);
    if (rootView != null) {
        super.onCreateView(rootView);
        quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background);
        quickReturnView = rootView.findViewById(R.id.quick_return_view);
        quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear);
        quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() {
            @Override//from  w  w w  .j  a  v a 2  s. c o  m
            public void onClick(View v) {
                if (quickReturnEditText != null) {
                    query = "";
                    quickReturnEditText.setText("");
                    quickReturnEditText.performClick();
                    showKeyboard(quickReturnEditText);
                }
            }
        });
        quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext);
        quickReturnEditText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                quickReturnEditText.setCursorVisible(true);
                quickReturnView.animate().translationY(0.0f).setDuration(300)
                        .setInterpolator(new EaseInOutBezierInterpolator()).start();
                quickReturnBackground.animate().translationY(0.0f).alpha(1.0f).setDuration(300)
                        .setInterpolator(new EaseInOutBezierInterpolator()).start();
            }
        });
        quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                    return search();
                }
                return false;
            }

        });
        quickReturnEditText.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) {
                if (!TextUtils.isEmpty(s)) {
                    quickReturnEditTextClearButton.setVisibility(View.VISIBLE);
                } else {
                    quickReturnEditTextClearButton.setVisibility(View.GONE);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        gridView.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                float currentTranslationY = quickReturnView.getTranslationY();
                float maxTranslationY = quickReturnHeight;
                float newTranslationY = currentTranslationY + -dy;

                if (newTranslationY > 0) {
                    newTranslationY = 0;
                } else if (newTranslationY < -maxTranslationY) {
                    newTranslationY = -maxTranslationY;
                }
                quickReturnView.setTranslationY(newTranslationY);

                float percent = (-maxTranslationY) / 100.0f;
                float currentPercent = 100 - (newTranslationY / percent);

                quickReturnBackground.setAlpha(currentPercent / 100);
                quickReturnBackground.setTranslationY(newTranslationY);

            }
        });

        colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker);
        colorPickerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();

            }
        });

        colorTagCard = rootView.findViewById(R.id.search_color_card);
        colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview);
        colorTagTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();
            }
        });
        colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear);
        colorTagClearButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                colorTagCard.setVisibility(View.GONE);
                colorPickerButton.setVisibility(View.VISIBLE);
                currentColor = null;
                query = quickReturnEditText.getText().toString();
                gridView.setAdapter(null);
                showLoader();
                getImages(1, query);
            }
        });

        setupAutoSizeGridView();
        if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) {
            query = savedInstanceState.getString(STATE_QUERY, "");
            Message msgObj = uiHandler.obtainMessage();
            msgObj.what = MSG_IMAGES_REQUEST_CREATE;
            msgObj.arg1 = 1;
            msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES);
            uiHandler.sendMessage(msgObj);
            currentColor = savedInstanceState.getString(STATE_COLOR);
            if (currentColor != null) {
                int backgroundColor = Color.parseColor("#" + currentColor);
                int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT);
                colorizeColorTag(backgroundColor, textColor, textColor, currentColor);
                colorTagCard.setVisibility(View.VISIBLE);
                colorPickerButton.setVisibility(View.GONE);
            }
            currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE);
            ((MainActivity) getActivity()).addOnFileChangedListener(this);
            ((MainActivity) getActivity()).addOnFiltersChangedListener(this);
        }
    }
    return rootView;
}