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.bayapps.android.robophish.ui.tv.TvVerticalGridFragment.java

protected void setMediaId(String mediaId) {
    LogHelper.d(TAG, "setMediaId: ", mediaId);
    if (TextUtils.equals(mMediaId, mediaId)) {
        return;//w w w . j a v a  2 s.  c  o m
    }
    MediaBrowserCompat mediaBrowser = mMediaFragmentListener.getMediaBrowser();

    // First, unsubscribe from old mediaId:
    if (mMediaId != null) {
        mediaBrowser.unsubscribe(mMediaId);
    }
    if (mediaId == null) {
        mediaId = mediaBrowser.getRoot();
    }
    mMediaId = mediaId;
    mediaBrowser.subscribe(mMediaId, mSubscriptionCallback);
}

From source file:com.orangesoft.jook.ui.tv.TvVerticalGridFragment.java

protected void setMediaId(String mediaId) {
    Log.d(TAG, "setMediaId: " + mediaId);
    if (TextUtils.equals(this.mediaId, mediaId))
        return;/*  ww  w. j  a v a2s .  c om*/
    MediaBrowser mediaBrowser = mediaFragmentListener.getMediaBrowser();

    if (this.mediaId != null)
        mediaBrowser.unsubscribe(mediaId);
    if (null == mediaId)
        mediaId = mediaBrowser.getRoot();
    this.mediaId = mediaId;
    mediaBrowser.subscribe(this.mediaId, subscriptionCallback);
}

From source file:com.android.switchaccess.SwitchAccessPreferenceActivity.java

/**
 * Check the global menu preference for auto-select
 *
 * @param context The current context/*from ww w. j a  v  a 2  s .  com*/
 * @return {@code true} auto-selecting is controlled from the auto-scan menu,
 * {@code false} otherwise
 */
public static boolean isGlobalMenuAutoselectOn(Context context) {
    SharedPreferences prefs = SharedPreferencesUtils.getSharedPreferences(context);
    String autoselectGlobalMenuPrefValue = prefs.getString(
            context.getString(R.string.switch_access_choose_action_global_menu_behavior_key),
            context.getString(R.string.switch_access_pref_choose_action_behavior_default));
    return TextUtils.equals(autoselectGlobalMenuPrefValue,
            context.getString(R.string.switch_access_choose_action_auto_select_key));
}

From source file:com.henry.ecdemo.ui.chatting.model.DescriptionTxRow.java

@Override
public void buildChattingData(Context context, BaseHolder baseHolder, ECMessage msg, int position) {
    DescriptionViewHolder holder = (DescriptionViewHolder) baseHolder;
    if (msg != null) {
        String msgType = "";
        JSONArray jsonArray = null;/*from www  . j  a  va 2  s  . c  o  m*/
        if (!TextUtils.isEmpty(msg.getUserData()))
            try {
                JSONObject jsonObject = new JSONObject(msg.getUserData());
                msgType = jsonObject.getString(CCPChattingFooter2.TXT_MSGTYPE);
                jsonArray = jsonObject.getJSONArray(CCPChattingFooter2.MSG_DATA);

            } catch (JSONException e) {
                e.printStackTrace();
            }
        if (TextUtils.equals(msgType, CCPChattingFooter2.FACETYPE)) {
            holder.getDescTextView().setBackgroundResource(0);
        } else {
            holder.getDescTextView().setBackgroundResource(R.drawable.chat_to_bg_normal);
        }
        ECTextMessageBody textBody = (ECTextMessageBody) msg.getBody();
        String msgTextString = textBody.getMessage();

        holder.getDescTextView().showMessage(msg.getId() + "", msgTextString, msgType, jsonArray);
        holder.getDescTextView().setMovementMethod(LinkMovementMethod.getInstance());
        View.OnClickListener onClickListener = ((ChattingActivity) context).mChattingFragment
                .getChattingAdapter().getOnClickListener();
        ViewHolderTag holderTag = ViewHolderTag.createTag(msg, ViewHolderTag.TagType.TAG_IM_TEXT, position);
        holder.getDescTextView().setTag(holderTag);
        holder.getDescTextView().setOnClickListener(onClickListener);
        setAutoLinkForTextView(holder.getDescTextView());
        getMsgStateResId(position, holder, msg, onClickListener);
    }
}

From source file:com.henry.ecdemo.ui.chatting.model.DescriptionRxRow.java

@Override
public void buildChattingData(final Context context, BaseHolder baseHolder, ECMessage detail, int position) {

    DescriptionViewHolder holder = (DescriptionViewHolder) baseHolder;
    ECMessage message = detail;//from w  w w.  j ava2  s.  c om
    if (message != null) {
        if (message.getType() == ECMessage.Type.TXT) {
            String msgType = "";
            JSONArray jsonArray = null;
            if (!TextUtils.isEmpty(message.getUserData()))
                try {
                    JSONObject jsonObject = new JSONObject(message.getUserData());
                    msgType = jsonObject.getString(CCPChattingFooter2.TXT_MSGTYPE);
                    jsonArray = jsonObject.getJSONArray(CCPChattingFooter2.MSG_DATA);

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            if (TextUtils.equals(msgType, CCPChattingFooter2.FACETYPE)) {
                holder.getDescTextView().setBackgroundResource(0);
            } else {
                holder.getDescTextView().setBackgroundResource(R.drawable.chat_from_bg_normal);
            }
            ECTextMessageBody textBody = (ECTextMessageBody) message.getBody();
            String msgTextString = textBody.getMessage();
            holder.getDescTextView().showMessage(message.getId() + "", msgTextString, msgType, jsonArray);
            holder.getDescTextView().setMovementMethod(LinkMovementMethod.getInstance());
            View.OnClickListener onClickListener = ((ChattingActivity) context).mChattingFragment
                    .getChattingAdapter().getOnClickListener();
            ViewHolderTag holderTag = ViewHolderTag.createTag(message, ViewHolderTag.TagType.TAG_IM_TEXT,
                    position);
            holder.getDescTextView().setTag(holderTag);
            holder.getDescTextView().setOnClickListener(onClickListener);
        } else if (message.getType() == ECMessage.Type.CALL) {
            ECCallMessageBody textBody = (ECCallMessageBody) message.getBody();
            holder.getDescTextView().setText(textBody.getCallText());
            holder.getDescTextView().setMovementMethod(LinkMovementMethod.getInstance());
        }
    }
}

From source file:com.citrus.sdk.webops.SavePayOption.java

@Override
protected void onPostExecute(Void aVoid) {
    super.onPostExecute(aVoid);
    if (TextUtils.equals(result, "success")) {
        Toast.makeText(activity.getApplicationContext(), "Payment Option Saved.", Toast.LENGTH_LONG).show();
    }//  w w w .  j a v  a2s. com
}

From source file:com.alibaba.weex.extend.module.WXEventModule.java

@JSMethod(uiThread = true)
public void openURL(String url) {
    if (TextUtils.isEmpty(url)) {
        return;/*from w  ww .ja va2s.  co  m*/
    }
    String scheme = Uri.parse(url).getScheme();
    StringBuilder builder = new StringBuilder();

    if ("weex://go/scan".equals(url)) {
        if (ContextCompat.checkSelfPermission(mWXSDKInstance.getContext(),
                Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) mWXSDKInstance.getContext(),
                    Manifest.permission.CAMERA)) {
                Toast.makeText(mWXSDKInstance.getContext(),
                        "Weex playground need the camera permission to scan QR code", Toast.LENGTH_SHORT)
                        .show();
            } else {
                ActivityCompat.requestPermissions((Activity) mWXSDKInstance.getContext(),
                        new String[] { Manifest.permission.CAMERA }, CAMERA_PERMISSION_REQUEST_CODE);
            }
        } else {
            mWXSDKInstance.getContext()
                    .startActivity(new Intent(mWXSDKInstance.getContext(), CaptureActivity.class));
        }
        return;
    }

    if (TextUtils.equals("http", scheme) || TextUtils.equals("https", scheme)
            || TextUtils.equals("file", scheme)) {
        builder.append(url);
    } else {
        builder.append("http:");
        builder.append(url);
    }

    Uri uri = Uri.parse(builder.toString());
    Intent intent = new Intent(mWXSDKInstance.getContext(), WXPageActivity.class);
    intent.setAction(WEEX_ACTION);
    intent.setData(uri);
    intent.addCategory(WEEX_CATEGORY);
    mWXSDKInstance.getContext().startActivity(intent);

    if (mWXSDKInstance.checkModuleEventRegistered("event", this)) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("param1", "param1");
        params.put("param2", "param2");
        params.put("param3", "param3");
        mWXSDKInstance.fireModuleEvent("event", this, params);
    }
}

From source file:com.macadamian.blinkup.BlinkUpCompleteActivity.java

private void getDeviceInfo(final String developerPlanId, int timeoutMs) {
    final TokenStatusCallback tokenStatusCallback = new TokenStatusCallback() {

        //---------------------------------
        // give connection info to Cordova
        //---------------------------------
        @Override/*from  w w w. j  a v  a  2s  . c  o  m*/
        public void onSuccess(JSONObject json) {
            BlinkUpPluginResult successResult = new BlinkUpPluginResult();
            successResult.setState(BlinkUpPluginResult.STATE_COMPLETED);
            successResult.setStatusCode(BlinkUpPlugin.STATUS_DEVICE_CONNECTED);
            successResult.setDeviceInfoFromJson(json);
            successResult.sendResultsToCallback();

            // cache planID if not development ID (see electricimp.com/docs/manufacturing/planids/)
            try {
                String planId = json.getString(BlinkUpPluginResult.SDK_PLAN_ID_KEY);
                if (!TextUtils.equals(planId, developerPlanId)) {
                    PreferencesHelper.setPlanId(BlinkUpCompleteActivity.this, planId);
                }
            } catch (JSONException e) {
                BlinkUpPluginResult.sendPluginErrorToCallback(BlinkUpPlugin.ERROR_JSON_ERROR);
            }
        }

        //---------------------------------
        // give error msg to Cordova
        //---------------------------------
        @Override
        public void onError(String errorMsg) {
            // can't use "sendPluginErrorToCallback" since this is an SDK error
            BlinkUpPluginResult errorResult = new BlinkUpPluginResult();
            errorResult.setState(BlinkUpPluginResult.STATE_ERROR);
            errorResult.setBlinkUpError(errorMsg);
            errorResult.sendResultsToCallback();
        }

        //---------------------------------
        // give timeout message to Cordova
        //---------------------------------
        @Override
        public void onTimeout() {
            BlinkUpPluginResult.sendPluginErrorToCallback(BlinkUpPlugin.ERROR_PROCESS_TIMED_OUT);
        }
    };

    // request the device info from the server
    BlinkupController.getInstance().getTokenStatus(tokenStatusCallback, timeoutMs);
}

From source file:com.macadamian.blinkup.BlinkUpPluginResult.java

/*************************************
 * Setters for our Results//from w  w w .ja v a2  s . c  o  m
 *************************************/
public void setState(String state) {
    DebugUtils.checkAssert(TextUtils.equals(state, STATE_COMPLETED) || TextUtils.equals(state, STATE_ERROR)
            || TextUtils.equals(state, STATE_STARTED));
    mState = state;
}

From source file:android.support.v17.leanback.widget.FullWidthDetailsOverviewSharedElementHelper.java

public void setSharedElementEnterTransition(Activity activity, String sharedElementName, long timeoutMs) {
    if (activity == null && !TextUtils.isEmpty(sharedElementName)
            || activity != null && TextUtils.isEmpty(sharedElementName)) {
        throw new IllegalArgumentException();
    }/*  w ww  .  j  a  v a 2s  . co  m*/
    if (activity == mActivityToRunTransition && TextUtils.equals(sharedElementName, mSharedElementName)) {
        return;
    }
    mActivityToRunTransition = activity;
    mSharedElementName = sharedElementName;
    if (DEBUG) {
        Log.d(TAG, "postponeEnterTransition " + mActivityToRunTransition);
    }
    Object transition = TransitionHelper.getSharedElementEnterTransition(activity.getWindow());
    setAutoStartSharedElementTransition(transition != null);
    ActivityCompat.postponeEnterTransition(mActivityToRunTransition);
    if (timeoutMs > 0) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (DEBUG) {
                    Log.d(TAG, "timeout " + mActivityToRunTransition);
                }
                startPostponedEnterTransitionInternal();
            }
        }, timeoutMs);
    }
}