List of usage examples for java.lang CharSequence length
int length();
From source file:com.springsource.greenhouse.twitter.PostTweetActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.post_tweet); textViewCount = (TextView) this.findViewById(R.id.post_tweet_count); textWatcher = new TextWatcher() { public void beforeTextChanged(CharSequence s, int start, int count, int after) { }/*from w ww.j a va2s.co m*/ public void onTextChanged(CharSequence s, int start, int before, int count) { textViewCount.setText(String.valueOf(MAX_TWEET_LENGTH - s.length())); } public void afterTextChanged(Editable s) { } }; final EditText editText = (EditText) findViewById(R.id.post_tweet_text); editText.addTextChangedListener(textWatcher); final Button button = (Button) findViewById(R.id.post_tweet_button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // hide the soft keypad InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); EditText editText = (EditText) findViewById(R.id.post_tweet_text); inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0); new PostTweetTask().execute(); } }); }
From source file:com.acceleratedio.pac_n_zoom.SaveAnmActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_save_anm); EventBus.getDefault().register(this); crt_ctx = this; tagText = (EditText) findViewById(R.id.sav_tags); tagText.addTextChangedListener(new TextWatcher() { @Override/*from w w w .j av a 2s . co m*/ public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence key_sqnc, int start, int before, int count) { final StringBuilder strBldr = new StringBuilder(key_sqnc.length()); strBldr.append(key_sqnc); srch_str = strBldr.toString(); dsply_tags(); } @Override public void afterTextChanged(Editable s) { } }); tagText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; tags_str = tagText.getText().toString(); if (actionId == EditorInfo.IME_ACTION_SEND) { progress = ProgressDialog.show(crt_ctx, "Saving the animation", "dialog message", true); MakePostRequest savAnimation = new MakePostRequest(); savAnimation.execute(); handled = true; } return handled; } }); fil_tags = PickAnmActivity.orgnl_tags.split("(\\s*,\\s*)|(\\s* \\s*)"); Arrays.sort(fil_tags, String.CASE_INSENSITIVE_ORDER); dsply_tags(); }
From source file:com.springsource.greenhouse.events.sessions.EventSessionRatingActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.event_session_rating); textViewCount = (TextView) this.findViewById(R.id.event_session_rating_count); textWatcher = new TextWatcher() { public void beforeTextChanged(CharSequence s, int start, int count, int after) { }/*from w ww . j a va 2 s . co m*/ public void onTextChanged(CharSequence s, int start, int before, int count) { textViewCount.setText(String.valueOf(MAX_LENGTH - s.length())); } public void afterTextChanged(Editable s) { } }; final EditText editText = (EditText) findViewById(R.id.event_session_rating_text); editText.addTextChangedListener(textWatcher); final Button submitButton = (Button) findViewById(R.id.event_session_rating_submit); submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // hide the soft keypad InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); EditText editText = (EditText) findViewById(R.id.event_session_rating_text); inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0); submitRating(); } }); final Button selectStartButton = (Button) findViewById(R.id.event_session_rating_select_star); selectStartButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showSelectStarRatingDialog(); } }); }
From source file:dk.teachus.backend.test.CreateMysqlTestDatabase.java
private List<String> parseSqlIntoSingleStatements(CharSequence sql) { List<String> statements = new ArrayList<String>(); StringBuilder statement = new StringBuilder(); boolean escape = false; boolean quote = false; for (int n = 0; n < sql.length(); n++) { char currentChar = sql.charAt(n); switch (currentChar) { case '"': case '`': case '\'': if (escape == false) { quote = quote == false;/*from w ww .ja v a 2 s. co m*/ } escape = false; statement.append(currentChar); break; case '\\': escape = escape == false; statement.append(currentChar); break; case ';': if (quote == false) { statements.add(statement.toString()); statement = new StringBuilder(); } break; default: statement.append(currentChar); } } String sqlStatement = statement.toString(); sqlStatement = sqlStatement.trim(); if (sqlStatement.length() > 0) { statements.add(sqlStatement); } return statements; }
From source file:de.cosmocode.lucene.DefaultLuceneQuery.java
@Override public DefaultLuceneQuery addSubquery(final LuceneQuery value, final QueryModifier modifier) { if (value == null) { setLastSuccessful(false);/*from www. j a va 2 s. c o m*/ return this; } final CharSequence subQuery = value.getQuery(); if (subQuery.length() == 0) { setLastSuccessful(false); return this; } queryArguments.append(modifier.getTermPrefix()); queryArguments.append("(").append(subQuery).append(") "); setLastSuccessful(true); return this; }
From source file:com.asakusafw.runtime.io.csv.CsvEmitter.java
private void appendEscaped(StringBuilder buffer, CharSequence string) { buffer.append(ESCAPE);/*www .java 2s . c o m*/ for (int i = 0, n = string.length(); i < n; i++) { char c = string.charAt(i); if (c == ESCAPE) { buffer.append(ESCAPE); } buffer.append(c); } buffer.append(ESCAPE); }
From source file:br.msf.commons.util.CharSequenceUtils.java
/** * Indicates if the given sequence is <b>null OR empty</b>. * * @param sequence The sequence to be analysed. * @return {@code true} if, and only if, the given sequence is <b>null OR empty</b>. *//*from w ww .j a va2 s. c o m*/ public static boolean isEmptyOrNull(final CharSequence sequence) { return sequence == null || sequence.length() == 0; }
From source file:onl.area51.httpd.action.Response.java
default Response write(CharSequence seq) throws IOException { return write(seq, 0, seq.length()); }
From source file:br.msf.commons.util.CharSequenceUtils.java
public static int indexOfLastChar(final CharSequence sequence) { return (isNotEmpty(sequence)) ? (sequence.length() - 1) : -1; }
From source file:de.cosmocode.lucene.DefaultLuceneQuery.java
@Override public DefaultLuceneQuery addUnescaped(final CharSequence value, final boolean mandatory) { if (value == null || value.length() == 0) { setLastSuccessful(false);/*ww w . j a v a2s .c o m*/ return this; } if (mandatory) queryArguments.append("+"); queryArguments.append(value).append(" "); setLastSuccessful(true); return this; }