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.scvngr.levelup.core.net.LevelUpResponse.java

/**
 * Get a specific {@link Error} from the {@link LevelUpResponse} which contains specific values
 * for {@link Error#getObject} and {@link Error#getCode}.
 *
 * @param object the {@link ErrorObject} of the desired error. This object is scoped to the
 * context of the web service.//from   w w  w  . jav  a 2  s .  c o m
 * @param code the {@link ErrorCode} of the desired error.
 * @return the {@link Error} or null if the error is not found.
 */
@Nullable
public Error getServerError(@NonNull final ErrorObject object, @NonNull final ErrorCode code) {
    Error filteredError = null;

    for (final Error error : mServerErrors) {
        if (TextUtils.equals(object.toString(), error.getObject())) {
            if (TextUtils.equals(code.toString(), error.getCode())) {
                filteredError = error;
                break;
            }
        }
    }

    return filteredError;
}

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

@Override
public void onException(WXSDKInstance wxsdkInstance, String s, String s1) {
    super.onException(wxsdkInstance, s, s1);
    mProgressBar.setVisibility(View.GONE);
    mTipView.setVisibility(View.VISIBLE);
    if (TextUtils.equals(s, WXRenderErrorCode.WX_NETWORK_ERROR)) {
        mTipView.setText(R.string.index_tip);
    } else {/*from   ww  w .  ja va  2  s  . c om*/
        mTipView.setText("render error:" + s1);
    }
}

From source file:im.vector.activity.VectorUnifiedSearchActivity.java

@Override
public void onTabUnselected(android.support.v7.app.ActionBar.Tab tab,
        android.support.v4.app.FragmentTransaction ft) {
    String tabTag = (String) tab.getTag();
    Log.d(LOG_TAG, "## onTabUnselected() FragTag=" + tabTag);

    if (TextUtils.equals(tabTag, TAG_FRAGMENT_SEARCH_IN_MESSAGE)) {
        if (null != mSearchInMessagesFragment) {
            mSearchInMessagesFragment.cancelCatchingRequests();
            ft.detach(mSearchInMessagesFragment);
        }/*from  w w  w . jav  a  2s .c o m*/
    } else if (TextUtils.equals(tabTag, TAG_FRAGMENT_SEARCH_IN_ROOM_NAMES)) {
        if (null != mSearchInRoomNamesFragment) {
            ft.detach(mSearchInRoomNamesFragment);
        }
    } else if (TextUtils.equals(tabTag, TAG_FRAGMENT_SEARCH_IN_FILES)) {
        if (null != mSearchInFilesFragment) {
            mSearchInFilesFragment.cancelCatchingRequests();
            ft.detach(mSearchInFilesFragment);
        }
    } else if (TextUtils.equals(tabTag, TAG_FRAGMENT_SEARCH_PEOPLE)) {
        if (null != mSearchInPeopleFragment) {
            ft.detach(mSearchInPeopleFragment);
        }
    }
}

From source file:com.jungle.base.utils.MiscUtils.java

public static String getMainLauncherActivity() {
    try {//from   w ww .j  av  a  2  s.c o  m
        Context context = BaseApplication.getAppContext();
        PackageManager manager = context.getPackageManager();
        Intent intent = new Intent(Intent.ACTION_MAIN, null);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        List<ResolveInfo> list = manager.queryIntentActivities(intent, 0);
        Collections.sort(list, new ResolveInfo.DisplayNameComparator(manager));

        String packageName = MiscUtils.getPackageName();
        for (ResolveInfo info : list) {
            if (TextUtils.equals(packageName, info.activityInfo.packageName)) {
                return info.activityInfo.name;
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }

    return null;
}

From source file:im.vector.receiver.VectorUniversalLinkReceiver.java

/***
 * Tries to parse an universal link./*from   w  ww . ja v a2s . c o m*/
 *
 * @param uri the uri to parse
 * @return the universal link items, null if the universal link is invalid
 */
public static HashMap<String, String> parseUniversalLink(Uri uri) {
    HashMap<String, String> map = null;

    try {
        // sanity check
        if ((null == uri) || TextUtils.isEmpty(uri.getPath())) {
            Log.e(LOG_TAG, "## parseUniversalLink : null");
            return null;
        }

        if (!TextUtils.equals(uri.getHost(), "vector.im") && !TextUtils.equals(uri.getHost(), "riot.im")
                && !TextUtils.equals(uri.getHost(), "matrix.to")) {
            Log.e(LOG_TAG, "## parseUniversalLink : unsupported host " + uri.getHost());
            return null;
        }

        boolean isSupportedHost = TextUtils.equals(uri.getHost(), "vector.im")
                || TextUtils.equals(uri.getHost(), "riot.im");

        // when the uri host is vector.im, it is followed by a dedicated path
        if (isSupportedHost && !mSupportedVectorLinkPaths.contains(uri.getPath())) {
            Log.e(LOG_TAG, "## parseUniversalLink : not supported");
            return null;
        }

        // remove the server part
        String uriFragment;
        if (null != (uriFragment = uri.getFragment())) {
            uriFragment = uriFragment.substring(1); // get rid of first "/"
        } else {
            Log.e(LOG_TAG, "## parseUniversalLink : cannot extract path");
            return null;
        }

        String temp[] = uriFragment.split("/", 3); // limit to 3 for security concerns (stack overflow injection)

        if (!isSupportedHost) {
            ArrayList<String> compliantList = new ArrayList<>(Arrays.asList(temp));
            compliantList.add(0, "room");
            temp = compliantList.toArray(new String[compliantList.size()]);
        }

        if (temp.length < 2) {
            Log.e(LOG_TAG, "## parseUniversalLink : too short");
            return null;
        }

        if (!TextUtils.equals(temp[0], "room") && !TextUtils.equals(temp[0], "user")) {
            Log.e(LOG_TAG, "## parseUniversalLink : not supported " + temp[0]);
            return null;
        }

        map = new HashMap<>();

        String firstParam = temp[1];

        if (MXSession.isUserId(firstParam)) {
            if (temp.length > 2) {
                Log.e(LOG_TAG, "## parseUniversalLink : universal link to member id is too long");
                return null;
            }

            map.put(ULINK_MATRIX_USER_ID_KEY, firstParam);
        } else if (MXSession.isRoomAlias(firstParam) || MXSession.isRoomId(firstParam)) {
            map.put(ULINK_ROOM_ID_OR_ALIAS_KEY, firstParam);
        } else if (MXSession.isGroupId(firstParam)) {
            map.put(ULINK_GROUP_ID_KEY, firstParam);
        }

        // room id only ?
        if (temp.length > 2) {
            String eventId = temp[2];

            if (MXSession.isMessageId(eventId)) {
                map.put(ULINK_EVENT_ID_KEY, temp[2]);
            } else {
                uri = Uri.parse(uri.toString().replace("#/room/", "room/"));

                map.put(ULINK_ROOM_ID_OR_ALIAS_KEY, uri.getLastPathSegment());

                Set<String> names = uri.getQueryParameterNames();

                for (String name : names) {
                    String value = uri.getQueryParameter(name);

                    try {
                        value = URLDecoder.decode(value, "UTF-8");
                    } catch (Exception e) {
                        Log.e(LOG_TAG, "## parseUniversalLink : URLDecoder.decode " + e.getMessage());
                        return null;
                    }

                    map.put(name, value);
                }
            }
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "## parseUniversalLink : crashes " + e.getLocalizedMessage());
    }

    // check if the parsing succeeds
    if ((null != map) && (map.size() < 1)) {
        Log.e(LOG_TAG, "## parseUniversalLink : empty dictionary");
        return null;
    }

    return map;
}

From source file:com.songcode.materialnotes.ui.NoteEditActivity.java

private boolean isActionInsertOrEdit() {
    return TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, getIntent().getAction());
}

From source file:com.songcode.materialnotes.ui.NoteEditActivity.java

private boolean isActionActionView() {
    return TextUtils.equals(Intent.ACTION_VIEW, getIntent().getAction());
}

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

/** This would ideally be in ClassifyFragment.onResume() or similar,
 * but we need to do it here to avoid this exception sometimes:
 *   "java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState".
 * as suggested here:/* w w w . j av a 2  s. c  om*/
 * http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html
 */
@Override
protected void onResumeFragments() {
    super.onResumeFragments();

    mIsStateAlreadySaved = false;

    //Stop the NetworkChangeReceiver if it is active
    //We already try again to use the network after resume,
    //so we don't need to listen for a reconnection yet.
    stopListeningForNetworkReconnection();

    //See onClassificationFinished().
    if (mPendingClassificationFinished) {
        mPendingClassificationFinished = false;
        doClassificationFinished();
        return;
    }

    //See warnAboutNetworkProblemWithRetry().
    if (mPendingWarnAboutNetworkProblemWithRetry) {
        mPendingWarnAboutNetworkProblemWithRetry = false;
        doWarnAboutNetworkProblemWithRetry();
        return;
    }

    final ClassifyFragment fragmentClassify = getChildFragment();
    if (fragmentClassify != null) {

        if (TextUtils.equals(fragmentClassify.getItemId(), ItemsContentProvider.URI_PART_ITEM_ID_NEXT)) {
            //We are probably resuming again after a previous failure to get new items
            //from the network, so try again:
            fragmentClassify.update();
        }
    }
}

From source file:com.android.emailcommon.provider.HostAuth.java

@Override
public boolean equals(Object o) {
    if (!(o instanceof HostAuth)) {
        return false;
    }//from  ww w.j av  a2  s  . c o m
    HostAuth that = (HostAuth) o;
    return mPort == that.mPort && mId == that.mId && mFlags == that.mFlags
            && TextUtils.equals(mProtocol, that.mProtocol) && TextUtils.equals(mAddress, that.mAddress)
            && TextUtils.equals(mLogin, that.mLogin) && TextUtils.equals(mPassword, that.mPassword)
            && TextUtils.equals(mDomain, that.mDomain)
            && TextUtils.equals(mClientCertAlias, that.mClientCertAlias);
    // We don't care about the server certificate for equals
}

From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java

private void redrawSources() {
    if (mSourceContainerView == null || !isAdded()) {
        return;// w  w  w  .j  av a2s  .c  o m
    }

    mSourceContainerView.removeAllViews();
    for (final Source source : mSources) {
        source.rootView = LayoutInflater.from(getActivity()).inflate(R.layout.settings_choose_source_item,
                mSourceContainerView, false);

        source.selectSourceButton = source.rootView.findViewById(R.id.source_image);
        source.selectSourceButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (source.componentName.equals(mSelectedSource)) {
                    ((Callbacks) getActivity()).onRequestCloseActivity();
                } else if (source.setupActivity != null) {
                    mCurrentInitialSetupSource = source.componentName;
                    launchSourceSetup(source);
                } else {
                    mSourceManager.selectSource(source.componentName);
                }
            }
        });

        source.selectSourceButton.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
                final String pkg = source.componentName.getPackageName();
                if (TextUtils.equals(pkg, getActivity().getPackageName())) {
                    // Don't open Muzei's app info
                    return false;
                }
                // Otherwise open third party extensions
                try {
                    startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                            Uri.fromParts("package", pkg, null)));
                } catch (final ActivityNotFoundException e) {
                    return false;
                }
                return true;
            }
        });

        source.rootView.setAlpha(ALPHA_UNSELECTED);

        source.icon.setColorFilter(source.color, PorterDuff.Mode.SRC_ATOP);
        source.selectSourceButton.setBackground(source.icon);

        TextView titleView = (TextView) source.rootView.findViewById(R.id.source_title);
        titleView.setText(source.label);
        titleView.setTextColor(source.color);

        updateSourceStatusUi(source);

        source.settingsButton = source.rootView.findViewById(R.id.source_settings_button);
        CheatSheet.setup(source.settingsButton);
        source.settingsButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                launchSourceSettings(source);
            }
        });

        animateSettingsButton(source.settingsButton, false, false);

        mSourceContainerView.addView(source.rootView);
    }

    updateSelectedItem(false);
}