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:com.macadamian.blinkup.BlinkUpPluginResult.java

/*************************************
 * Generates JSON of our plugin results//w w w  .  j a  v  a 2  s . c  om
 * and sends back to the callback
 *************************************/
public void sendResultsToCallback() {
    JSONObject resultJSON = new JSONObject();

    // set result status
    PluginResult.Status cordovaResultStatus;
    if (TextUtils.equals(mState, STATE_ERROR)) {
        cordovaResultStatus = PluginResult.Status.ERROR;
    } else {
        cordovaResultStatus = PluginResult.Status.OK;
    }

    try {
        resultJSON.put(ResultKeys.STATE.getKey(), mState);

        if (TextUtils.equals(mState, STATE_ERROR)) {
            resultJSON.put(ResultKeys.ERROR.getKey(), generateErrorJson());
        } else {
            resultJSON.put(ResultKeys.STATUS_CODE.getKey(), ("" + mStatusCode));
            if (mHasDeviceInfo) {
                resultJSON.put(ResultKeys.DEVICE_INFO.getKey(), generateDeviceInfoJson());
            }
        }
    } catch (JSONException e) {
        // don't want endless loop calling ourselves so just log error (don't send to callback)
        Log.e(TAG, "", e);
    }

    PluginResult pluginResult = new PluginResult(cordovaResultStatus, resultJSON.toString());
    pluginResult.setKeepCallback(true); // uses same BlinkUpPlugin object across calls, so need to keep callback
    BlinkUpPlugin.getCallbackContext().sendPluginResult(pluginResult);
}

From source file:com.example.locale.MainActivity.java

@Override
public boolean onQueryTextChange(String newText) {
    if (!TextUtils.equals(newText, mFilter)) {
        mLoading.show();//  w w w.ja  v a2 s. c  o  m

        mFilter = newText;
        AsyncTaskCompat.executeParallel(new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                mAdapter.setFilter(mFilter);
                return null;
            }

            @Override
            protected void onPostExecute(Void ignored) {
                mLoading.hide();
                mAdapter.notifyDataSetChanged();
            }
        });
    }
    return true;
}

From source file:android.support.v7.preference.ListPreference.java

/**
 * Sets the value of the key. This should be one of the entries in
 * {@link #getEntryValues()}./*ww w  .j av  a  2 s  .  c  o  m*/
 *
 * @param value The value to set for the key.
 */
public void setValue(String value) {
    // Always persist/notify the first time.
    final boolean changed = !TextUtils.equals(mValue, value);
    if (changed || !mValueSet) {
        mValue = value;
        mValueSet = true;
        persistString(value);
        if (changed) {
            notifyChanged();
        }
    }
}

From source file:com.murrayc.galaxyzoo.app.LoginUtils.java

/**
 * This returns null if there is no account (not even an anonymous account).
 * Don't call this from the main thread - use an AsyncTask, for instance.
 *
 * @param context//from   w  w w .  jav  a  2s  .  c o  m
 * @return
 */
@Nullable
public static LoginDetails getAccountLoginDetails(final Context context) {
    final AccountManager mgr = AccountManager.get(context);
    if (mgr == null) {
        Log.error(
                "getAccountLoginDetails(): getAccountLoginDetails() failed because AccountManager.get() returned null.");
        return null;
    }

    final Account account = getAccount(mgr);
    if (account == null) {
        Log.error(
                "getAccountLoginDetails(): getAccountLoginDetails() failed because getAccount() returned null. ");
        return null;
    }

    //Make sure that this has not been unset somehow:
    setAutomaticAccountSync(context, account);

    final LoginDetails result = new LoginDetails();

    //Avoid showing our anonymous account name in the UI.
    //Also, an anonymous account never has an auth_api_key.
    result.isAnonymous = TextUtils.equals(account.name, ACCOUNT_NAME_ANONYMOUS);
    if (result.isAnonymous) {
        return result; //Return a mostly-empty empty (but not null) LoginDetails.
    }

    result.name = account.name;

    //Note that this requires the USE_CREDENTIALS permission on
    //SDK <=22.
    final AccountManagerFuture<Bundle> response = mgr.getAuthToken(account, ACCOUNT_AUTHTOKEN_TYPE, null, null,
            null, null);
    try {
        final Bundle bundle = response.getResult();
        if (bundle == null) {
            //TODO: Let the caller catch this?
            Log.error(
                    "getAccountLoginDetails(): getAccountLoginDetails() failed because getAuthToken() returned a null response result bundle.");
            return null;
        }

        result.authApiKey = bundle.getString(AccountManager.KEY_AUTHTOKEN);
        return result;
    } catch (final OperationCanceledException e) {
        //TODO: Let the caller catch this?
        Log.error("getAccountLoginDetails(): getAccountLoginDetails() failed", e);
        return null;
    } catch (final AuthenticatorException e) {
        //TODO: Let the caller catch this?
        Log.error("getAccountLoginDetails(): getAccountLoginDetails() failed", e);
        return null;
    } catch (final IOException e) {
        //TODO: Let the caller catch this?
        Log.error("getAccountLoginDetails(): getAccountLoginDetails() failed", e);
        return null;
    }
}

From source file:com.google.android.apps.muzei.notifications.NewWallpaperNotificationReceiver.java

private void triggerUserCommandFromRemoteInput(final Context context, Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null) {
        return;//from  w w w. j av  a 2  s  .c  o  m
    }
    final String selectedCommand = remoteInput.getCharSequence(EXTRA_USER_COMMAND).toString();
    final PendingResult pendingResult = goAsync();
    final LiveData<Source> sourceLiveData = MuzeiDatabase.getInstance(context).sourceDao().getCurrentSource();
    sourceLiveData.observeForever(new Observer<Source>() {
        @Override
        public void onChanged(@Nullable final Source selectedSource) {
            sourceLiveData.removeObserver(this);
            if (selectedSource != null) {
                for (UserCommand action : selectedSource.commands) {
                    if (TextUtils.equals(selectedCommand, action.getTitle())) {
                        SourceManager.sendAction(context, action.getId());
                        break;
                    }
                    pendingResult.finish();
                }
            }
        }
    });
}

From source file:com.meetingninja.csse.user.ProfileFragment.java

private void fetchUserInfo(final String userID) {
    displayedUser = new User();
    // Local user is stored in SessionManager, so do not fetch
    if (TextUtils.equals(userID, session.getUserID())) {
        displayedUser.setID(session.getUserID());
        Map<String, String> details = session.getUserDetails();
        displayedUser.setDisplayName(details.get(SessionManager.USER));
        displayedUser.setCompany(details.get(SessionManager.COMPANY));
        displayedUser.setTitle(details.get(SessionManager.TITLE));
        displayedUser.setLocation(details.get(SessionManager.LOCATION));
        displayedUser.setEmail(details.get(SessionManager.EMAIL));
        displayedUser.setPhone(details.get(SessionManager.PHONE));
        setUser(displayedUser);// ww  w.ja  va 2 s .com
        return;
    }

    // Swap visibility while loading information
    emptyView.setVisibility(View.VISIBLE);
    informationView.setVisibility(View.GONE);

    UserVolleyAdapter.fetchUserInfo(userID, new AsyncResponse<User>() {
        @Override
        public void processFinish(User result) {
            if (ProfileFragment.this.isAdded())
                ProfileFragment.this.setUser(result);

        }
    });
}

From source file:com.android.talkback.eventprocessor.ProcessorScreen.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    int eventType = event.getEventType();
    if (eventType != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            && eventType != AccessibilityEvent.TYPE_WINDOWS_CHANGED) {
        return;/* www  .  j a v a  2s.  c o m*/
    }

    int windowIdABefore = mWindowIdA;
    CharSequence windowTitleABefore = getWindowTitle(mWindowIdA);
    int windowIdBBefore = mWindowIdB;
    CharSequence windowTitleBBefore = getWindowTitle(mWindowIdB);
    int accessibilityOverlayWindowIdBefore = mAccessibilityOverlayWindowId;
    CharSequence accessibilityOverlayWindowTitleBefore = getWindowTitle(mAccessibilityOverlayWindowId);

    updateWindowTitlesMap(event);
    updateScreenState(event);

    // If there is no screen update, do not provide spoken feedback.
    if (windowIdABefore == mWindowIdA && TextUtils.equals(windowTitleABefore, getWindowTitle(mWindowIdA))
            && windowIdBBefore == mWindowIdB && TextUtils.equals(windowTitleBBefore, getWindowTitle(mWindowIdB))
            && accessibilityOverlayWindowIdBefore == mAccessibilityOverlayWindowId && TextUtils.equals(
                    accessibilityOverlayWindowTitleBefore, getWindowTitle(mAccessibilityOverlayWindowId))) {
        return;
    }

    // If the user performs a cursor control(copy, paste, start selection mode, etc) in the
    // local context menu and lands back to the edit text, a TYPE_WINDOWS_CHANGED and a
    // TYPE_WINDOW_STATE_CHANGED events will be fired. We should skip these two events to
    // avoid announcing the window title.
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED && EventState.getInstance()
            .checkAndClearRecentEvent(EventState.EVENT_SKIP_WINDOWS_CHANGED_PROCESSING_AFTER_CURSOR_CONTROL)) {
        return;
    }
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            && EventState.getInstance().checkAndClearRecentEvent(
                    EventState.EVENT_SKIP_WINDOW_STATE_CHANGED_PROCESSING_AFTER_CURSOR_CONTROL)) {
        return;
    }

    // Generate spoken feedback.
    CharSequence utterance;
    boolean isUiStabilized;
    if (mAccessibilityOverlayWindowId != WINDOW_ID_NONE) {
        // Case where accessibility overlay is shown. Use separated logic for accessibility
        // overlay not to say out of split screen mode, e.g. accessibility overlay is shown when
        // user is in split screen mode.
        utterance = getWindowTitleForFeedback(mAccessibilityOverlayWindowId);
        isUiStabilized = true;
    } else if (mWindowIdB == WINDOW_ID_NONE) {
        // Single window mode.
        CharSequence windowTitleA = getWindowTitle(mWindowIdA);
        if (windowTitleA == null) {
            // In single window mode, do not provide feedback if window title is not set.
            return;
        }

        utterance = getWindowTitleForFeedback(mWindowIdA);

        if (IS_IN_ARC) {
            // If windowIdABefore was WINDOW_ID_NONE, we consider it as the focus comes into Arc
            // window.
            utterance = formatAnnouncementForArc(utterance,
                    windowIdABefore == WINDOW_ID_NONE /* focusIntoArc */);
        }

        // Consider UI is stabilized if it's alert dialog to provide faster feedback.
        isUiStabilized = !mIsSplitScreenModeAvailable || isAlertDialog(mWindowIdA);
    } else {
        // Split screen mode.
        int feedbackTemplate;
        if (mService.isScreenOrientationLandscape()) {
            if (mService.isScreenLayoutRTL()) {
                feedbackTemplate = R.string.template_split_screen_mode_landscape_rtl;
            } else {
                feedbackTemplate = R.string.template_split_screen_mode_landscape_ltr;
            }
        } else {
            feedbackTemplate = R.string.template_split_screen_mode_portrait;
        }

        utterance = mService.getString(feedbackTemplate, getWindowTitleForFeedback(mWindowIdA),
                getWindowTitleForFeedback(mWindowIdB));
        isUiStabilized = !mIsSplitScreenModeAvailable || isAlertDialog(mWindowIdA) || isAlertDialog(mWindowIdB);
    }

    // Speak.
    if (!isUiStabilized) {
        // If UI is not stabilized, wait SCREEN_FEEDBACK_DELAY for next accessibility event.
        speakLater(utterance, SCREEN_FEEDBACK_DELAY);
    } else {
        speak(utterance);
    }
}

From source file:com.foodie.app.fragment.MessageFragment.java

private void updateWorksInfo() {
    if (HttpUtils.isNetworkConnected(getActivity())) {
        HttpUtils.get(Constant.WORKS_LIST, new AsyncHttpResponseHandler() {
            @Override//from   ww  w .j  a va 2s .  c o  m
            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 != null) {
                    //Toast.makeText(getActivity(),"?"+worksInfos.size(),Toast.LENGTH_LONG).show();
                    Log.i(TAG, new String(responseBody));
                    progressBar.setVisibility(View.GONE);
                    worksListView.setAdapter(new MessageListAdapter(getActivity(), worksInfos));
                    return;
                } else {
                    Toast.makeText(getActivity(), "???" + new String(responseBody),
                            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:im.vector.notifications.NotificationUtils.java

/**
 * Add a notification groups./*from  ww  w  .  ja v a2s  .  com*/
 *
 * @param context the context
 */
@SuppressLint("NewApi")
public static void addNotificationChannels(Context context) {
    if (Build.VERSION.SDK_INT < 26) {
        return;
    }

    if (null == NOISY_NOTIFICATION_CHANNEL_NAME) {
        NOISY_NOTIFICATION_CHANNEL_NAME = context.getString(R.string.notification_noisy_notifications);
    }

    if (null == SILENT_NOTIFICATION_CHANNEL_NAME) {
        SILENT_NOTIFICATION_CHANNEL_NAME = context.getString(R.string.notification_silent_notifications);
    }

    if (null == CALL_NOTIFICATION_CHANNEL_NAME) {
        CALL_NOTIFICATION_CHANNEL_NAME = context.getString(R.string.call);
    }

    if (null == LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_NAME) {
        LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_NAME = context
                .getString(R.string.notification_listen_for_events);
    }

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    // A notification channel cannot be updated :
    // it must be deleted and created with another channel id
    if ((null == NOISY_NOTIFICATION_CHANNEL_ID)) {
        List<NotificationChannel> channels = notificationManager.getNotificationChannels();

        for (NotificationChannel channel : channels) {
            if (channel.getId().startsWith(NOISY_NOTIFICATION_CHANNEL_ID_BASE)) {
                NOISY_NOTIFICATION_CHANNEL_ID = channel.getId();
            }
        }
    }

    if (null != NOISY_NOTIFICATION_CHANNEL_ID) {
        NotificationChannel channel = notificationManager.getNotificationChannel(NOISY_NOTIFICATION_CHANNEL_ID);
        Uri notificationSound = channel.getSound();
        Uri expectedSound = PreferencesManager.getNotificationRingTone(context);

        // the notification sound has been updated
        // need to delete it, to create a new one
        // else the sound won't be updated
        if (((null == notificationSound) ^ (null == expectedSound)) || ((null != notificationSound)
                && !TextUtils.equals(notificationSound.toString(), expectedSound.toString()))) {
            notificationManager.deleteNotificationChannel(NOISY_NOTIFICATION_CHANNEL_ID);
            NOISY_NOTIFICATION_CHANNEL_ID = null;
        }
    }

    if (null == NOISY_NOTIFICATION_CHANNEL_ID) {
        NOISY_NOTIFICATION_CHANNEL_ID = NOISY_NOTIFICATION_CHANNEL_ID_BASE + System.currentTimeMillis();

        NotificationChannel channel = new NotificationChannel(NOISY_NOTIFICATION_CHANNEL_ID,
                NOISY_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
        channel.setDescription(NOISY_NOTIFICATION_CHANNEL_NAME);
        channel.setSound(PreferencesManager.getNotificationRingTone(context), null);
        channel.enableVibration(true);
        notificationManager.createNotificationChannel(channel);
    }

    if (null == notificationManager.getNotificationChannel(SILENT_NOTIFICATION_CHANNEL_NAME)) {
        NotificationChannel channel = new NotificationChannel(SILENT_NOTIFICATION_CHANNEL_ID,
                SILENT_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
        channel.setDescription(SILENT_NOTIFICATION_CHANNEL_NAME);
        channel.setSound(null, null);
        notificationManager.createNotificationChannel(channel);
    }

    if (null == notificationManager.getNotificationChannel(LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_ID)) {
        NotificationChannel channel = new NotificationChannel(LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_ID,
                LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_MIN);
        channel.setDescription(LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_NAME);
        channel.setSound(null, null);
        notificationManager.createNotificationChannel(channel);
    }

    if (null == notificationManager.getNotificationChannel(CALL_NOTIFICATION_CHANNEL_ID)) {
        NotificationChannel channel = new NotificationChannel(CALL_NOTIFICATION_CHANNEL_ID,
                CALL_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
        channel.setDescription(CALL_NOTIFICATION_CHANNEL_NAME);
        channel.setSound(null, null);
        notificationManager.createNotificationChannel(channel);
    }
}

From source file:com.citrus.sdk.fragments.Netbanking.java

private void initSubmit() {
    submit = (Button) returnView.findViewById(R.id.submitButton);

    submit.setOnClickListener(new OnClickListener() {

        @Override/*www  . j av a  2s. c o  m*/
        public void onClick(View v) {

            if (!TextUtils.isEmpty(selectedBank)) {
                try {
                    if (TextUtils.equals(paymentType, Constants.GUEST_FLOW)) {
                        createUser();
                    } else {
                        savePayOption(selectedBank);
                    }
                    getSignature();

                } catch (Exception e) {
                    Toast.makeText(getActivity().getApplicationContext(), "Server may be down.",
                            Toast.LENGTH_LONG).show();
                }

            }

        }
    });
}