List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_details); baseApplication = (BaseApplication) getApplication(); rsapi = baseApplication.getRSAPI();/*from www .ja v a 2 s . c o m*/ BahnhofsDbAdapter dbAdapter = baseApplication.getDbAdapter(); countryCode = baseApplication.getCountryCode(); country = dbAdapter.fetchCountryByCountryCode(countryCode); getSupportActionBar().setDisplayHomeAsUpEnabled(true); detailsLayout = findViewById(R.id.content_details); header = findViewById(R.id.header); tvBahnhofName = findViewById(R.id.tvbahnhofname); coordinates = findViewById(R.id.coordinates); imageView = findViewById(R.id.imageview); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onPictureClicked(); } }); takePictureButton = findViewById(R.id.button_take_picture); takePictureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { takePictureWithPermissionCheck(); } }); selectPictureButton = findViewById(R.id.button_select_picture); selectPictureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { selectPictureWithPermissionCheck(); } }); reportGhostStationButton = findViewById(R.id.button_remove_station); reportGhostStationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { reportGhostStationWithPermissionCheck(); } }); licenseTagView = findViewById(R.id.license_tag); licenseTagView.setMovementMethod(LinkMovementMethod.getInstance()); // switch off image and license view until we actually have a foto imageView.setVisibility(View.INVISIBLE); licenseTagView.setVisibility(View.INVISIBLE); setPictureButtonsVisibility(View.INVISIBLE); fullscreen = false; readPreferences(); Intent intent = getIntent(); boolean directPicture = false; if (intent != null) { bahnhof = (Bahnhof) intent.getSerializableExtra(EXTRA_BAHNHOF); if (bahnhof == null) { Log.w(TAG, "EXTRA_BAHNHOF in intent data missing"); Toast.makeText(this, R.string.station_not_found, Toast.LENGTH_LONG).show(); finish(); return; } directPicture = intent.getBooleanExtra(EXTRA_TAKE_FOTO, false); tvBahnhofName.setText(bahnhof.getTitle() + " (" + bahnhof.getId() + ")"); coordinates.setText(bahnhof.getLat() + ", " + bahnhof.getLon()); if (bahnhof.hasPhoto()) { if (ConnectionUtil.checkInternetConnection(this)) { BitmapCache.getInstance().getFoto(this, bahnhof.getPhotoUrl()); } setPictureButtonsVisibility( TextUtils.equals(nickname, bahnhof.getPhotographer()) ? View.VISIBLE : View.INVISIBLE); } else { setLocalBitmap(); } } if (directPicture) { takePictureWithPermissionCheck(); } }
From source file:com.citrus.payment.PG.java
private void validate() { if (TextUtils.equals(paymenttype.toString(), "card") || TextUtils.equals(paymenttype.toString(), "cardtoken")) { if (TextUtils.isEmpty(card.getCardNumber()) && TextUtils.isEmpty(card.getcardToken())) { callback.onTaskexecuted("", "Invalid Card or Card token!"); return; }/*from ww w . j a va 2 s.c o m*/ if (!TextUtils.isEmpty(card.getCardNumber())) { if (!card.validateCard()) { callback.onTaskexecuted("", "Invalid Card!"); return; } } } String access_key = bill.getAccess_key(); String txn_id = bill.getTxnId(); String signature = bill.getSignature(); String returnUrl = bill.getReturnurl(); String email = userDetails.getEmail(); String mobile = userDetails.getMobile(); String firstname = userDetails.getFirstname(); String lastname = userDetails.getLastname(); mylist.add(access_key); mylist.add(txn_id); mylist.add(signature); mylist.add(returnUrl); mylist.add(email); mylist.add(mobile); mylist.add(firstname); mylist.add(lastname); checkifnull(); formjson(); }
From source file:com.asd.littleprincesbeauty.data.Task.java
@Override public JSONObject getLocalJSONFromContent() { String name = getName();//from ww w .ja v a 2s . com 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.taobao.weex.utils.WXUtils.java
public static Integer getInteger(@Nullable Object value, @Nullable Integer df) { if (value == null) { return df; }//from w w w.ja v a 2 s. c o m String temp = value.toString().trim(); String key = temp; Integer cache = sCache.get(key); if (cache != null) { return cache; } else { Integer ret = df; String suffix = ""; if (temp.length() >= 2) { suffix = temp.substring(temp.length() - 2, temp.length()); } if (TextUtils.equals("wx", suffix)) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { ret = (int) transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } else if (TextUtils.equals("px", suffix)) { try { temp = temp.substring(0, temp.length() - 2); if (!TextUtils.isEmpty(temp) && temp.contains(".")) { ret = (int) WXUtils.parseFloat(temp); } else { ret = Integer.parseInt(temp); } } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } else { try { if (!TextUtils.isEmpty(temp)) { if (temp.contains(".")) { ret = (int) WXUtils.parseFloat(temp); } else { ret = Integer.parseInt(temp); } } else { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("Argument value is null, df is" + df); } } } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } if (!ret.equals(df)) { sCache.put(key, ret); } return ret; } }
From source file:com.bayapps.android.robophish.playback.LocalPlayback.java
@Override public void play(QueueItem item) { //we never call this if we're auto-queued due to gapless if (mMediaPlayersSwapping) { mMediaPlayersSwapping = false;/*from w w w .j a v a 2 s . co m*/ } mPlayOnFocusGain = true; tryToGetAudioFocus(); registerAudioNoisyReceiver(); String mediaId = item.getDescription().getMediaId(); boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId); if (mediaHasChanged) { mCurrentPosition = 0; mCurrentMediaId = mediaId; } if (mState == PlaybackStateCompat.STATE_PAUSED && !mediaHasChanged && mMediaPlayer != null) { configMediaPlayerState(); } else { mState = PlaybackStateCompat.STATE_STOPPED; relaxResources(false); // release everything except MediaPlayer MediaMetadataCompat track = mMusicProvider .getMusic(MediaIDHelper.extractMusicIDFromMediaID(item.getDescription().getMediaId())); //noinspection ResourceType String source = track.getString(MusicProviderSource.CUSTOM_METADATA_TRACK_SOURCE); try { createMediaPlayerIfNeeded(); mState = PlaybackStateCompat.STATE_BUFFERING; mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setDataSource(source); // Starts preparing the media player in the background. When // it's done, it will call our OnPreparedListener (that is, // the onPrepared() method on this class, since we set the // listener to 'this'). Until the media player is prepared, // we *cannot* call start() on it! mMediaPlayer.prepareAsync(); // If we are streaming from the internet, we want to hold a // Wifi lock, which prevents the Wifi radio from going to // sleep while the song is playing. mWifiLock.acquire(); if (mCallback != null) { mCallback.onPlaybackStatusChanged(mState); } } catch (IOException ex) { LogHelper.e(TAG, ex, "Exception playing song"); if (mCallback != null) { mCallback.onError(ex.getMessage()); } } } }
From source file:com.beem.project.beem.ui.wizard.CreateAccountFragment.java
/** * Check if the fields password and confirm password match. * * @return return true if password & confirm password fields match, else * false/*from w ww .jav a2 s . co m*/ */ private boolean checkPasswords() { CharSequence pass = password.getText(); return !TextUtils.isEmpty(pass) && TextUtils.equals(pass, confirmPassword.getText()); }
From source file:com.jefftharris.passwdsafe.sync.owncloud.OwncloudProvider.java
/** Set account settings */ public final void setSettings(String url) { // TODO: test deadlock with this update and gdrive on startup if (!TextUtils.equals(itsUrl.toString(), url)) { saveAuthData(itsAccountName, url); updateOwncloudAcct();/*w w w.j a va2 s.co m*/ } }
From source file:com.songcode.materialnotes.ui.NoteEditActivity.java
private boolean initActivityState(Intent intent) { /**/*from w w w. j ava 2s . c om*/ * If the user specified the {@link Intent#ACTION_VIEW} but not provided with id, * then jump to the NotesListActivity */ mWorkingNote = null; if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) { long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0); mUserQuery = ""; /** * Starting from the searched result */ if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) { noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY)); mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY); } if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) { Intent jump = new Intent(this, NotesListActivity.class); startActivity(jump); showToast(R.string.error_note_not_exist); finish(); return false; } else { mWorkingNote = WorkingNote.load(this, noteId); if (mWorkingNote == null) { Log.e(TAG, "load note failed with note id" + noteId); finish(); return false; } } } else if (TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) { // New note long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0); int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); int widgetType = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_TYPE, Notes.TYPE_WIDGET_INVALIDE); int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, ResourceParser.getDefaultBgId(this)); // Parse call-record note String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0); if (callDate != 0 && phoneNumber != null) { if (TextUtils.isEmpty(phoneNumber)) { Log.w(TAG, "The call record number is null"); } long noteId = 0; if ((noteId = DataUtils.getNoteIdByPhoneNumberAndCallDate(getContentResolver(), phoneNumber, callDate)) > 0) { mWorkingNote = WorkingNote.load(this, noteId); if (mWorkingNote == null) { Log.e(TAG, "load call note failed with note id" + noteId); finish(); return false; } } else { mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId); mWorkingNote.convertToCallNote(phoneNumber, callDate); } } else { mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId); } } else { Log.e(TAG, "Intent not specified action, should not support"); finish(); return false; } getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); mWorkingNote.setOnSettingStatusChangedListener(this); return true; }
From source file:com.rascarlo.aurdroid.ui.SearchFragment.java
private void bindSort() { if (context != null) { String sharedPreferenceSort = AurdroidSharedPreferences.getSharedPreferenceString(context, getString(R.string.key_sort), getString(R.string.key_sort_default_value)); if (TextUtils.equals(sharedPreferenceSort, getString(R.string.key_sort_by_package_name))) { radioButtonSortPackageName.setChecked(true); } else if (TextUtils.equals(sharedPreferenceSort, getString(R.string.key_sort_by_votes))) { radioButtonSortVotes.setChecked(true); } else if (TextUtils.equals(sharedPreferenceSort, getString(R.string.key_sort_by_popularity))) { radioButtonSortPopularity.setChecked(true); } else if (TextUtils.equals(sharedPreferenceSort, getString(R.string.key_sort_by_last_updated))) { radioButtonSortLastUpdated.setChecked(true); } else if (TextUtils.equals(sharedPreferenceSort, getString(R.string.key_sort_by_first_submitted))) { radioButtonSortFirstSubmitted.setChecked(true); } else {/*from w w w .ja v a2 s . c o m*/ radioButtonSortPackageName.setChecked(true); } } }
From source file:com.google.android.apps.muzei.datalayer.ActivateMuzeiIntentService.java
@Override protected void onHandleIntent(Intent intent) { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String action = intent.getAction(); if (TextUtils.equals(action, ACTION_MARK_NOTIFICATION_READ)) { preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); return;// ww w .j a va 2s .co m } else if (TextUtils.equals(action, ACTION_REMOTE_INSTALL_MUZEI)) { Intent remoteIntent = new Intent(Intent.ACTION_VIEW).addCategory(Intent.CATEGORY_BROWSABLE) .setData(Uri.parse("market://details?id=" + getPackageName())); RemoteIntent.startRemoteActivity(this, remoteIntent, new ResultReceiver(new Handler()) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { if (resultCode == RemoteIntent.RESULT_OK) { FirebaseAnalytics.getInstance(ActivateMuzeiIntentService.this) .logEvent("activate_notif_install_sent", null); preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); } else { Toast.makeText(ActivateMuzeiIntentService.this, R.string.activate_install_failed, Toast.LENGTH_SHORT).show(); } } }); return; } // else -> Open on Phone action GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build(); ConnectionResult connectionResult = googleApiClient.blockingConnect(30, TimeUnit.SECONDS); if (!connectionResult.isSuccess()) { Log.e(TAG, "Failed to connect to GoogleApiClient."); Toast.makeText(this, R.string.activate_failed, Toast.LENGTH_SHORT).show(); return; } Set<Node> nodes = Wearable.CapabilityApi .getCapability(googleApiClient, "activate_muzei", CapabilityApi.FILTER_REACHABLE).await() .getCapability().getNodes(); if (nodes.isEmpty()) { Toast.makeText(this, R.string.activate_failed, Toast.LENGTH_SHORT).show(); } else { FirebaseAnalytics.getInstance(this).logEvent("activate_notif_message_sent", null); // Show the open on phone animation Intent openOnPhoneIntent = new Intent(this, ConfirmationActivity.class); openOnPhoneIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); openOnPhoneIntent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.OPEN_ON_PHONE_ANIMATION); startActivity(openOnPhoneIntent); // Clear the notification NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(INSTALL_NOTIFICATION_ID); preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); // Send the message to the phone to open Muzei for (Node node : nodes) { Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), "notification/open", null).await(); } } googleApiClient.disconnect(); }