Java Code Examples for android.text.TextUtils
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { super.onPopulateAccessibilityEvent(event); } final CharSequence cdesc=getContentDescription(); if (!TextUtils.isEmpty(cdesc)) { event.getText().add(cdesc); } }
Example 2
From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { super.onPopulateAccessibilityEvent(event); } final CharSequence cdesc=getContentDescription(); if (!TextUtils.isEmpty(cdesc)) { event.getText().add(cdesc); } }
Example 3
From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { super.onPopulateAccessibilityEvent(event); } final CharSequence cdesc=getContentDescription(); if (!TextUtils.isEmpty(cdesc)) { event.getText().add(cdesc); } }
Example 4
From project agit, under directory /agit/src/main/java/com/madgag/agit/.
Source file: BlobViewFragment.java

private String dressFileContentForWebView(String decode){ GoogleCodePrettify googleCodePrettify=new GoogleCodePrettify(); String boom=TextUtils.htmlEncode(decode).replace("\n","<br>"); String contentString=""; contentString+="<html><head>"; for ( String css : googleCodePrettify.getCssFiles()) { contentString+="<link href='file:///android_asset/" + css + "' rel='stylesheet' type='text/css'/>"; } for ( String js : googleCodePrettify.getJsFiles()) { contentString+="<script src='file:///android_asset/" + js + "' type='text/javascript'></script> "; } contentString+="</head><body onload='prettyPrint()'><pre class='prettyprint'>"; contentString+=boom; contentString+="</pre></body></html>"; return contentString; }
Example 5
From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { super.onPopulateAccessibilityEvent(event); } final CharSequence cdesc=getContentDescription(); if (!TextUtils.isEmpty(cdesc)) { event.getText().add(cdesc); } }
Example 6
From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/app/.
Source file: AmenoidApp.java

@Override public void onCreate(){ this.cache=new SimpleWebImageCache<ThumbnailBus,ThumbnailMessage>(null,null,101,bus); Config.init(getApplicationContext()); DEVELOPER_MODE=getResources().getBoolean(R.bool.debuggable); if (getResources().getBoolean(R.bool.strict)) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyDropBox().penaltyLog().build()); } super.onCreate(); prefs=PreferenceManager.getDefaultSharedPreferences(this); amenTypeThin=Typeface.createFromAsset(getAssets(),"fonts/AmenTypeThin.ttf"); amenTypeBold=Typeface.createFromAsset(getAssets(),"fonts/AmenTypeBold.ttf"); instance=this; builder=new AlertDialog.Builder(this); Log.v(TAG,"onCreate"); final String authToken=readAuthTokenFromPrefs(prefs); final User me=readMeFromPrefs(prefs); String email=prefs.getString(Constants.PREFS_EMAIL,null); if (TextUtils.isEmpty(email)) { email=prefs.getString(Constants.PREFS_USER_NAME,""); if (!TextUtils.isEmpty(email) && email.contains("@")) { SharedPreferences.Editor editor=prefs.edit(); editor.putString(Constants.PREFS_EMAIL,email); editor.commit(); } } final String password=prefs.getString(Constants.PREFS_PASSWORD,null); if (authToken != null && me != null) { configureAmenService(); service.init(authToken,me); } else if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) { getService(email,password); } else { getService(); } }
Example 7
From project and-bible, under directory /AndBible/src/net/bible/service/db/bookmark/.
Source file: BookmarkDBAdapter.java

/** * return Dto from current cursor position or null * @param c * @return * @throws NoSuchKeyException */ private BookmarkDto getBookmarkDto(Cursor c){ BookmarkDto dto=new BookmarkDto(); try { Long id=c.getLong(BookmarkQuery.ID); dto.setId(id); String key=c.getString(BookmarkQuery.KEY); if (!TextUtils.isEmpty(key)) { dto.setKey(PassageKeyFactory.instance().getKey(key)); } } catch ( NoSuchKeyException nke) { Log.e(TAG,"Key error",nke); } return dto; }
Example 8
From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { super.onPopulateAccessibilityEvent(event); } final CharSequence cdesc=getContentDescription(); if (!TextUtils.isEmpty(cdesc)) { event.getText().add(cdesc); } }
Example 9
From project Android, under directory /app/src/main/java/com/github/mobile/accounts/.
Source file: AccountAuthenticator.java

@Override public Bundle getAuthToken(AccountAuthenticatorResponse response,Account account,String authTokenType,Bundle options) throws NetworkErrorException { final Bundle bundle=new Bundle(); if (!ACCOUNT_TYPE.equals(authTokenType)) return bundle; AccountManager am=AccountManager.get(context); String username=account.name; String password=am.getPassword(account); if (TextUtils.isEmpty(password)) { bundle.putParcelable(KEY_INTENT,createLoginIntent(response)); return bundle; } DefaultClient client=new DefaultClient(); client.setCredentials(username,password); OAuthService service=new OAuthService(client); List<String> scopes=Arrays.asList("repo","user","gist"); try { String authToken=getAuthorization(service,scopes); if (TextUtils.isEmpty(authToken)) authToken=createAuthorization(service,scopes); if (TextUtils.isEmpty(authToken)) bundle.putParcelable(KEY_INTENT,createLoginIntent(response)); else { bundle.putString(KEY_ACCOUNT_NAME,account.name); bundle.putString(KEY_ACCOUNT_TYPE,ACCOUNT_TYPE); bundle.putString(KEY_AUTHTOKEN,authToken); am.clearPassword(account); } return bundle; } catch ( IOException e) { Log.e(TAG,e.getMessage()); throw new NetworkErrorException(e); } }
Example 10
From project android-async-http, under directory /src/com/loopj/android/http/.
Source file: PersistentCookieStore.java

/** * Construct a persistent cookie store. */ public PersistentCookieStore(Context context){ cookiePrefs=context.getSharedPreferences(COOKIE_PREFS,0); cookies=new ConcurrentHashMap<String,Cookie>(); String storedCookieNames=cookiePrefs.getString(COOKIE_NAME_STORE,null); if (storedCookieNames != null) { String[] cookieNames=TextUtils.split(storedCookieNames,","); for ( String name : cookieNames) { String encodedCookie=cookiePrefs.getString(COOKIE_NAME_PREFIX + name,null); if (encodedCookie != null) { Cookie decodedCookie=decodeCookie(encodedCookie); if (decodedCookie != null) { cookies.put(name,decodedCookie); } } } clearExpired(new Date()); } }
Example 11
From project android-bankdroid, under directory /src/com/liato/bankdroid/lockpattern/.
Source file: LockPatternUtils.java

/** * @return A formatted string of the next alarm (for showing on the lock screen),or null if there is no next alarm. */ public String getNextAlarm(){ String nextAlarm=Settings.System.getString(mContentResolver,Settings.System.NEXT_ALARM_FORMATTED); if (nextAlarm == null || TextUtils.isEmpty(nextAlarm)) { return null; } return nextAlarm; }
Example 12
From project android-client_1, under directory /src/com/googlecode/asmack/connection/impl/.
Source file: FeatureNegotiationEngine.java

/** * Bind a given resource, probably resuming an old session. * @param resource String The preferred resource string. * @return String The actual resource string. * @throws XmppException On Error. */ public String bind(String resource) throws XmppException { Log.d("BC/XMPP/Negotiation","bind " + resource); try { if (!TextUtils.isEmpty(resource)) { xmppOutput.sendUnchecked("<iq type=\"set\" id=\"bind_1\">" + "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" + "<resource>" + resource + "</resource>"+ "</bind>"+ "</iq>"); } else { xmppOutput.sendUnchecked("<iq type=\"set\" id=\"bind_1\">" + "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" + "</bind>"+ "</iq>"); } Stanza stanza=xmppInput.nextStanza(); Node node=XMLUtils.getDocumentNode(stanza.getXml()); Node bind=XMLUtils.getFirstChild(node,"urn:ietf:params:xml:ns:xmpp-bind","bind"); Node jid=XMLUtils.getFirstChild(bind,null,"jid"); if (sessionsSupported) { startSession(); } return jid.getTextContent(); } catch ( IllegalArgumentException e) { throw new XmppMalformedException("bind malformed",e); } catch ( IllegalStateException e) { throw new XmppMalformedException("bind malformed",e); } catch ( SAXException e) { throw new XmppMalformedException("bind malformed",e); } }
Example 13
From project android-context, under directory /src/edu/fsu/cs/contextprovider/.
Source file: ContextProvider.java

@Override public Cursor query(Uri url,String[] projection,String selection,String[] selectionArgs,String sort){ SQLiteQueryBuilder qb=new SQLiteQueryBuilder(); qb.setTables(getTableName()); if (isCollectionUri(url)) { qb.setProjectionMap(getDefaultProjection()); } else { qb.appendWhere(getIdColumnName() + "=" + url.getPathSegments().get(1)); } String orderBy; if (TextUtils.isEmpty(sort)) { orderBy=getDefaultSortOrder(); } else { orderBy=sort; } Cursor c=qb.query(db,projection,selection,selectionArgs,null,null,orderBy); c.setNotificationUri(getContext().getContentResolver(),url); return c; }
Example 14
From project android-database-sqlcipher, under directory /src/net/sqlcipher/database/.
Source file: SQLiteDatabase.java

/** * Finds the name of the first table, which is editable. * @param tables a list of tables * @return the first table listed */ public static String findEditTable(String tables){ if (!TextUtils.isEmpty(tables)) { int spacepos=tables.indexOf(' '); int commapos=tables.indexOf(','); if (spacepos > 0 && (spacepos < commapos || commapos < 0)) { return tables.substring(0,spacepos); } else if (commapos > 0 && (commapos < spacepos || spacepos < 0)) { return tables.substring(0,commapos); } return tables; } else { throw new IllegalStateException("Invalid tables"); } }
Example 15
From project android-joedayz, under directory /Proyectos/FBConnectTest/src/com/facebook/android/.
Source file: Facebook.java

/** * Internal method to handle single sign-on backend for authorize(). * @param activity The Android Activity that will parent the ProxyAuth Activity. * @param applicationId The Facebook application identifier. * @param permissions A list of permissions required for this application. If you do not require any permissions, pass an empty String array. * @param activityCode Activity code to uniquely identify the result Intent in the callback. */ private boolean startSingleSignOn(Activity activity,String applicationId,String[] permissions,int activityCode){ boolean didSucceed=true; Intent intent=new Intent(); intent.setClassName("com.facebook.katana","com.facebook.katana.ProxyAuth"); intent.putExtra("client_id",applicationId); if (permissions.length > 0) { intent.putExtra("scope",TextUtils.join(",",permissions)); } if (!validateActivityIntent(activity,intent)) { return false; } mAuthActivity=activity; mAuthPermissions=permissions; mAuthActivityCode=activityCode; try { activity.startActivityForResult(intent,activityCode); } catch ( ActivityNotFoundException e) { didSucceed=false; } return didSucceed; }
Example 16
From project android-pulltorefresh, under directory /library/src/com/handmark/pulltorefresh/library/internal/.
Source file: LoadingLayout.java

public void reset(){ mHeaderText.setText(mPullLabel); mHeaderImage.setVisibility(View.VISIBLE); if (mUseIntrinisicAnimation) { ((AnimationDrawable)mHeaderImage.getDrawable()).stop(); } else { mHeaderImage.clearAnimation(); } resetImageRotation(); if (TextUtils.isEmpty(mSubHeaderText.getText())) { mSubHeaderText.setVisibility(View.GONE); } else { mSubHeaderText.setVisibility(View.VISIBLE); } }
Example 17
From project android-service-arch, under directory /ServiceFramework/src/ru/evilduck/framework/handlers/impl/.
Source file: TestActionHandler.java

@Override public void doExecute(Intent intent,Context context,ResultReceiver callback){ String arg1=intent.getStringExtra(EXTRA_PARAM_1); String arg2=intent.getStringExtra(EXTRA_PARAM_2); Bundle data=new Bundle(); try { Thread.sleep(2000); } catch ( InterruptedException e) { Log.wtf(TAG,"WTF"); } if (TextUtils.isEmpty(arg1) || TextUtils.isEmpty(arg2)) { data.putString("error","Surprise mothafucka!"); sendUpdate(RESPONSE_FAILURE,data); } else { data.putString("data",arg1 + arg2); sendUpdate(RESPONSE_SUCCESS,data); } }
Example 18
From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/core/model/.
Source file: Context.java

public final boolean isInitialized(){ if (TextUtils.isEmpty(mName)) { return false; } return true; }
Example 19
From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/facebook/extpack/com/facebook/android/.
Source file: Facebook.java

/** * Internal method to handle single sign-on backend for authorize(). * @param activity The Android Activity that will parent the ProxyAuth Activity. * @param applicationId The Facebook application identifier. * @param permissions A list of permissions required for this application. If you do not require any permissions, pass an empty String array. * @param activityCode Activity code to uniquely identify the result Intent in the callback. */ private boolean startSingleSignOn(Activity activity,String applicationId,String[] permissions,int activityCode){ boolean didSucceed=true; Intent intent=new Intent(); intent.setClassName("com.facebook.katana","com.facebook.katana.ProxyAuth"); intent.putExtra("client_id",applicationId); if (permissions.length > 0) { intent.putExtra("scope",TextUtils.join(",",permissions)); } if (!validateAppSignatureForIntent(activity,intent)) { return false; } mAuthActivity=activity; mAuthPermissions=permissions; mAuthActivityCode=activityCode; try { activity.startActivityForResult(intent,activityCode); } catch ( ActivityNotFoundException e) { didSucceed=false; } return didSucceed; }
Example 20
From project Android-SyncAdapter-JSON-Server-Example, under directory /src/com/example/android/samplesync/authenticator/.
Source file: AuthenticatorActivity.java

/** * Handles onClick event on the Submit button. Sends username/password to the server for authentication. * @param view The Submit button for which this method is invoked */ public void handleLogin(View view){ if (mRequestNewAccount) { mUsername=mUsernameEdit.getText().toString(); } mPassword=mPasswordEdit.getText().toString(); if (TextUtils.isEmpty(mUsername) || TextUtils.isEmpty(mPassword)) { mMessage.setText(getMessage()); } else { showProgress(); mAuthThread=NetworkUtilities.attemptAuth(mUsername,mPassword,mHandler,AuthenticatorActivity.this); } }
Example 21
From project android-tether, under directory /facebook/src/com/facebook/android/.
Source file: Facebook.java

/** * Internal method to handle single sign-on backend for authorize(). * @param activity The Android Activity that will parent the ProxyAuth Activity. * @param applicationId The Facebook application identifier. * @param permissions A list of permissions required for this application. If you do not require any permissions, pass an empty String array. * @param activityCode Activity code to uniquely identify the result Intent in the callback. */ private boolean startSingleSignOn(Activity activity,String applicationId,String[] permissions,int activityCode){ boolean didSucceed=true; Intent intent=new Intent(); intent.setClassName("com.facebook.katana","com.facebook.katana.ProxyAuth"); intent.putExtra("client_id",applicationId); if (permissions.length > 0) { intent.putExtra("scope",TextUtils.join(",",permissions)); } if (!validateAppSignatureForIntent(activity,intent)) { return false; } mAuthActivity=activity; mAuthPermissions=permissions; mAuthActivityCode=activityCode; try { activity.startActivityForResult(intent,activityCode); } catch ( ActivityNotFoundException e) { didSucceed=false; } return didSucceed; }
Example 22
From project android-thaiime, under directory /common/src/com/android/common/contacts/.
Source file: BaseEmailAddressAdapter.java

@Override protected FilterResults performFiltering(CharSequence constraint){ Cursor directoryCursor=null; if (!mDirectoriesLoaded) { directoryCursor=mContentResolver.query(DirectoryListQuery.URI,DirectoryListQuery.PROJECTION,null,null,null); mDirectoriesLoaded=true; } FilterResults results=new FilterResults(); Cursor cursor=null; if (!TextUtils.isEmpty(constraint)) { Uri.Builder builder=Email.CONTENT_FILTER_URI.buildUpon().appendPath(constraint.toString()).appendQueryParameter(LIMIT_PARAM_KEY,String.valueOf(mPreferredMaxResultCount)); if (mAccount != null) { builder.appendQueryParameter(PRIMARY_ACCOUNT_NAME,mAccount.name); builder.appendQueryParameter(PRIMARY_ACCOUNT_TYPE,mAccount.type); } Uri uri=builder.build(); cursor=mContentResolver.query(uri,EmailQuery.PROJECTION,null,null,null); results.count=cursor.getCount(); } results.values=new Cursor[]{directoryCursor,cursor}; return results; }