Example usage for android.text TextUtils equals

List of usage examples for android.text TextUtils equals

Introduction

In this page you can find the example usage for android.text TextUtils equals.

Prototype

public static boolean equals(CharSequence a, CharSequence b) 

Source Link

Document

Returns true if a and b are equal, including if they are both null.

Usage

From source file:im.neon.adapters.VectorMessagesAdapter.java

/**
 * Found the dedicated icon to display for each event id
 *//*ww w .ja  v  a  2  s.c o  m*/
private void manageCryptoEvents() {
    HashMap<String, Integer> e2eIconByEventId = new HashMap<>();
    HashMap<String, MXDeviceInfo> e2eDeviceInfoByEventId = new HashMap<>();

    if (mIsRoomEncrypted && mSession.isCryptoEnabled()) {
        // the key is "userid_deviceid"
        for (int index = 0; index < this.getCount(); index++) {
            MessageRow row = getItem(index);
            Event event = row.getEvent();

            // oneself event
            if (event.mSentState != Event.SentState.SENT) {
                e2eIconByEventId.put(event.eventId, R.drawable.e2e_verified);
            }
            // not encrypted event
            else if (!event.isEncrypted()) {
                e2eIconByEventId.put(event.eventId, R.drawable.e2e_unencrypted);
            }
            // in error cases, do not display
            else if (null != event.getCryptoError()) {
                e2eIconByEventId.put(event.eventId, R.drawable.e2e_blocked);
            } else {
                EncryptedEventContent encryptedEventContent = JsonUtils
                        .toEncryptedEventContent(event.getWireContent().getAsJsonObject());

                if (TextUtils.equals(mSession.getCredentials().deviceId, encryptedEventContent.device_id)
                        && TextUtils.equals(mSession.getMyUserId(), event.getSender())) {
                    e2eIconByEventId.put(event.eventId, R.drawable.e2e_verified);
                    MXDeviceInfo deviceInfo = mSession.getCrypto().deviceWithIdentityKey(
                            encryptedEventContent.sender_key, event.getSender(),
                            encryptedEventContent.algorithm);

                    if (null != deviceInfo) {
                        e2eDeviceInfoByEventId.put(event.eventId, deviceInfo);
                    }

                } else {
                    MXDeviceInfo deviceInfo = mSession.getCrypto().deviceWithIdentityKey(
                            encryptedEventContent.sender_key, event.getSender(),
                            encryptedEventContent.algorithm);

                    if (null != deviceInfo) {
                        e2eDeviceInfoByEventId.put(event.eventId, deviceInfo);
                        if (deviceInfo.isVerified()) {
                            e2eIconByEventId.put(event.eventId, R.drawable.e2e_verified);
                        } else if (deviceInfo.isBlocked()) {
                            e2eIconByEventId.put(event.eventId, R.drawable.e2e_blocked);
                        } else {
                            e2eIconByEventId.put(event.eventId, R.drawable.e2e_warning);
                        }
                    } else {
                        e2eIconByEventId.put(event.eventId, R.drawable.e2e_warning);
                    }
                }
            }
        }
    }

    mE2eDeviceByEventId = e2eDeviceInfoByEventId;
    mE2eIconByEventId = e2eIconByEventId;
}

From source file:io.github.hidroh.materialistic.AppUtils.java

@SuppressLint("MissingPermission")
public static void registerAccountsUpdatedListener(final Context context) {
    AccountManager.get(context).addOnAccountsUpdatedListener(accounts -> {
        String username = Preferences.getUsername(context);
        if (TextUtils.isEmpty(username)) {
            return;
        }/*from ww  w.ja v  a  2 s  .  com*/
        for (Account account : accounts) {
            if (TextUtils.equals(account.name, username)) {
                return;
            }
        }
        Preferences.setUsername(context, null);
    }, null, true);
}

From source file:im.vector.VectorApp.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (!TextUtils.equals(Locale.getDefault().toString(), getApplicationLocale().toString())) {
        Log.d(LOG_TAG,//from   w  w  w.ja va  2s.  co m
                "## onConfigurationChanged() : the locale has been updated to " + Locale.getDefault().toString()
                        + ", restore the expected value " + getApplicationLocale().toString());
        updateApplicationSettings(getApplicationLocale(), getFontScale(), ThemeUtils.getApplicationTheme(this));
    }
}

From source file:im.vector.util.ThemeUtils.java

/**
 * Get the resource Id applied to the current theme
 *
 * @param c          the context/*from  www  .  j av  a  2  s .  c o  m*/
 * @param resourceId the resource id
 * @return the resource Id for the current theme
 */
public static int getResourceId(Context c, int resourceId) {
    if (TextUtils.equals(getApplicationTheme(c), THEME_DARK_VALUE)) {

        if (resourceId == R.drawable.line_divider_light) {
            return R.drawable.line_divider_dark;
        }
    }
    return resourceId;
}

From source file:com.google.android.apps.forscience.whistlepunk.metadata.TriggerListFragment.java

private boolean isTriggerActive(SensorTrigger trigger) {
    for (int i = 0; i < mSensorLayout.activeSensorTriggerIds.length; i++) {
        if (TextUtils.equals(trigger.getTriggerId(), mSensorLayout.activeSensorTriggerIds[i])) {
            return true;
        }//from  www  .ja  v a  2 s . co  m
    }
    return false;
}

From source file:com.alibaba.weex.IndexActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_index);
    setContainer((ViewGroup) findViewById(R.id.index_container));
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from  ww w  . j a v a2 s .  c om
    getWindow().setFormat(PixelFormat.TRANSLUCENT);

    mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar);
    mTipView = (TextView) findViewById(R.id.index_tip);
    mProgressBar.setVisibility(View.VISIBLE);
    mTipView.setVisibility(View.VISIBLE);

    if (!WXSoInstallMgrSdk.isCPUSupport()) {
        mProgressBar.setVisibility(View.INVISIBLE);
        mTipView.setText(R.string.cpu_not_support_tip);
        return;
    }

    if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) {
        renderPage(WXFileUtils.loadAsset("index.js", this), getIndexUrl());
    } else {
        renderPageByURL(getIndexUrl());
    }

    mReloadReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            createWeexInstance();
            if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) {
                renderPage(WXFileUtils.loadAsset("index.js", getApplicationContext()), getIndexUrl());
            } else {
                renderPageByURL(getIndexUrl());
            }
            mProgressBar.setVisibility(View.VISIBLE);
        }
    };

    LocalBroadcastManager.getInstance(this).registerReceiver(mReloadReceiver,
            new IntentFilter(WXSDKEngine.JS_FRAMEWORK_RELOAD));
}

From source file:com.cyanogenmod.messaging.quickmessage.QuickMessagePopup.java

/**
 * display the sim select dialog for multi sim phones
 *//*from   w ww  . j a v  a  2 s.  co  m*/
private void showSimSelector(Activity activity, final ComposeMessageView.OnSimSelectedCallback cb) {
    final TelecomManager telecomMgr = (TelecomManager) activity.getSystemService(Context.TELECOM_SERVICE);
    final List<PhoneAccountHandle> handles = telecomMgr.getCallCapablePhoneAccounts();
    final List<PhoneAccountHandle> filteredHandles = new ArrayList<>();

    //trim out SIP accounts
    for (PhoneAccountHandle handle : handles) {
        PhoneAccount phoneAccount = PhoneUtils.getAccountOrNull(activity, handle);
        if (phoneAccount != null) {
            Uri address = phoneAccount.getAddress();
            if (address != null && !TextUtils.equals(address.getScheme(), PhoneAccount.SCHEME_SIP)) {
                filteredHandles.add(handle);
            }
        }
    }

    final SelectPhoneAccountDialogFragment.SelectPhoneAccountListener listener = new SelectPhoneAccountDialogFragment.SelectPhoneAccountListener() {
        @Override
        public void onPhoneAccountSelected(PhoneAccountHandle selectedAccountHandle, boolean setDefault) {
            // we need the subId and we only have a PhoneAccountHandle
            TelephonyManager telephonyManager = (TelephonyManager) mContext
                    .getSystemService(Context.TELEPHONY_SERVICE);
            Iterator<PhoneAccountHandle> phoneAccounts = telecomMgr.getCallCapablePhoneAccounts()
                    .listIterator();
            int subId = 0; // defaulting to 0, just in case
            while (phoneAccounts.hasNext()) {
                PhoneAccountHandle p = phoneAccounts.next();
                if (p.getId().equals(selectedAccountHandle.getId())) {
                    PhoneAccount phoneAccount = telecomMgr.getPhoneAccount(p);
                    subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
                }
            }
            cb.onSimSelected(subId);
        }

        @Override
        public void onDialogDismissed() {
        }
    };

    DialogFragment dialogFragment = SelectPhoneAccountDialogFragment.newInstance(
            R.string.select_phone_account_title, false /* canSetDefault */, filteredHandles, listener);
    dialogFragment.show(activity.getFragmentManager(), "SELECT_PHONE_ACCOUNT_DIALOG_FRAGMENT");
}

From source file:edu.berkeley.eecs.cfc_tracker.test.location.SendMockLocationService.java

public int onStartCommand(Context ctxt, Intent startIntent, int flags, int startId) {
    mCachedContext = ctxt;//from w w  w.j  av  a2 s  . co  m
    // Get the type of test to run
    mTestRequest = startIntent.getAction();

    /*
     * 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);

        // Start connecting to Location Services
        mGoogleApiClient.connect();
    } else if (TextUtils.equals(mTestRequest, LocationUtils.ACTION_STOP_TEST)) {

        // 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:com.songcode.materialnotes.ui.NotesListActivity.java

private void updateDrawerWithState(ListEditState state) {
    if (mNavigationListView == null) {
        Log.e(TAG, "mNavigationListView == null");
        return;/*from   w w w  .ja va2s . c o m*/
    }
    String[] itemsStrings = null;
    final String createNewStr = getString(R.string.notelist_menu_new);
    final String createFolderStr = getString(R.string.menu_create_folder);
    final String exportTextStr = getString(R.string.menu_export_text);
    final String syncStr = getString(R.string.menu_sync);
    final String cancelSyncStr = getString(R.string.menu_sync_cancel);
    final String syncStateStr = GTaskSyncService.isSyncing() ? cancelSyncStr : syncStr;
    final String searchStr = getString(R.string.menu_search);
    final String setStr = getString(R.string.menu_setting);
    if (state == ListEditState.NOTE_LIST) {
        itemsStrings = new String[] { createNewStr, createFolderStr, exportTextStr, syncStateStr, searchStr,
                setStr };
    } else if (state == ListEditState.SUB_FOLDER) {
        itemsStrings = new String[] { createNewStr };
    } else if (state == ListEditState.CALL_RECORD_FOLDER) {
        itemsStrings = new String[] { searchStr };
    } else {
        Log.e(TAG, "Wrong state:" + mState);
    }

    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_activated_1, android.R.id.text1, itemsStrings);
    mNavigationListView.setAdapter(arrayAdapter);
    mNavigationListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String curItemStr = arrayAdapter.getItem(position);
            if (createNewStr.equals(curItemStr)) {
                createNewNote();
            } else if (createFolderStr.equals(curItemStr)) {
                showCreateOrModifyFolderDialog(true);
            } else if (exportTextStr.equals(curItemStr)) {
                exportNoteToText();
            } else if (syncStr.equals(curItemStr) || cancelSyncStr.equals(curItemStr)) {
                if (isSyncMode()) {
                    //TODO:???
                    if (TextUtils.equals(curItemStr, syncStr)) {
                        GTaskSyncService.startSync(NotesListActivity.this);
                    } else {
                        GTaskSyncService.cancelSync(NotesListActivity.this);
                    }
                } else {
                    startPreferenceActivity();
                }
            } else if (searchStr.equals(curItemStr)) {
                onSearchRequested();
            } else if (setStr.equals(curItemStr)) {
                startPreferenceActivity();
            }
            closeDrawerLayout();
        }
    });
}

From source file:com.doctoror.fuckoffmusicplayer.presentation.queue.QueueActivity.java

private void onPlayClick(@NonNull final View clickedView, final int queuePosition) {

    mPlaybackInitializer.setQueueAndPlay(queue, queuePosition);
    final Media media = CollectionUtils.getItemSafe(queue, queuePosition);
    final boolean shouldPassCoverView = mAppbarOffset == 0
            && TextUtils.equals(mCoverUri, media != null ? media.getAlbumArt() : null);
    if (shouldPassCoverView) {
        prepareViewsAndExit(() -> startNowPlayingActivity(albumArt, null));
    } else {/*from  www .j ava  2s  .  c  om*/
        mFabAnchorParams = CoordinatorLayoutUtil.getAnchorParams(fab);
        CoordinatorLayoutUtil.clearAnchorGravityAndApplyMargins(fab);
        startNowPlayingActivity(null, clickedView);
    }
}