List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.bayapps.android.robophish.ui.tv.TvPlaybackFragment.java
private boolean equalsQueue(List<MediaSessionCompat.QueueItem> list1, List<MediaSessionCompat.QueueItem> list2) { if (list1 == list2) { return true; }//from w ww. j ava 2s . co m if (list1 == null || list2 == null) { return false; } if (list1.size() != list2.size()) { return false; } for (int i = 0; i < list1.size(); i++) { if (list1.get(i).getQueueId() != list2.get(i).getQueueId()) { return false; } if (!TextUtils.equals(list1.get(i).getDescription().getMediaId(), list2.get(i).getDescription().getMediaId())) { return false; } } return true; }
From source file:com.citrus.sdk.fragments.Netbanking.java
private void initiateTxn() { taskExecuted = new JSONTaskComplete() { @Override// w w w. j av a 2s . co m public void onTaskExecuted(JSONObject[] paymentObject, String message) { if (TextUtils.equals(message, "success")) { try { String url = paymentObject[0].getString("redirectUrl"); Intent intent = new Intent(getActivity(), Web3DSecure.class); intent.putExtra("redirectUrl", url); startActivity(intent); } catch (JSONException e) { e.printStackTrace(); } } } }; new Pay(getActivity(), paymentObject, taskExecuted).execute(); }
From source file:com.citrus.sdk.fragments.SavedOptions.java
protected void createTransaction(OptionDetails optionDetails) { final String token = optionDetails.getToken(); final String type = optionDetails.getType(); final String txnId = "MRTXN" + String.valueOf(System.currentTimeMillis()); JSONTaskComplete taskComplete = new JSONTaskComplete() { @Override// w ww . j a v a 2 s.c om public void onTaskExecuted(JSONObject[] paymentObject, String signature) { if (TextUtils.equals(type, "NETBANKING")) { fillDetails(txnId, signature, token, ""); } else { processCardFlow(txnId, signature, token); } } }; GetSign sign = new GetSign(getActivity(), txnId, JSONUtils.TXN_AMOUNT, taskComplete); sign.execute(); }
From source file:com.kanedias.vanilla.lyrics.LyricsShowActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); // we only request one permission if (!havePermissions(this, WRITE_EXTERNAL_STORAGE)) { // user denied our request, leave activity as-is return;/*from w w w . j a v a2s . c o m*/ } for (int i = 0; i < permissions.length; ++i) { if (TextUtils.equals(permissions[i], WRITE_EXTERNAL_STORAGE) && grantResults[i] == PackageManager.PERMISSION_GRANTED) { // continue persist process started in Write... -> *.lrc file persistAsLrcFile(); } } }
From source file:com.jtechme.apphub.FDroidApp.java
@TargetApi(9) @Override//from w w w . j a v a2 s. co m public void onCreate() { if (Build.VERSION.SDK_INT >= 9 && BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); } updateLanguage(); super.onCreate(); ACRA.init(this); // Needs to be setup before anything else tries to access it. // Perhaps the constructor is a better place, but then again, // it is more deterministic as to when this gets called... Preferences.setup(this); // Apply the Google PRNG fixes to properly seed SecureRandom PRNGFixes.apply(); // Check that the installed app cache hasn't gotten out of sync somehow. // e.g. if we crashed/ran out of battery half way through responding // to a package installed intent. It doesn't really matter where // we put this in the bootstrap process, because it runs on a different // thread, which will be delayed by some seconds to avoid an error where // the database is locked due to the database updater. InstalledAppCacheUpdater.updateInBackground(getApplicationContext()); // If the user changes the preference to do with filtering rooted apps, // it is easier to just notify a change in the app provider, // so that the newly updated list will correctly filter relevant apps. Preferences.get().registerAppsRequiringRootChangeListener(new Preferences.ChangeListener() { @Override public void onPreferenceChange() { getContentResolver().notifyChange(AppProvider.getContentUri(), null); } }); // This is added so that the bluetooth:// scheme we use for URLs the BluetoothDownloader // understands is not treated as invalid by the java.net.URL class. The actual Handler does // nothing, but its presence is enough. URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() { @Override public URLStreamHandler createURLStreamHandler(String protocol) { return TextUtils.equals(protocol, "bluetooth") ? new Handler() : null; } }); final Context context = this; Preferences.get().registerUnstableUpdatesChangeListener(new Preferences.ChangeListener() { @Override public void onPreferenceChange() { AppProvider.Helper.calcDetailsFromIndex(context); } }); // Clear cached apk files. We used to just remove them after they'd // been installed, but this causes problems for proprietary gapps // users since the introduction of verification (on pre-4.2 Android), // because the install intent says it's finished when it hasn't. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); curTheme = Theme.valueOf(prefs.getString(Preferences.PREF_THEME, Preferences.DEFAULT_THEME)); Utils.deleteFiles(Utils.getApkDownloadDir(this), null, ".apk"); if (!Preferences.get().shouldCacheApks()) { Utils.deleteFiles(Utils.getApkCacheDir(this), null, ".apk"); } // Index files which downloaded, but were not removed (e.g. due to F-Droid being force // closed during processing of the file, before getting a chance to delete). This may // include both "index-*-downloaded" and "index-*-extracted.xml" files. The first is from // either signed or unsigned repos, and the later is from signed repos. Utils.deleteFiles(getCacheDir(), "index-", null); // As above, but for legacy F-Droid clients that downloaded under a different name, and // extracted to the files directory rather than the cache directory. // TODO: This can be removed in a a few months or a year (e.g. 2016) because people will // have upgraded their clients, this code will have executed, and they will not have any // left over files any more. Even if they do hold off upgrading until this code is removed, // the only side effect is that they will have a few more MiB of storage taken up on their // device until they uninstall and re-install F-Droid. Utils.deleteFiles(getCacheDir(), "dl-", null); Utils.deleteFiles(getFilesDir(), "index-", null); UpdateService.schedule(getApplicationContext()); bluetoothAdapter = getBluetoothAdapter(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .imageDownloader(new IconDownloader(getApplicationContext())) .diskCache(new LimitedAgeDiskCache( new File(StorageUtils.getCacheDirectory(getApplicationContext(), true), "icons"), null, new FileNameGenerator() { @Override public String generate(String imageUri) { return imageUri.substring(imageUri.lastIndexOf('/') + 1); } }, // 30 days in secs: 30*24*60*60 = 2592000 2592000)) .threadPoolSize(4).threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1 .build(); ImageLoader.getInstance().init(config); // TODO reintroduce PinningTrustManager and MemorizingTrustManager // initialized the local repo information FDroidApp.initWifiSettings(); startService(new Intent(this, WifiStateChangeService.class)); // if the HTTPS pref changes, then update all affected things Preferences.get().registerLocalRepoHttpsListeners(new ChangeListener() { @Override public void onPreferenceChange() { startService(new Intent(FDroidApp.this, WifiStateChangeService.class)); } }); }
From source file:com.artemchep.horario.ui.fragments.details.TeacherDetailsFragment.java
@Override protected ViewGroup onCreateContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @NonNull List<ContentItem<Teacher>> contentItems, @Nullable Bundle savedInstanceState) { getToolbar().inflateMenu(R.menu.details_teacher); ViewGroup vg = (ViewGroup) inflater.inflate(R.layout.fragment_details_teacher, container, false); initWithFab(R.id.action_edit, R.drawable.ic_pencil_white_24dp); mNoteContainer = vg.findViewById(R.id.info_container); mPhoneContainer = vg.findViewById(R.id.phone_container); mPhoneContainer.setOnClickListener(new View.OnClickListener() { @Override//from www . j ava2 s.co m public void onClick(View view) { if (TextUtils.isEmpty(mModel.phone)) { Timber.tag(TAG).w("Tried to copy an empty phone!"); return; } // Copy email to clipboard ClipboardManager clipboard = (ClipboardManager) getContext() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(mModel.phone, mModel.phone); // TODO: More informative description of the clip clipboard.setPrimaryClip(clip); // Show toast message String msg = getString(R.string.details_phone_clipboard, mModel.phone); Toasty.info(getContext(), msg).show(); } }); mEmailContainer = vg.findViewById(R.id.email_container); mEmailContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.email)) { Timber.tag(TAG).w("Tried to copy an empty email!"); return; } // Copy email to clipboard ClipboardManager clipboard = (ClipboardManager) getContext() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(mModel.email, mModel.email); // TODO: More informative description of the clip clipboard.setPrimaryClip(clip); // Show toast message String msg = getString(R.string.details_email_clipboard, mModel.email); Toasty.info(getContext(), msg).show(); } }); mPhoneButton = (Button) mPhoneContainer.findViewById(R.id.phone_send); mPhoneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.phone)) { Timber.tag(TAG).w("Tried to call an empty phone!"); return; } Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + mModel.phone)); try { startActivity(intent); } catch (ActivityNotFoundException ignored) { } } }); mEmailButton = (Button) mEmailContainer.findViewById(R.id.email_send); mEmailButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.email)) { Timber.tag(TAG).w("Tried to send to an empty email!"); return; } String[] recipients = { mModel.email }; Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients); intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); // only email apps should handle it try { startActivity(intent); } catch (ActivityNotFoundException e) { // TODO:!!!!! String msg = "No email app"; //getString(R.string.feedback_error_no_app); Toasty.info(getContext(), msg).show(); } } }); mNoteTextView = (TextView) mNoteContainer.findViewById(R.id.info); mEmailTextView = (TextView) mEmailContainer.findViewById(R.id.email); mPhoneTextView = (TextView) mPhoneContainer.findViewById(R.id.phone); // Note contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.info)) { mNoteContainer.setVisibility(View.GONE); } else { mNoteContainer.setVisibility(View.VISIBLE); mNoteTextView.setText(model.info); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.info : null; String b = model != null ? model.info : null; return !TextUtils.equals(a, b); } }); // Email contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.email)) { mEmailContainer.setVisibility(View.GONE); } else { mEmailContainer.setVisibility(View.VISIBLE); mEmailTextView.setText(model.info); if (PatternUtils.isEmail(model.email)) { mEmailButton.setVisibility(View.VISIBLE); } else mEmailButton.setVisibility(View.GONE); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.email : null; String b = model != null ? model.email : null; return !TextUtils.equals(a, b); } }); // Phone contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.phone)) { mPhoneContainer.setVisibility(View.GONE); } else { mPhoneContainer.setVisibility(View.VISIBLE); mPhoneTextView.setText(model.phone); if (PatternUtils.isPhone(model.phone)) { mPhoneButton.setVisibility(View.VISIBLE); } else mPhoneButton.setVisibility(View.GONE); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.phone : null; String b = model != null ? model.phone : null; return !TextUtils.equals(a, b); } }); return vg; }
From source file:info.guardianproject.netcipher.NetCipher.java
/** * Get a {@link HttpsURLConnection} from a {@link URI} using the best TLS * configuration available on the device. * * @param uri//from ww w.j av a2 s .c om * @return the {@code uri} in an instance of {@link HttpsURLConnection} * @throws IOException * @throws IllegalArgumentException if the proxy or TLS setup is incorrect, * or if an HTTP URL is given that does not support HTTPS */ public static HttpsURLConnection getHttpsURLConnection(URI uri) throws IOException { if (TextUtils.equals(uri.getScheme(), "https")) return getHttpsURLConnection(uri.toURL(), false); else // otherwise force scheme to https return getHttpsURLConnection(uri.toString()); }
From source file:io.scalac.locationprovider.SendMockLocationService.java
@Override public int onStartCommand(Intent startIntent, int flags, int startId) { // Get the type of test to run mTestRequest = startIntent.getAction(); /*// w w w. ja v a 2 s.c o m * If the incoming Intent was a request to run a one-time or continuous test */ if ((TextUtils.equals(mTestRequest, LocationUtils.ACTION_START_ONCE)) || (TextUtils.equals(mTestRequest, LocationUtils.ACTION_START_CONTINUOUS))) { // Get the pause interval and injection interval mPauseInterval = startIntent.getIntExtra(LocationUtils.EXTRA_PAUSE_VALUE, 2); mInjectionInterval = startIntent.getIntExtra(LocationUtils.EXTRA_SEND_INTERVAL, 1); mMockId = startIntent.getStringExtra(LocationUtils.EXTRA_MOCK_ID); // Post a notification in the notification bar that a test is starting postNotification(getString(R.string.notification_content_test_start)); // Create a location client mLocationClient = new LocationClient(this, this, this); // Start connecting to Location Services mLocationClient.connect(); } else if (TextUtils.equals(mTestRequest, LocationUtils.ACTION_STOP_TEST)) { // Remove any existing notifications removeNotification(); // Send a message back to the main activity that the test is stopping sendBroadcastMessage(LocationUtils.CODE_TEST_STOPPED, 0); // Stop this Service stopSelf(); } /* * Tell the system to keep the Service alive, but to discard the Intent that * started the Service */ return Service.START_STICKY; }
From source file:cn.code.notes.gtask.data.Task.java
public JSONObject getLocalJSONFromContent() { String name = getName();/*from w w w. j a va 2s . co m*/ try { if (mMetaInfo == null) { // new task created from web if (name == null) { Log.w(TAG, "the note seems to be an empty one"); return null; } JSONObject js = new JSONObject(); JSONObject note = new JSONObject(); JSONArray dataArray = new JSONArray(); JSONObject data = new JSONObject(); data.put(DataColumns.CONTENT, name); dataArray.put(data); js.put(GTaskStringUtils.META_HEAD_DATA, dataArray); note.put(NoteColumns.TYPE, Notes.TYPE_NOTE); js.put(GTaskStringUtils.META_HEAD_NOTE, note); return js; } else { // synced task JSONObject note = mMetaInfo.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); JSONArray dataArray = mMetaInfo.getJSONArray(GTaskStringUtils.META_HEAD_DATA); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); if (TextUtils.equals(data.getString(DataColumns.MIME_TYPE), DataConstants.NOTE)) { data.put(DataColumns.CONTENT, getName()); break; } } note.put(NoteColumns.TYPE, Notes.TYPE_NOTE); return mMetaInfo; } } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); return null; } }
From source file:com.rascarlo.aurdroid.MainActivity.java
private int getAppTheme() { String sharedPreferenceTheme = AurdroidSharedPreferences.getSharedPreferenceString(MainActivity.this, getString(R.string.key_theme), getString(R.string.key_theme_default_value)); if (TextUtils.equals(getString(R.string.key_theme_dark), sharedPreferenceTheme)) { return R.style.AppThemeDark; } else if (TextUtils.equals(getString(R.string.key_theme_black), sharedPreferenceTheme)) { return R.style.AppThemeBlack; } else if (TextUtils.equals(getString(R.string.key_theme_light), sharedPreferenceTheme)) { return R.style.AppThemeLight; } else {/* www. j a v a 2s . c o m*/ return R.style.AppThemeDark; } }