List of usage examples for java.lang CharSequence length
int length();
From source file:com.easemob.chatuidemo.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from www . java 2s . c o m*/ 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); getView().findViewById(R.id.back).setOnClickListener(this); //??? 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 = ((DemoHXSDKHelper) 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)); // } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); 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; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { 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(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:com.uzmap.pkg.uzmodules.UISearchBar.SearchBarActivity.java
public boolean isEmpty(CharSequence cs) { return (cs == null) || (cs.length() == 0); }
From source file:br.msf.commons.util.CharSequenceUtils.java
@SuppressWarnings("unchecked") public static List<MatchEntry> find(final CharSequence toSearch, final CharSequence sequence, final Boolean caseSensitive) { if (isEmptyOrNull(toSearch) || isEmptyOrNull(sequence)) { return CollectionUtils.EMPTY_LIST; }//from w w w . j a va 2s.c o m final List<MatchEntry> occurrences = new ArrayList<MatchEntry>(); int start = indexOf(toSearch, 0, sequence, caseSensitive); while (start >= 0) { int end = start + toSearch.length(); occurrences.add(new MatchEntry(start, end)); start = indexOf(toSearch, end, sequence, caseSensitive); } return occurrences; }
From source file:com.cyberway.issue.extractor.RegexpHTMLLinkExtractor.java
protected void processScript(CharSequence sequence, int endOfOpenTag) { // first, get attributes of script-open tag // as per any other tag processGeneralTag(sequence.subSequence(0, 6), sequence.subSequence(0, endOfOpenTag)); // then, apply best-effort string-analysis heuristics // against any code present (false positives are OK) processScriptCode(sequence.subSequence(endOfOpenTag, sequence.length())); }
From source file:com.uzmap.pkg.uzmodules.UISearchBar.SearchBarActivity.java
public boolean isBlank(CharSequence cs) { int strLen;//from w w w .j a v a 2s. co m if ((cs == null) || ((strLen = cs.length()) == 0)) return true; for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; }
From source file:eu.edisonproject.training.wsd.DisambiguatorImpl.java
private Set<String> getDocument(Term term) throws IOException, MalformedURLException, ParseException { Set<String> doc = new HashSet<>(); List<CharSequence> g = term.getGlosses(); if (g != null) { for (CharSequence s : g) { if (s != null && s.length() > 0) { s = s.toString().replaceAll("_", " "); tokenizer.setDescription(s.toString()); String cleanText = tokenizer.execute(); lematizer.setDescription(cleanText); String lematizedText = lematizer.execute(); // cleaner.setDescription(s.toString()); // String stemed = cleaner.execute(); doc.addAll(Arrays.asList(lematizedText.split(" "))); }// w w w. jav a2s . c o m } } List<CharSequence> al = term.getAltLables(); if (al != null) { for (CharSequence s : al) { if (s != null && s.length() > 0) { // cleaner.setDescription(s.toString()); // String stemed = cleaner.execute(); s = s.toString().replaceAll("_", " "); tokenizer.setDescription(s.toString()); String cleanText = tokenizer.execute(); lematizer.setDescription(cleanText); String lematizedText = lematizer.execute(); doc.addAll(Arrays.asList(lematizedText.split(" "))); } } } List<CharSequence> cat = term.getCategories(); if (cat != null) { for (CharSequence s : cat) { if (s != null && s.length() > 0) { s = s.toString().replaceAll("_", " "); // cleaner.setDescription(s.toString()); // String stemed = cleaner.execute(); tokenizer.setDescription(s.toString()); String cleanText = tokenizer.execute(); lematizer.setDescription(cleanText); String lematizedText = lematizer.execute(); doc.addAll(Arrays.asList(lematizedText.split(" "))); } } } return doc; }
From source file:org.deviceconnect.android.uiapp.fragment.profile.ExtraProfileFragment.java
/** * ??.//from w w w . j a va2 s. c o m * @param view ? */ protected void onClickSend(final View view) { // final CharSequence inter = ((TextView) getView().findViewById(R.id.fragment_extra_interface)).getText(); // final CharSequence attr = ((TextView) getView().findViewById(R.id.fragment_extra_attribute)).getText(); // final String accessToken = getAccessToken(); // final CharSequence query = ((TextView) getView().findViewById(R.id.fragment_extra_query)).getText(); final URIBuilder builder = new URIBuilder(); builder.setProfile(mProfile); if (inter != null && inter.length() > 0) { builder.setInterface(inter.toString()); } if (attr != null && attr.length() > 0) { builder.setAttribute(attr.toString()); } builder.addParameter(DConnectMessage.EXTRA_DEVICE_ID, getSmartDevice().getId()); if (accessToken != null) { builder.addParameter(DConnectMessage.EXTRA_ACCESS_TOKEN, accessToken); } if (query != null) { String path = query.toString(); if (path.length() > 0) { String[] keyvalues = path.split("&"); for (int i = 0; i < keyvalues.length; i++) { String[] kv = keyvalues[i].split("="); if (kv.length == 1) { builder.addParameter(kv[0], ""); } else if (kv.length == 2) { builder.addParameter(kv[0], kv[1]); } } } } HttpRequest request = null; try { Spinner spinner = (Spinner) getView().findViewById(R.id.spinner); String method = (String) spinner.getSelectedItem(); if (method.equals("GET")) { request = new HttpGet(builder.build()); } else if (method.equals("POST")) { request = new HttpPost(builder.build()); } else if (method.equals("PUT")) { request = new HttpPut(builder.build()); } else if (method.equals("DELETE")) { request = new HttpDelete(builder.build()); } getActivity().runOnUiThread(new Runnable() { @Override public void run() { TextView tv = (TextView) getView().findViewById(R.id.fragment_extra_request); try { String uri = builder.build().toASCIIString(); tv.setText(uri); } catch (URISyntaxException e) { tv.setText(""); } } }); } catch (URISyntaxException e) { e.printStackTrace(); } (new AsyncTask<HttpRequest, Void, DConnectMessage>() { public DConnectMessage doInBackground(final HttpRequest... args) { if (args == null || args.length <= 0) { return new DConnectResponseMessage(DConnectMessage.RESULT_ERROR); } DConnectMessage message = new DConnectResponseMessage(DConnectMessage.RESULT_ERROR); try { HttpRequest request = args[0]; HttpResponse response = getDConnectClient().execute(getDefaultHost(), request); message = (new HttpMessageFactory()).newDConnectMessage(response); } catch (IOException e) { e.printStackTrace(); } return message; } @Override protected void onPostExecute(final DConnectMessage result) { if (getActivity().isFinishing()) { return; } if (result == null) { return; } View view = getView(); if (view != null) { TextView tv = (TextView) view.findViewById(R.id.fragment_extra_response); tv.setText(result.toString()); } } }).execute(request); }
From source file:eu.stratosphere.types.StringValue.java
@Override public Appendable append(CharSequence csq) { append(csq, 0, csq.length()); return this; }
From source file:com.cyberway.issue.crawler.extractor.ExtractorHTML.java
/** * Handle generic HREF cases.//from ww w. j a v a 2s . co m * * @param curi * @param value * @param context */ protected void processLink(CrawlURI curi, final CharSequence value, CharSequence context) { if (TextUtils.matches(JAVASCRIPT, value) || TextUtils.matches(JAVASCRIPT2, value)) { processScriptCode(curi, value.subSequence(11, value.length())); } else { if (logger.isLoggable(Level.FINEST)) { logger.finest("link: " + value.toString() + " from " + curi); } addLinkFromString(curi, (value instanceof String) ? (String) value : value.toString(), context, Link.NAVLINK_HOP); this.numberOfLinksExtracted++; } }
From source file:eu.stratosphere.types.StringValue.java
/** * Sets the value of the StringValue to the given string. * /*w ww . ja va 2 s. co m*/ * @param value The new string value. */ public void setValue(CharSequence value) { Validate.notNull(value); setValue(value, 0, value.length()); }