List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:foam.jellyfish.StarwispBuilder.java
public void Build(final StarwispActivity ctx, final String ctxname, JSONArray arr, ViewGroup parent) { try {/* ww w . j av a2 s. co m*/ String type = arr.getString(0); //Log.i("starwisp","building started "+type); if (type.equals("build-fragment")) { String name = arr.getString(1); int ID = arr.getInt(2); Fragment fragment = ActivityManager.GetFragment(name); LinearLayout inner = new LinearLayout(ctx); inner.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); inner.setId(ID); FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(ID, fragment); fragmentTransaction.commit(); parent.addView(inner); return; } if (type.equals("linear-layout")) { LinearLayout v = new LinearLayout(ctx); v.setId(arr.getInt(1)); v.setOrientation(BuildOrientation(arr.getString(2))); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); //v.setPadding(2,2,2,2); JSONArray col = arr.getJSONArray(4); v.setBackgroundColor(Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2))); parent.addView(v); JSONArray children = arr.getJSONArray(5); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("frame-layout")) { FrameLayout v = new FrameLayout(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } /* if (type.equals("grid-layout")) { GridLayout v = new GridLayout(ctx); v.setId(arr.getInt(1)); v.setRowCount(arr.getInt(2)); //v.setColumnCount(arr.getInt(2)); v.setOrientation(BuildOrientation(arr.getString(3))); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); parent.addView(v); JSONArray children = arr.getJSONArray(5); for (int i=0; i<children.length(); i++) { Build(ctx,ctxname,new JSONArray(children.getString(i)), v); } return; } */ if (type.equals("scroll-view")) { HorizontalScrollView v = new HorizontalScrollView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("scroll-view-vert")) { ScrollView v = new ScrollView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("view-pager")) { ViewPager v = new ViewPager(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); v.setOffscreenPageLimit(3); final JSONArray items = arr.getJSONArray(3); v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) { @Override public int getCount() { return items.length(); } @Override public Fragment getItem(int position) { try { String fragname = items.getString(position); return ActivityManager.GetFragment(fragname); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } return null; } }); parent.addView(v); return; } if (type.equals("space")) { // Space v = new Space(ctx); (class not found runtime error??) TextView v = new TextView(ctx); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); } if (type.equals("image-view")) { ImageView v = new ImageView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); String image = arr.getString(2); if (image.startsWith("/")) { Bitmap bitmap = BitmapFactory.decodeFile(image); v.setImageBitmap(bitmap); } else { int id = ctx.getResources().getIdentifier(image, "drawable", ctx.getPackageName()); v.setImageResource(id); } parent.addView(v); } if (type.equals("text-view")) { TextView v = new TextView(ctx); v.setId(arr.getInt(1)); v.setText(Html.fromHtml(arr.getString(2))); v.setTextSize(arr.getInt(3)); v.setMovementMethod(LinkMovementMethod.getInstance()); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); if (arr.length() > 5) { if (arr.getString(5).equals("left")) { v.setGravity(Gravity.LEFT); } else { if (arr.getString(5).equals("fill")) { v.setGravity(Gravity.FILL); } else { v.setGravity(Gravity.CENTER); } } } else { v.setGravity(Gravity.LEFT); } v.setTypeface(((StarwispActivity) ctx).m_Typeface); parent.addView(v); } if (type.equals("debug-text-view")) { TextView v = (TextView) ctx.getLayoutInflater().inflate(R.layout.debug_text, null); // v.setBackgroundResource(R.color.black); v.setId(arr.getInt(1)); // v.setText(Html.fromHtml(arr.getString(2))); // v.setTextColor(R.color.white); // v.setTextSize(arr.getInt(3)); // v.setMovementMethod(LinkMovementMethod.getInstance()); // v.setMaxLines(10); // v.setVerticalScrollBarEnabled(true); // v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); //v.setMovementMethod(new ScrollingMovementMethod()); /* if (arr.length()>5) { if (arr.getString(5).equals("left")) { v.setGravity(Gravity.LEFT); } else { if (arr.getString(5).equals("fill")) { v.setGravity(Gravity.FILL); } else { v.setGravity(Gravity.CENTER); } } } else { v.setGravity(Gravity.LEFT); } v.setTypeface(((StarwispActivity)ctx).m_Typeface);*/ parent.addView(v); } if (type.equals("web-view")) { WebView v = new WebView(ctx); v.setId(arr.getInt(1)); v.setVerticalScrollBarEnabled(false); v.loadData(arr.getString(2), "text/html", "utf-8"); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); parent.addView(v); } if (type.equals("edit-text")) { final EditText v = new EditText(ctx); v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); String inputtype = arr.getString(4); if (inputtype.equals("text")) { //v.setInputType(InputType.TYPE_CLASS_TEXT); } else if (inputtype.equals("numeric")) { v.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_DECIMAL); } else if (inputtype.equals("email")) { v.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS); } v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(5))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(5); v.setSingleLine(true); v.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { CallbackArgs(ctx, ctxname, v.getId(), "\"" + s.toString() + "\""); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); parent.addView(v); } if (type.equals("button")) { Button v = new Button(ctx); v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(5); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Callback(ctx, ctxname, v.getId()); } }); parent.addView(v); } if (type.equals("toggle-button")) { ToggleButton v = new ToggleButton(ctx); v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(5); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, v.getId(), arg); } }); parent.addView(v); } if (type.equals("seek-bar")) { SeekBar v = new SeekBar(ctx); v.setId(arr.getInt(1)); v.setMax(arr.getInt(2)); v.setProgress(arr.getInt(2) / 2); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); final String fn = arr.getString(4); v.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar v, int a, boolean s) { CallbackArgs(ctx, ctxname, v.getId(), Integer.toString(a)); } public void onStartTrackingTouch(SeekBar v) { } public void onStopTrackingTouch(SeekBar v) { } }); parent.addView(v); } if (type.equals("spinner")) { Spinner v = new Spinner(ctx); final int wid = arr.getInt(1); v.setId(wid); final JSONArray items = arr.getJSONArray(2); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); ArrayList<String> spinnerArray = new ArrayList<String>(); for (int i = 0; i < items.length(); i++) { spinnerArray.add(items.getString(i)); } ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx, android.R.layout.simple_spinner_item, spinnerArray) { public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface); return v; } }; v.setAdapter(spinnerArrayAdapter); v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> a, View v, int pos, long id) { try { CallbackArgs(ctx, ctxname, wid, "\"" + items.getString(pos) + "\""); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } } public void onNothingSelected(AdapterView<?> v) { } }); parent.addView(v); } if (type.equals("nomadic")) { final int wid = arr.getInt(1); NomadicSurfaceView v = new NomadicSurfaceView(ctx, wid); v.setId(wid); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); } /* if (type.equals("canvas")) { StarwispCanvas v = new StarwispCanvas(ctx); final int wid = arr.getInt(1); v.setId(wid); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); v.SetDrawList(arr.getJSONArray(3)); parent.addView(v); } if (type.equals("camera-preview")) { PictureTaker pt = new PictureTaker(); CameraPreview v = new CameraPreview(ctx,pt); final int wid = arr.getInt(1); v.setId(wid); // LinearLayout.LayoutParams lp = // new LinearLayout.LayoutParams(minWidth, minHeight, 1); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); // v.setLayoutParams(lp); parent.addView(v); } */ if (type.equals("button-grid")) { LinearLayout horiz = new LinearLayout(ctx); final int id = arr.getInt(1); final String buttontype = arr.getString(2); horiz.setId(id); horiz.setOrientation(LinearLayout.HORIZONTAL); parent.addView(horiz); int height = arr.getInt(3); int textsize = arr.getInt(4); LinearLayout.LayoutParams lp = BuildLayoutParams(arr.getJSONArray(5)); JSONArray buttons = arr.getJSONArray(6); int count = buttons.length(); int vertcount = 0; LinearLayout vert = null; for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); if (vertcount == 0) { vert = new LinearLayout(ctx); vert.setId(0); vert.setOrientation(LinearLayout.VERTICAL); horiz.addView(vert); } vertcount = (vertcount + 1) % height; if (buttontype.equals("button")) { Button b = new Button(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(6); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } else if (buttontype.equals("toggle")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(6); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg); } }); vert.addView(b); } } } } catch (JSONException e) { Log.e("starwisp", "Error parsing [" + arr.toString() + "] " + e.toString()); } //Log.i("starwisp","building ended"); }
From source file:com.cerema.cloud2.authentication.AuthenticatorActivity.java
/** * //from w w w.j a v a 2s . c o m * @param savedInstanceState Saved activity state, as in {{@link #onCreate(Bundle)} */ private void initServerPreFragment(Bundle savedInstanceState) { /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState) boolean isUrlInputAllowed = getResources().getBoolean(R.bool.show_server_url_input); if (savedInstanceState == null) { if (mAccount != null) { mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL); // TODO do next in a setter for mBaseUrl mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); mServerInfo.mVersion = AccountUtils.getServerVersion(mAccount); } else { mServerInfo.mBaseUrl = getString(R.string.server_url).trim(); mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); } } else { mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID); mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED); // TODO parcelable mServerInfo.mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN); mServerInfo.mBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); if (ocVersion != null) { mServerInfo.mVersion = new OwnCloudVersion(ocVersion); } mServerInfo.mAuthMethod = AuthenticationMethod .valueOf(savedInstanceState.getString(KEY_SERVER_AUTH_METHOD)); } /// step 2 - set properties of UI elements (text, visibility, enabled...) mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); // Convert IDN to Unicode mHostUrlInput.setText("https://cloud.cerema-dtm.fr/"); //mHostUrlInput.setEnabled(false); //mHostUrlInput.setFocusable(false); if (mAction != ACTION_CREATE) { /// lock things that should not change mHostUrlInput.setEnabled(false); mHostUrlInput.setFocusable(false); } if (isUrlInputAllowed) { mRefreshButton = findViewById(R.id.embeddedRefreshButton); } else { findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); mRefreshButton = findViewById(R.id.centeredRefreshButton); } showRefreshButton(mServerIsChecked && !mServerIsValid && mWaitingForOpId > Integer.MAX_VALUE); mServerStatusView = (TextView) findViewById(R.id.server_status_text); showServerStatus(); /// step 3 - bind some listeners and options //mHostUrlInput.setImeOptions(EditorInfo.IME_ACTION_NEXT); mHostUrlInput.setOnEditorActionListener(this); /// step 4 - create listeners that will be bound at onResume mHostUrlInputWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (mOkButton.isEnabled() && !mServerInfo.mBaseUrl.equals(normalizeUrl(s.toString(), mServerInfo.mIsSslConn))) { mOkButton.setEnabled(false); } } @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 (mAuthStatusIcon != 0) { Log_OC.d(TAG, "onTextChanged: hiding authentication status"); mAuthStatusIcon = 0; mAuthStatusText = 0; } } }; // TODO find out if this is really necessary, or if it can done in a different way findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()) .equals(mAuthTokenType) && mHostUrlInput.hasFocus()) { checkOcServer(); } } return false; } }); /// step 4 - mark automatic check to be started when OperationsService is ready mPendingAutoCheck = (savedInstanceState == null && (mAction != ACTION_CREATE || !isUrlInputAllowed)); }
From source file:com.paic.zhifu.wallet.activity.modules.boundcard.OpenPaymentConfirmActivity.java
@Override public void initObserver() { if (DataCache.getDataCache().getCountDown() > 0) { startCountDown(DataCache.getDataCache().getCountDown()); }//from w w w .j av a 2 s . c o m openpayagreement.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { jump(StaticVariableTool.ACTIVITY_OPENPAYAGREEMENT); } }); headTitle.setBackPressedListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); notecheck.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isSendVaildate) return; if (!canSendSms) return; phoneNum = phonenumber.getText().toString(); // ????? ?????????? HashMap<String, String> checkCodeMap = new HashMap<String, String>(); checkCodeMap.put("clientId", StaticVariableTool.getIMEI(MyApp.getContext())); checkCodeMap.put("operationType", ServerConnect.getOperationType(HttpConstants.CONNECTIONID_SMSCODE)); checkCodeMap.put("useType", "2"); checkCodeMap.put("loginId", ""); checkCodeMap.put("phoneNum", phoneNum); OpenPaymentOperation.sendSMSCode(OpenPaymentConfirmActivity.this, listener, checkCodeMap); startCountDown(); } }); next_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!checkPhoneNum()) { ToastShow("??"); return; } if (phoneNumLastSend == null) { ToastShow("????"); return; } if (!phoneNumLastSend.equals(phonenumber.getText().toString())) { ToastShow("?????????"); return; } if (!checkSMSCode()) { ToastShow("??6?"); return; } if (!checkLicense()) { ToastShow(getString(R.string.TextView_activity_openpay2_agreement_str_agree)); return; } // ???? HashMap<String, String> openPayMap = new HashMap<String, String>(); openPayMap.put("clientId", StaticVariableTool.getIMEI(MyApp.getContext())); openPayMap.put("operationType", ServerConnect.getOperationType(HttpConstants.CONNECTIONID_BANDCARD)); openPayMap.put("bankCardNo", cardNumAll); openPayMap.put("smsCode", smsCode.getText().toString()); OpenPaymentOperation.openPayment(OpenPaymentConfirmActivity.this, listener, openPayMap); } }); phonenumber.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { checkAndChangeNextBtnState(); // ? if (!isSendVaildate) { if (!phonenumber.getText().toString().equals(phoneNumLastSend)) { notecheck.setText(getResources().getString(R.string.Button_openpay_smsSend)); } else { notecheck.setText(getString(R.string.Button_openpay_smsSend_again)); } } } }); smsCode.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { checkAndChangeNextBtnState(); } }); agreeCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checkAndChangeNextBtnState(); } }); }
From source file:com.code.android.vibevault.SearchScreen.java
private void init() { // Set up the date selection spinner. spinnerAdapter = ArrayAdapter.createFromResource(this, R.array.date_modifier, android.R.layout.simple_spinner_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); dateModifierSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/*ww w. ja v a 2 s . c om*/ public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { VibeVault.dateSearchModifierPos = pos; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); dateModifierSpinner.setAdapter(spinnerAdapter); dateModifierSpinner.setSelection(VibeVault.dateSearchModifierPos); searchDrawer.setOnDrawerScrollListener(new OnDrawerScrollListener() { @Override public void onScrollEnded() { } @Override public void onScrollStarted() { vibrator.vibrate(50); } }); artistSearchInput.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (isMoreSearch(s.toString(), yearSearchInput.getText().toString())) { searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.morebutton), null, null, null); searchButton.setText("More"); } else { searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.searchbutton_plain), null, null, null); searchButton.setText("Search"); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); yearSearchInput.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (isMoreSearch(artistSearchInput.getText().toString(), s.toString())) { searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.morebutton), null, null, null); searchButton.setText("More"); } else { searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.searchbutton_plain), null, null, null); searchButton.setText("Search"); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); searchDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() { @Override public void onDrawerOpened() { searchList.setBackgroundDrawable(getResources().getDrawable(R.drawable.backgrounddrawableblue)); searchList.getBackground().setDither(true); searchList.setEnabled(false); handleText.setText("Search Panel"); handleText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); artistSearchInput.setText(VibeVault.artistSearchText); if (VibeVault.yearSearchInt != -1) { yearSearchInput.setText(String.valueOf(VibeVault.yearSearchInt)); } else { yearSearchInput.setText(""); } dateModifierSpinner.setSelection(VibeVault.dateSearchModifierPos); } }); searchDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener() { @Override public void onDrawerClosed() { searchList.setBackgroundColor(Color.BLACK); searchList.setEnabled(true); handleText.setText("Drag up to search..."); handleText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 28); } }); // Set listeners in the show details and artist search bars for the enter key. OnKeyListener enterListener = new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { if (!(artistSearchInput.getText().toString().equals(""))) { VibeVault.artistSearchText = artistSearchInput.getText().toString(); if (setDate()) { executeSearch(makeSearchURLString(1)); pageNum = 1; searchDrawer.close(); return true; } } } return false; } }; this.artistSearchInput.setOnKeyListener(enterListener); this.searchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String query = artistSearchInput.getText().toString(); // Blank if (query.equals("")) { vibrator.vibrate(50); Toast.makeText(getBaseContext(), "You need a query first...", Toast.LENGTH_SHORT).show(); return; } // Search more else if (isMoreSearch(artistSearchInput.getText().toString(), yearSearchInput.getText().toString())) { searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.morebutton), null, null, null); searchButton.setText("More"); dateModifierSpinner.setSelection(VibeVault.dateSearchModifierPos); // pageNum is incremented then searched with to get the next // page. executeSearch(makeSearchURLString(++pageNum)); vibrator.vibrate(50); searchDrawer.close(); } // New search else { searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.searchbutton_plain), null, null, null); searchButton.setText("Search"); VibeVault.searchResults.clear(); VibeVault.artistSearchText = artistSearchInput.getText().toString(); if (setDate()) { // "1" is passed to retrieve page number 1. vibrator.vibrate(50); executeSearch(makeSearchURLString(1)); pageNum = 1; searchDrawer.close(); } } } }); this.settingsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { launchSettingsDialog(); vibrator.vibrate(50); } }); this.clearButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { artistSearchInput.setText(""); yearSearchInput.setText(""); VibeVault.artistSearchText = ""; VibeVault.yearSearchInt = -1; searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.searchbutton_plain), null, null, null); searchButton.setText("Search"); VibeVault.searchResults.clear(); refreshSearchList(); vibrator.vibrate(50); } }); searchList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { ArchiveShowObj show = (ArchiveShowObj) searchList.getItemAtPosition(position); Intent i = new Intent(SearchScreen.this, ShowDetailsScreen.class); i.putExtra("Show", show); startActivity(i); } }); // Create the directory for our app if it don't exist. appRootDir = new File(Environment.getExternalStorageDirectory(), VibeVault.APP_DIRECTORY); if (!appRootDir.isFile() || !appRootDir.isDirectory()) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { appRootDir.mkdirs(); } else { Toast.makeText(getBaseContext(), "sdcard is unwritable... is it mounted on the computer?", Toast.LENGTH_SHORT).show(); } } artistSearchInput.setText(VibeVault.artistSearchText); if (VibeVault.yearSearchInt != -1) { yearSearchInput.setText(String.valueOf(VibeVault.yearSearchInt)); } else { yearSearchInput.setText(""); } dateModifierSpinner.setSelection(VibeVault.dateSearchModifierPos); }
From source file:com.makotogo.mobile.hoursdroid.HoursDetailFragment.java
private void configureDescription(View view) { EditText descriptionEditText = (EditText) view.findViewById(R.id.edittext_hours_detail_description); descriptionEditText.setText(mHours.getDescription()); descriptionEditText.addTextChangedListener(new TextWatcher() { @Override/*from w ww. j av a 2 s.c om*/ public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Nothing to do } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { mHours.setDescription(s.toString()); } @Override public void afterTextChanged(Editable s) { // Nothing to do } }); }
From source file:com.example.android.contactslist.ui.eventEntry.EventEntryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflates the main layout to be used by this fragment final View detailView = inflater.inflate(R.layout.event_entry_fragment, container, false); // Gets handles to view objects in the layout //mDetailsLayout = (LinearLayout) detailView.findViewById(R.id.contact_details_layout); //mImageView = (ImageView) detailView.findViewById(R.id.contact_image); mEmptyView = (TextView) detailView.findViewById(android.R.id.empty); mDurationView = (Spinner) detailView.findViewById(R.id.edit_duration); mClassSelectionSpinner = (Spinner) detailView.findViewById(R.id.event_class_spinner); mEventNotes = (EditText) detailView.findViewById(R.id.event_notes); mEventNoteCharacterCount = (TextView) detailView.findViewById(R.id.event_note_character_count_view); mAddressTitle = (TextView) detailView.findViewById(R.id.address_title); mEventTypeTitle = (TextView) detailView.findViewById(R.id.event_type_title); mWordCountTitle = (TextView) detailView.findViewById(R.id.word_count_title); mEventDurationTitle = (TextView) detailView.findViewById(R.id.event_duration_title); radioGroup = (RadioGroup) detailView.findViewById(R.id.raidioGroup_incoming_outgoing); mEventDurationLayout = (LinearLayout) detailView.findViewById(R.id.event_duration_layout); mEventWordCountLayout = (LinearLayout) detailView.findViewById(R.id.event_word_count_layout); mWordCountSeekBar = (SeekBar) detailView.findViewById(R.id.word_count_seek_bar); //bUTTONS// w w w. j av a 2 s . c om mDateViewButton = (Button) detailView.findViewById(R.id.edit_date); mTimeViewButton = (Button) detailView.findViewById((R.id.edit_time)); mAddressViewButton = (Button) detailView.findViewById(R.id.address); mWordCountViewButton = (Button) detailView.findViewById(R.id.word_count_button); mIncomingButton = (RadioButton) detailView.findViewById(R.id.radio_incoming_event_type); mOutgoingButton = (RadioButton) detailView.findViewById(R.id.radio_outgoing_event_type); if (mIsTwoPaneLayout) { // If this is a two pane view, the following code changes the visibility of the contact // name in details. For a one-pane view, the contact name is displayed as a title. mContactNameView = (TextView) detailView.findViewById(R.id.contact_name); mContactNameView.setVisibility(View.VISIBLE); } addItemsToClassSpinner(); addItemsToDurationSpinner(); //Display the current date setDateAndTimeViews((long) 0); //Take care of the radio button selection of Event Type radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { // checkedId is the RadioButton selected switch (checkedId) { case R.id.radio_incoming_event_type: mEventType = EventInfo.INCOMING_TYPE; mOutgoingButton.setChecked(false); break; case R.id.radio_outgoing_event_type: mEventType = EventInfo.OUTGOING_TYPE; mIncomingButton.setChecked(false); break; } } }); mAddressViewButton.setOnClickListener(new View.OnClickListener() { // perform function when pressed @Override public void onClick(View v) { editAddressTextDialog(); } }); mWordCountViewButton.setOnClickListener(new View.OnClickListener() { // perform function when pressed @Override public void onClick(View v) { editWordCountTextDialog(); } }); mWordCountSeekBar.setMax(MAX_SEEK_BAR_WORD_COUNT); mWordCountSeekBar.setProgress(mWordCount); mWordCountSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mWordCount = progress; mWordCountViewButton.setText(Integer.toString(progress)); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mEventNotes.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { mEventNoteCharacterCount.setText(Integer.toString((int) mEventNotes.getText().length()) + "/140"); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); fab1 = (FloatingActionButton2) detailView.findViewById(R.id.fab_1); fab1.setOnClickListener(new View.OnClickListener() { // perform function when pressed @Override public void onClick(View view) { // if the event is complete, save to the database and return if (completenessCheck()) { // create the new eventInfo based on this data generateNewEvent(); new Thread(new Runnable() { @Override public void run() { int updateCount = 0; Updates contactUpdate = new Updates(mContext); ArrayList<EventInfo> eventList = new ArrayList<EventInfo>(); eventList.add(mNewEventInfo); // add event to the database and update the contact mContactStats = contactUpdate.updateDataBaseWithContactEvents(mContactStats, eventList); contactUpdate.close(); final boolean insertComplete = (mContactStats != null); getActivity().runOnUiThread(new Runnable() { @Override public void run() { // end by running the final method of the activity finishActivity(insertComplete); } }); } }).start(); } //TODO: do other stuff for tablet } }); return detailView; }
From source file:com.example.zf_android.trade.ApplyDetailActivity.java
/** * firstly init the merchant category with item keys, * and after user select the merchant the values will be set *///w w w. ja v a2 s. c o m private void initMerchantDetailKeys() { // the first category mMerchantKeys = getResources().getStringArray(R.array.apply_detail_merchant_keys); mMerchantContainer.addView(getDetailItem(ITEM_CHOOSE, mMerchantKeys[0], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[1], null)); LinearLayout ll = getDetailItem(ITEM_EDIT, mMerchantKeys[2], null); etMerchantName = (EditText) ll.findViewById(R.id.apply_detail_value); etMerchantName.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) { etBankMerchantName.setText(s.toString()); } @Override public void afterTextChanged(Editable s) { etBankMerchantName.setText(s.toString()); } }); mMerchantContainer.addView(ll); View merchantGender = getDetailItem(ITEM_CHOOSE, mMerchantKeys[3], null); merchantGender.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(ApplyDetailActivity.this); final String[] items = getResources().getStringArray(R.array.apply_detail_gender); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setItemValue(mMerchantKeys[3], items[which]); } }); builder.show(); } }); mMerchantContainer.addView(merchantGender); View merchantBirthday = getDetailItem(ITEM_CHOOSE, mMerchantKeys[4], null); merchantBirthday.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CommonUtil.showDatePicker(ApplyDetailActivity.this, mMerchantBirthday, new CommonUtil.OnDateSetListener() { @Override public void onDateSet(String date) { setItemValue(mMerchantKeys[4], date); } }); } }); mMerchantContainer.addView(merchantBirthday); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[5], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[6], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[7], null)); View merchantCity = getDetailItem(ITEM_CHOOSE, mMerchantKeys[8], null); merchantCity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ApplyDetailActivity.this, CityProvinceActivity.class); intent.putExtra(SELECTED_PROVINCE, mMerchantProvince); intent.putExtra(SELECTED_CITY, mMerchantCity); startActivityForResult(intent, REQUEST_CHOOSE_CITY); } }); mMerchantContainer.addView(merchantCity); // the second category mBankKeys = getResources().getStringArray(R.array.apply_detail_bank_keys); mCustomerContainer.addView(getDetailItem(ITEM_CHOOSE, mBankKeys[0], null)); LinearLayout tmpll = (LinearLayout) mContainer.findViewWithTag(mBankKeys[0]); tmpll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { customTag = mBankKeys[0]; Intent intent = new Intent(ApplyDetailActivity.this, BankList.class); intent.putExtra(AGENT_NAME, mBankName); intent.putExtra("terminalId", mTerminalId); startActivityForResult(intent, REQUEST_CHOOSE_BANK); } }); View bankAccountName = getDetailItem(ITEM_EDIT, mBankKeys[1], null); etBankMerchantName = (EditText) bankAccountName.findViewById(R.id.apply_detail_value); etBankMerchantName.setEnabled(false); mCustomerContainer.addView(bankAccountName); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[2], null)); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[3], null)); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[4], null)); View chooseChannel = getDetailItem(ITEM_CHOOSE, getString(R.string.apply_detail_channel), null); chooseChannel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ApplyDetailActivity.this, ChannelSelecter.class); startActivityForResult(intent, REQUEST_CHOOSE_CHANNEL); } }); mCustomerContainer.addView(chooseChannel); }
From source file:com.gunz.carrental.Fragments.CarsFragment.java
private void clearErrorMsg(Dialog dialog) { for (int i = 0; i < inputField.length; i++) { final MaterialEditText txTmp = (MaterialEditText) dialog.findViewById(inputField[i]); txTmp.addTextChangedListener(new TextWatcher() { @Override//from w ww . j a v a2 s. co m public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (count > 0) { txTmp.setError(null); } } @Override public void afterTextChanged(Editable s) { } }); } }
From source file:com.ieeton.agency.activity.ChatActivity.java
/** * initView//from w w w .j a v a2 s . c o m */ protected void initView() { recordingContainer = findViewById(R.id.recording_container); micImage = (ImageView) findViewById(R.id.mic_image); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice); mBtnQuick = (Button) findViewById(R.id.btn_quick_reply); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(R.id.vPager); expressionContainer = (LinearLayout) findViewById(R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container); locationImgview = (ImageView) findViewById(R.id.btn_location); //iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal); //iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); buttonSend = findViewById(R.id.btn_send); //btnMore = (Button) findViewById(R.id.btn_more); //iv_emoticons_normal.setVisibility(View.VISIBLE); //iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(R.id.more); //edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); mTitleName = (TextView) findViewById(R.id.name); mBtnAdd = (ImageButton) findViewById(R.id.iv_add); mBtnAdd.setOnClickListener(this); mBtnCall = (ImageButton) findViewById(R.id.iv_call); mBtnCall.setOnClickListener(this); mBtnShare = (ImageButton) findViewById(R.id.iv_share); mBtnShare.setOnClickListener(this); mBtnPhoto = (Button) findViewById(R.id.btn_photo); mBtnPhoto.setOnClickListener(this); mBtnQuick.setOnClickListener(this); buttonSend.setOnClickListener(this); mBackBtn = (LinearLayout) findViewById(R.id.ll_back); mBackBtn.setOnClickListener(this); // ?, micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01), getResources().getDrawable(R.drawable.record_animate_02), getResources().getDrawable(R.drawable.record_animate_03), getResources().getDrawable(R.drawable.record_animate_04), getResources().getDrawable(R.drawable.record_animate_05), getResources().getDrawable(R.drawable.record_animate_06), getResources().getDrawable(R.drawable.record_animate_07), getResources().getDrawable(R.drawable.record_animate_08), getResources().getDrawable(R.drawable.record_animate_09), getResources().getDrawable(R.drawable.record_animate_10), getResources().getDrawable(R.drawable.record_animate_11), getResources().getDrawable(R.drawable.record_animate_12), getResources().getDrawable(R.drawable.record_animate_13), getResources().getDrawable(R.drawable.record_animate_14), }; // list reslist = getExpressionRes(35); // ?viewpager List<View> views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); views.add(gv1); views.add(gv2); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); // mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { // // @Override // public void onFocusChange(View v, boolean hasFocus) { // if (hasFocus) { // edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); // } else { // edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); // } // // } // }); mEditTextContent.setImeOptions(EditorInfo.IME_ACTION_SEND); mEditTextContent.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { switch (actionId) { case EditorInfo.IME_ACTION_UNSPECIFIED: case EditorInfo.IME_ACTION_SEND: String s = mEditTextContent.getText().toString(); sendText(s); return true; default: return false; } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); //iv_emoticons_normal.setVisibility(View.VISIBLE); //iv_emoticons_checked.setVisibility(View.INVISIBLE); expressionContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { mBtnQuick.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { mBtnQuick.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
@Override protected void onStart() { super.onStart(); try {/*from ww w . j a va 2s. c o m*/ bodyInput.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub typingcall(); String msg = s.toString().trim(); if (isMultiMediaMsg(msg)) { bodyInput.getText().clear(); Intent intent = new Intent(MessageActivity.this, MessageCopyHandler.class); intent.putExtra("message", msg); intent.putExtra("user_number", stripNumber(prefs.getString(stored_chatuserNumber, ""))); startActivity(intent); } } @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 } }); } catch (Exception e) { // TODO: handle exception } }