List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.android.contacts.common.ContactsUtils.java
/** * Returns true if two {@link Intent}s are both null, or have the same action. */// ww w . ja va2s. c o m public static final boolean areIntentActionEqual(Intent a, Intent b) { if (a == b) { return true; } if (a == null || b == null) { return false; } return TextUtils.equals(a.getAction(), b.getAction()); }
From source file:com.smoothsync.smoothsetup.microfragments.appspecificpassword.AppSpecificWebviewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Nullable/*from w w w .ja v a 2 s . c o m*/ @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View root = inflater.inflate(R.layout.smoothsetup_microfragment_webview, container, false); mWebView = (WebView) root.findViewById(R.id.smoothsetup_webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); mWebView.setOnKeyListener(this); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); mProgress.animate().alpha(0).start(); } }); mWebView.addJavascriptInterface(new AppSpecificPasswordCallback() { @JavascriptInterface @Override public void onAppSpecificPassword(final String appSpecificPassword) { if (!TextUtils.isEmpty(appSpecificPassword) && !TextUtils.equals(mAppSpecificPassword, appSpecificPassword)) { mAppSpecificPassword = appSpecificPassword; mSnackbar = Snackbar .make(mWebView, getString(R.string.smoothsetup_snackbar_found_app_specific_password, appSpecificPassword), Snackbar.LENGTH_INDEFINITE) .setAction(R.string.smoothsetup_button_copy_app_specific_password, mOnCopyPasswordListener); mSnackbar.show(); } } }, "SmoothSetup"); String url = new FragmentEnvironment<Params>(this).microFragment().parameter().uri().toASCIIString(); if (savedInstanceState == null) { mWebView.loadUrl(url); } else { mWebView.restoreState(savedInstanceState); } mPasswordProbe = new DefaultPasswordProbeFactory().forUrl(URI.create(url)); mProgress = (ProgressBar) root.findViewById(android.R.id.progress); // start probing for the password mHandler.postDelayed(mPasswordProbeRunnable, PASSWORD_PROBE_PERIOD); return root; }
From source file:im.vector.util.ThemeUtils.java
/** * Set the activity theme according to the selected one. * * @param activity the activity//from w ww . j a v a 2s. c o m */ public static void setActivityTheme(Activity activity) { if (TextUtils.equals(getApplicationTheme(activity), THEME_DARK_VALUE)) { if (activity instanceof BugReportActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof AccountCreationActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof DeactivateAccountActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Dark); } else if (activity instanceof CountryPickerActivity) { activity.setTheme(R.style.CountryPickerTheme_Dark); } else if (activity instanceof FallbackLoginActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof HistoricalRoomsActivity) { activity.setTheme(R.style.HomeActivityTheme_Dark); } else if (activity instanceof LanguagePickerActivity) { activity.setTheme(R.style.CountryPickerTheme_Dark); } else if (activity instanceof NotificationPrivacyActivity) { activity.setTheme(R.style.CountryPickerTheme_Dark); } else if (activity instanceof LoginActivity) { activity.setTheme(R.style.LoginAppTheme_Dark); } else if (activity instanceof PhoneNumberAdditionActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Dark); } else if (activity instanceof PhoneNumberVerificationActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Dark); } else if (activity instanceof RoomDirectoryPickerActivity) { activity.setTheme(R.style.DirectoryPickerTheme_Dark); } else if (activity instanceof SplashActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Dark); } else if (activity instanceof LoggingOutActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Dark); } else if (activity instanceof VectorBaseSearchActivity) { activity.setTheme(R.style.SearchesAppTheme_Dark); } else if (activity instanceof VectorCallViewActivity) { activity.setTheme(R.style.CallActivityTheme_Dark); } else if (activity instanceof VectorHomeActivity) { activity.setTheme(R.style.HomeActivityTheme_Dark); } else if (activity instanceof VectorMediasPickerActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_FullScreen_Dark); } else if (activity instanceof VectorMediasViewerActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof VectorMemberDetailsActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Dark); } else if (activity instanceof VectorPublicRoomsActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof VectorRoomActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Dark); } else if (activity instanceof VectorRoomCreationActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof VectorRoomDetailsActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof VectorSettingsActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof VectorUniversalLinkActivity) { activity.setTheme(R.style.AppTheme_Dark); } else if (activity instanceof LockScreenActivity) { activity.setTheme(R.style.Vector_Lock_Dark); } else if (activity instanceof VectorGroupDetailsActivity) { activity.setTheme(R.style.AppTheme_Dark); } } if (TextUtils.equals(getApplicationTheme(activity), THEME_BLACK_VALUE)) { if (activity instanceof BugReportActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof AccountCreationActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof DeactivateAccountActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Black); } else if (activity instanceof CountryPickerActivity) { activity.setTheme(R.style.CountryPickerTheme_Black); } else if (activity instanceof FallbackLoginActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof HistoricalRoomsActivity) { activity.setTheme(R.style.HomeActivityTheme_Black); } else if (activity instanceof LanguagePickerActivity) { activity.setTheme(R.style.CountryPickerTheme_Black); } else if (activity instanceof NotificationPrivacyActivity) { activity.setTheme(R.style.CountryPickerTheme_Black); } else if (activity instanceof LoginActivity) { activity.setTheme(R.style.LoginAppTheme_Black); } else if (activity instanceof PhoneNumberAdditionActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Black); } else if (activity instanceof PhoneNumberVerificationActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Black); } else if (activity instanceof RoomDirectoryPickerActivity) { activity.setTheme(R.style.DirectoryPickerTheme_Black); } else if (activity instanceof SplashActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Black); } else if (activity instanceof LoggingOutActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Black); } else if (activity instanceof VectorBaseSearchActivity) { activity.setTheme(R.style.SearchesAppTheme_Black); } else if (activity instanceof VectorCallViewActivity) { activity.setTheme(R.style.CallActivityTheme_Black); } else if (activity instanceof VectorHomeActivity) { activity.setTheme(R.style.HomeActivityTheme_Black); } else if (activity instanceof VectorMediasPickerActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_FullScreen_Black); } else if (activity instanceof VectorMediasViewerActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof VectorMemberDetailsActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Black); } else if (activity instanceof VectorPublicRoomsActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof VectorRoomActivity) { activity.setTheme(R.style.AppTheme_NoActionBar_Black); } else if (activity instanceof VectorRoomCreationActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof VectorRoomDetailsActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof VectorSettingsActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof VectorUniversalLinkActivity) { activity.setTheme(R.style.AppTheme_Black); } else if (activity instanceof LockScreenActivity) { activity.setTheme(R.style.Vector_Lock_Black); } else if (activity instanceof VectorGroupDetailsActivity) { activity.setTheme(R.style.AppTheme_Black); } } if (TextUtils.equals(getApplicationTheme(activity), THEME_LIGHT_VALUE)) { // Specific quirk for quick reply screen if (activity instanceof LockScreenActivity) { activity.setTheme(R.style.Vector_Lock_Light); } } mColorByAttr.clear(); }
From source file:com.android.utils.AutomationUtils.java
/** * Returns whether a node matches the class specified by * {@code className} and exactly match the text or content description * specified by {@code text}./* ww w . j a v a 2s .c om*/ */ private static boolean nodeMatchesFilter(AccessibilityNodeInfoCompat node, CharSequence referenceClassName, String findText) { return ClassLoadingCache.checkInstanceOf(node.getClassName(), referenceClassName) && (TextUtils.equals(findText, node.getText()) || TextUtils.equals(findText, node.getContentDescription())); }
From source file:de.elanev.studip.android.app.frontend.contacts.ContactsGroupsFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (getActivity() == null) { return;//from w ww. j a va 2 s. c o m } List<SectionedCursorAdapter.Section> sections = new ArrayList<SectionedCursorAdapter.Section>(); cursor.moveToFirst(); String prevGroup = null; String currGroup = null; while (!cursor.isAfterLast()) { currGroup = cursor.getString(cursor.getColumnIndex(ContactsContract.Columns.ContactGroups.GROUP_NAME)); if (!TextUtils.equals(currGroup, prevGroup)) { sections.add(new SectionedCursorAdapter.Section(cursor.getPosition(), currGroup)); } prevGroup = currGroup; cursor.moveToNext(); } mUserAdapter.setSections(sections); mUserAdapter.swapCursor(cursor); setLoadingViewVisible(false); }
From source file:cn.code.notes.gtask.remote.GTaskClient.java
public boolean login(Activity activity) { // we suppose that the cookie would expire after 5 minutes // then we need to re-login final long interval = 1000 * 60 * 5; if (mLastLoginTime + interval < System.currentTimeMillis()) { mLoggedin = false;/*from w w w . ja v a 2 s .c o m*/ } // need to re-login after account switch if (mLoggedin && !TextUtils.equals(getSyncAccount().name, SystemEditActivity.getSyncAccountName(activity))) { mLoggedin = false; } if (mLoggedin) { Log.d(TAG, "already logged in"); return true; } mLastLoginTime = System.currentTimeMillis(); String authToken = loginGoogleAccount(activity, false); if (authToken == null) { Log.e(TAG, "login google account failed"); return false; } // login with custom domain if necessary if (!(mAccount.name.toLowerCase().endsWith("gmail.com") || mAccount.name.toLowerCase().endsWith("googlemail.com"))) { StringBuilder url = new StringBuilder(GTASK_URL).append("a/"); int index = mAccount.name.indexOf('@') + 1; String suffix = mAccount.name.substring(index); url.append(suffix + "/"); mGetUrl = url.toString() + "ig"; mPostUrl = url.toString() + "r/ig"; if (tryToLoginGtask(activity, authToken)) { mLoggedin = true; } } // try to login with google official url if (!mLoggedin) { mGetUrl = GTASK_GET_URL; mPostUrl = GTASK_POST_URL; if (!tryToLoginGtask(activity, authToken)) { return false; } } mLoggedin = true; return true; }
From source file:com.foodie.app.fragment.MyMessageFragment.java
private void updateWorksInfo() { if (HttpUtils.isNetworkConnected(getActivity())) { HttpUtils.getWithAuth(getContext(), "works/me/", new AsyncHttpResponseHandler() { @Override//w ww. j a v a2 s . c om public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Gson gson = new Gson(); //Type type = new TypeToken<JsonResult<User>>(){}.getType(); Type type = new TypeToken<JsonListResult<WorksInfo>>() { }.getType(); JsonListResult<WorksInfo> jsonListResult = gson.fromJson(new String(responseBody), type); String status = jsonListResult.getStatus(); worksInfos = jsonListResult.getData(); //Log.v(TAG,data); if (TextUtils.equals(status, Result.SUCCESS) && worksInfos.size() > 0) { //Toast.makeText(getActivity(),"?"+worksInfos.size(),Toast.LENGTH_LONG).show(); Log.i(TAG, new String(responseBody)); worksListView.setAdapter( new MessageListAdapter(getActivity().getApplicationContext(), worksInfos)); return; } else if (TextUtils.equals(status, Result.SUCCESS) && worksInfos.size() == 0) { noDataView.setVisibility(View.VISIBLE); //Toast.makeText(getActivity(),"??",Toast.LENGTH_LONG).show(); } else { //Toast.makeText(getActivity(),"???",Toast.LENGTH_LONG).show(); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { Toast.makeText(getActivity(), "!", Toast.LENGTH_LONG).show(); } }); } else { Toast.makeText(getActivity(), "!", Toast.LENGTH_LONG).show(); } }
From source file:com.foodie.app.fragment.UserListFragment.java
private void updateUsers() { if (HttpUtils.isNetworkConnected(getActivity())) { String url;/*from www . j a v a 2 s . com*/ if (flag != null) { url = flag.equals("allfans") ? "user/allfans/" : "user/allfollow/"; } else { return; } HttpUtils.getWithAuth(getContext(), url, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Gson gson = new Gson(); //Type type = new TypeToken<JsonResult<User>>(){}.getType(); Type type = new TypeToken<JsonListResult<User>>() { }.getType(); JsonListResult<User> jsonListResult = gson.fromJson(new String(responseBody), type); String status = jsonListResult.getStatus(); String tipCode = jsonListResult.getTipCode(); users = jsonListResult.getData(); //Log.v(TAG,data); if (TextUtils.equals(status, Result.SUCCESS) && users.size() > 0) { //Toast.makeText(getActivity(),"?"+worksInfos.size(),Toast.LENGTH_LONG).show(); Log.i("UserListFragment", new String(responseBody)); rv.setAdapter(new UserListAdapter(getContext(), users)); return; } else if (TextUtils.equals(status, Result.SUCCESS) && users.size() == 0) { noDataView.setVisibility(View.VISIBLE); return; } else if (TextUtils.equals(status, Result.FAILED) && TextUtils.equals(tipCode, "null")) { Log.i("UserListFragment", new String(responseBody)); } else { //Toast.makeText(getActivity(),"??",Toast.LENGTH_LONG).show(); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { Toast.makeText(getActivity(), "", Toast.LENGTH_LONG).show(); } }); } else { Toast.makeText(getActivity(), "!", Toast.LENGTH_LONG).show(); } }
From source file:com.example.simba.myapplicationnote.gtask.remote.GTaskClient.java
public boolean login(Activity activity) { // we suppose that the cookie would expire after 5 minutes // then we need to re-login final long interval = 1000 * 60 * 5; if (mLastLoginTime + interval < System.currentTimeMillis()) { mLoggedin = false;/*www . jav a 2s.co m*/ } // need to re-login after account switch if (mLoggedin && !TextUtils.equals(getSyncAccount().name, NotesPreferenceActivity.getSyncAccountName(activity))) { mLoggedin = false; } if (mLoggedin) { Log.d(TAG, "already logged in"); return true; } mLastLoginTime = System.currentTimeMillis(); String authToken = loginGoogleAccount(activity, false); if (authToken == null) { Log.e(TAG, "login google account failed"); return false; } // login with custom domain if necessary if (!(mAccount.name.toLowerCase().endsWith("gmail.com") || mAccount.name.toLowerCase().endsWith("googlemail.com"))) { StringBuilder url = new StringBuilder(GTASK_URL).append("a/"); int index = mAccount.name.indexOf('@') + 1; String suffix = mAccount.name.substring(index); url.append(suffix + "/"); mGetUrl = url.toString() + "ig"; mPostUrl = url.toString() + "r/ig"; if (tryToLoginGtask(activity, authToken)) { mLoggedin = true; } } // try to login with google official url if (!mLoggedin) { mGetUrl = GTASK_GET_URL; mPostUrl = GTASK_POST_URL; if (!tryToLoginGtask(activity, authToken)) { return false; } } mLoggedin = true; return true; }
From source file:info.guardianproject.otr.app.im.app.WelcomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = (ImApp) getApplication();//w w w .j ava2 s .c om mHandler = new MyHandler(this); mSignInHelper = new SignInHelper(this); Intent intent = getIntent(); mDoSignIn = intent.getBooleanExtra("doSignIn", true); mDoLock = intent.getBooleanExtra("doLock", false); if (!mDoLock) { mApp.maybeInit(this); } if (ImApp.mUsingCacheword) connectToCacheWord(); else { if (openEncryptedStores(null, false)) { IocVfs.init(this, ""); } else { connectToCacheWord(); //first time setup } } // if we have an incoming contact, send it to the right place String scheme = intent.getScheme(); if (TextUtils.equals(scheme, "xmpp")) { intent.setClass(this, AddContactActivity.class); startActivity(intent); finish(); return; } }