List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.android.tv.settings.device.storage.FormatActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPackageManager = getPackageManager(); mStorageManager = getSystemService(StorageManager.class); final IntentFilter filter = new IntentFilter(); filter.addAction(SettingsStorageService.ACTION_FORMAT_AS_PRIVATE); filter.addAction(SettingsStorageService.ACTION_FORMAT_AS_PUBLIC); LocalBroadcastManager.getInstance(this).registerReceiver(mFormatReceiver, filter); if (savedInstanceState != null) { mFormatAsPrivateDiskId = savedInstanceState.getString(SAVE_STATE_FORMAT_PRIVATE_DISK_ID); mFormatAsPublicDiskId = savedInstanceState.getString(SAVE_STATE_FORMAT_PUBLIC_DISK_ID); mFormatDiskDesc = savedInstanceState.getString(SAVE_STATE_FORMAT_DISK_DESC); } else {// w ww . j a v a2 s . c o m final String diskId = getIntent().getStringExtra(DiskInfo.EXTRA_DISK_ID); final String action = getIntent().getAction(); final Fragment f; if (TextUtils.equals(action, INTENT_ACTION_FORMAT_AS_PRIVATE)) { f = FormatAsPrivateStepFragment.newInstance(diskId); } else if (TextUtils.equals(action, INTENT_ACTION_FORMAT_AS_PUBLIC)) { f = FormatAsPublicStepFragment.newInstance(diskId); } else { throw new IllegalStateException("No known action specified"); } getFragmentManager().beginTransaction().add(android.R.id.content, f).commit(); } }
From source file:com.jungle.apps.photos.module.imgviewer.widget.ImageViewerLayoutView.java
private int getLocationIndex(String id) { int count = mContentProvider.getItemCount(); for (int i = 0; i < count; ++i) { CategoryManager.CategoryItem item = mContentProvider.getItem(i); if (TextUtils.equals(id, item.mId)) { return i; }// w w w .j av a 2s.c om } return 0; }
From source file:info.guardianproject.otr.app.im.app.AddContactActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = (ImApp) getApplication();/* w w w.ja v a 2 s .c o m*/ mApp.setAppTheme(this); mHandler = new SimpleAlertHandler(this); setContentView(R.layout.add_contact_activity); BrandingResources brandingRes = mApp.getBrandingResource(0); setTitle(brandingRes.getString(BrandingResourceIDs.STRING_ADD_CONTACT_TITLE)); TextView label = (TextView) findViewById(R.id.input_contact_label); label.setText(brandingRes.getString(BrandingResourceIDs.STRING_LABEL_INPUT_CONTACT)); mAddressList = (MultiAutoCompleteTextView) findViewById(R.id.email); mAddressList.setTokenizer(new Rfc822Tokenizer()); mAddressList.addTextChangedListener(mTextWatcher); mListSpinner = (Spinner) findViewById(R.id.choose_list); setupAccountSpinner(); mInviteButton = (Button) findViewById(R.id.invite); mInviteButton.setText(brandingRes.getString(BrandingResourceIDs.STRING_BUTTON_ADD_CONTACT)); mInviteButton.setOnClickListener(mButtonHandler); mInviteButton.setEnabled(false); mScanButton = (Button) findViewById(R.id.scan); mScanButton.setOnClickListener(mScanHandler); Intent intent = getIntent(); String scheme = intent.getScheme(); if (TextUtils.equals(scheme, "xmpp")) { addContactFromUri(intent.getData()); } }
From source file:com.appsimobile.appsii.module.home.config.HomeItemConfigurationHelper.java
@Override public long findCellWithPropertyValue(String propertyName, String value) { synchronized (this) { int len = mConfigurationProperties.size(); for (int i = 0; i < len; i++) { ConfigurationProperty property = mConfigurationProperties.valueAt(i); String propValue = property.getProperty(propertyName, null); if (propValue != null && TextUtils.equals(value, propValue)) { return property.mCellId; }/*from ww w.j av a 2 s . co m*/ } } return -1; }
From source file:com.raspi.chatapp.util.storage.file.LocalStorageProvider.java
@Override public Cursor queryRoots(final String[] projection) throws FileNotFoundException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (getContext() == null || ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { return null; }//from w w w . j a v a 2s . com // Create a cursor with either the requested fields, or the default projection if "projection" is null. final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_ROOT_PROJECTION); // Add Home directory File homeDir = Environment.getExternalStorageDirectory(); if (TextUtils.equals(Environment.getExternalStorageState(), Environment.MEDIA_MOUNTED)) { final MatrixCursor.RowBuilder row = result.newRow(); // These columns are required row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath()); row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath()); row.add(Root.COLUMN_TITLE, getContext().getString(R.string.home)); row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_IS_CHILD); row.add(Root.COLUMN_ICON, R.mipmap.ic_launcher); // These columns are optional row.add(Root.COLUMN_SUMMARY, homeDir.getAbsolutePath()); row.add(Root.COLUMN_AVAILABLE_BYTES, new StatFs(homeDir.getAbsolutePath()).getAvailableBytes()); // Root.COLUMN_MIME_TYPE is another optional column and useful if you have multiple roots with different // types of mime types (roots that don't match the requested mime type are automatically hidden) } // Add SD card directory File sdCard = new File("/storage/extSdCard"); String storageState = EnvironmentCompat.getStorageState(sdCard); if (TextUtils.equals(storageState, Environment.MEDIA_MOUNTED) || TextUtils.equals(storageState, Environment.MEDIA_MOUNTED_READ_ONLY)) { final MatrixCursor.RowBuilder row = result.newRow(); // These columns are required row.add(Root.COLUMN_ROOT_ID, sdCard.getAbsolutePath()); row.add(Root.COLUMN_DOCUMENT_ID, sdCard.getAbsolutePath()); row.add(Root.COLUMN_TITLE, getContext().getString(R.string.sd_card)); // Always assume SD Card is read-only row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY); row.add(Root.COLUMN_ICON, R.drawable.ic_sd_card); row.add(Root.COLUMN_SUMMARY, sdCard.getAbsolutePath()); row.add(Root.COLUMN_AVAILABLE_BYTES, new StatFs(sdCard.getAbsolutePath()).getAvailableBytes()); } return result; } else return null; }
From source file:com.rascarlo.aurdroid.ui.InfoResultFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Context context = container.getContext(); FragmentInfoResultBinding fragmentInfoResultBinding = FragmentInfoResultBinding.inflate(inflater, container, false);/*from www . j av a2 s . co m*/ ProgressBar progressBar = fragmentInfoResultBinding.fragmentInfoResultProgressBar; progressBar.setVisibility(View.VISIBLE); InfoViewModelFactory infoViewModelFactory = new InfoViewModelFactory(bundlePkgname); InfoViewModel infoViewModel = ViewModelProviders.of(this, infoViewModelFactory).get(InfoViewModel.class); infoViewModel.getInfoLiveData().observe(this, info -> { if (info != null && info.getInfoResultList().get(0) != null) { this.infoResult = info.getInfoResultList().get(0); fragmentInfoResultBinding.setInfoResult(infoResult); fragmentInfoResultBinding.executePendingBindings(); bindDepends(fragmentInfoResultBinding); } progressBar.setVisibility(View.GONE); }); infoViewModel.getMessageMutableLiveData().observe(this, s -> { if (s != null && !TextUtils.isEmpty(s)) { Toast.makeText(context, TextUtils.equals(AurdroidConstants.RETROFIT_FAILURE, s) ? getString(R.string.retrofit_something_went_wrong) : s, Toast.LENGTH_LONG).show(); } progressBar.setVisibility(View.GONE); }); return fragmentInfoResultBinding.getRoot(); }
From source file:fm.smart.r1.ItemActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); // could check here to see if this was suspended for login and go // straight to add_item ... setContentView(R.layout.item);/*from w ww. j av a2 s. com*/ TextView cue_and_pronunciation = (TextView) findViewById(R.id.cue_and_pronunciation); cue_and_pronunciation.setText(item.cue_text); // TODO handle case where // item is null? TextView cue_part_of_speech = (TextView) findViewById(R.id.cue_part_of_speech); if (!TextUtils.equals(item.part_of_speech, "None")) { cue_part_of_speech.setText(item.part_of_speech); } else { cue_part_of_speech.setVisibility(View.INVISIBLE); } TextView response_and_pronunciation = (TextView) findViewById(R.id.response_and_pronunciation); response_and_pronunciation.setText(item.children[0][0]); TextView response_part_of_speech = (TextView) findViewById(R.id.response_part_of_speech); if (item.type != null && item.type.equals("meaning")) { item.type = "Translation"; } response_part_of_speech.setText(item.type); response_part_of_speech.setVisibility(View.INVISIBLE); ImageView cue_sound = (ImageView) findViewById(R.id.cue_sound); try { setSound(cue_sound, item.cue_sound_url, this, R.id.cue_sound, (String) item.item_node.getString("id"), item.cue_text); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } ImageView response_sound = (ImageView) findViewById(R.id.response_sound); try { setSound(response_sound, item.response_sound_url, this, R.id.response_sound, (String) item.item_node.getString("id"), item.response_node.getJSONObject("content").getString("text")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } EfficientAdapter adapter = new EfficientAdapter(ItemActivity.this, item.sentence_vector); cache = new Cache(adapter); setListAdapter(adapter); if (adapter.getCount() == 0 && !ItemActivity.shown_toast) { Toast t = Toast.makeText(this, "Know a good example? Click the menu button to add one", 250); t.setGravity(Gravity.CENTER, 0, 0); t.show(); ItemActivity.shown_toast = true; } // notify(); }
From source file:br.fapema.morholt.android.wizardpager.wizard.basic.FixedFragmentStatePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; }/*from ww w .j a v a2 s . c o m*/ } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); String fragmentTag = getTag(position); if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment + " t=" + fragmentTag); if (mSavedState.size() > position) { String savedTag = mSavedFragmentTags.get(position); if (TextUtils.equals(fragmentTag, savedTag)) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, fragmentTag); return fragment; }
From source file:com.dandewine.user.tocleveroad.adapters.FixedFragmentStatePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this result_item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; }//from ww w. j a v a 2 s . c o m } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); String fragmentTag = getTag(position); if (DEBUG) Log.v(TAG, "Adding result_item #" + position + ": f=" + fragment + " t=" + fragmentTag); if (mSavedState.size() > position) { String savedTag = mSavedFragmentTags.get(position); if (TextUtils.equals(fragmentTag, savedTag)) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, fragmentTag); return fragment; }
From source file:com.example.fragmentstatepagerissueexample.app.FixedFragmentStatePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; }//from ww w .j a v a 2s.co m } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); String fragmentTag = getTag(position); if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment + " t=" + fragmentTag); if (mSavedState.size() > position) { String savedTag = mSavedFragmentTags.get(position); if (TextUtils.equals(fragmentTag, savedTag)) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, fragmentTag); return fragment; }