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.chinaftw.music.CastPlayback.java

private void updateMetadata() {
    // Sync: We get the customData from the remote media information and update the local
    // metadata if it happens to be different from the one we are currently using.
    // This can happen when the app was either restarted/disconnected + connected, or if the
    // app joins an existing session while the Chromecast was playing a queue.
    try {/*w  w  w  . j ava  2s.co  m*/
        MediaInfo mediaInfo = mCastManager.getRemoteMediaInformation();
        if (mediaInfo == null) {
            return;
        }
        JSONObject customData = mediaInfo.getCustomData();

        if (customData != null && customData.has(ITEM_ID)) {
            String remoteMediaId = customData.getString(ITEM_ID);
            if (!TextUtils.equals(mCurrentMediaId, remoteMediaId)) {
                mCurrentMediaId = remoteMediaId;
                if (mCallback != null) {
                    mCallback.onMetadataChanged(remoteMediaId);
                }
                mCurrentPosition = getCurrentStreamPosition();
            }
        }
    } catch (TransientNetworkDisconnectionException | NoConnectionException | JSONException e) {
        LogHelper.e(TAG, e, "Exception processing update metadata");
    }

}

From source file:com.citrus.payment.PG.java

private void formjson() {
    JSONObject paymentToken = new JSONObject();
    boolean isTokenizedPayment = false;
    JSONObject paymentmode;// w w  w. j a v a  2 s .c om
    if (TextUtils.equals(paymenttype.toString(), "card")) {

        paymentmode = new JSONObject();
        try {
            if (card.getCardType() != null && "MTRO".equalsIgnoreCase(card.getCardType().toString())
                    && TextUtils.isEmpty(card.getCvvNumber())) {
                paymentmode.put("cvv", "123"); //dummy value
            } else {
                paymentmode.put("cvv", card.getCvvNumber());
            }

            paymentmode.put("holder", card.getCardHolderName());
            paymentmode.put("number", card.getCardNumber());
            paymentmode.put("scheme", card.getCardType());
            paymentmode.put("type", card.getCrdr());
            if (card.getCardType() != null && "MTRO".equalsIgnoreCase(card.getCardType().toString())
                    && TextUtils.isEmpty(card.getExpiryMonth()) && TextUtils.isEmpty(card.getExpiryYear())) {
                paymentmode.put("expiry", "11/2019"); // This is the dummy value
            } else {
                paymentmode.put("expiry", card.getExpiryMonth() + "/" + card.getExpiryYear());
            }

            paymentToken.put("type", "paymentOptionToken");
            paymentToken.put("paymentMode", paymentmode);
        } catch (JSONException e) {
            e.printStackTrace();
            callback.onTaskexecuted("", "Problem forming payment Json");
            return;
        }

    } else if (TextUtils.equals(paymenttype.toString(), "prepaid")) { //pay using citrus cash
        isTokenizedPayment = true;
        paymentmode = new JSONObject();
        try {
            paymentmode.put("cvv", "000");
            paymentmode.put("holder", prepaid.getUserEmail());
            paymentmode.put("number", "1234561234561234");
            paymentmode.put("scheme", "CPAY");
            paymentmode.put("type", "prepaid");
            paymentmode.put("expiry", "04/2030");

            paymentToken.put("type", "paymentOptionToken");
            paymentToken.put("paymentMode", paymentmode);
        } catch (JSONException e) {
            e.printStackTrace();
            callback.onTaskexecuted("", "Problem forming payment Json");
            return;
        }
    } else if (TextUtils.equals(paymenttype.toString(), "cardtoken")) { //tokenized card payment
        isTokenizedPayment = true;
        try {
            paymentToken.put("type", "paymentOptionIdToken");
            paymentToken.put("id", card.getcardToken());
            paymentToken.put("cvv", card.getCvvNumber());
            isTokenizedPayment = true;

        } catch (JSONException e) {
            e.printStackTrace();
        }

    } else {
        try {
            if (paymenttype != null && paymenttype.equalsIgnoreCase(BankPaymentType.TOKEN.toString())) { //tokenized bank payment
                isTokenizedPayment = true;
                paymentToken.put("id", bank.getBankToken());
                paymentToken.put("type", bank.getPaymentType().toString());
            } else { //bank payment with CID
                paymentmode = new JSONObject();
                paymentmode.put("type", "netbanking");
                paymentmode.put("code", bank.getCidnumber());
                paymentToken.put("type", "paymentOptionToken");
                paymentToken.put("paymentMode", paymentmode);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    JSONObject userdetails = new JSONObject();

    JSONObject address = new JSONObject();

    try {
        address.put("state", userDetails.getState());
        address.put("street1", userDetails.getStreet1());
        address.put("street2", userDetails.getStreet2());
        address.put("city", userDetails.getCity());
        address.put("country", userDetails.getCountry());
        address.put("zip", userDetails.getZip());
    } catch (JSONException e) {
        e.printStackTrace();
        callback.onTaskexecuted("", "Problem forming in address Json");
        return;
    }

    try {
        userdetails.put("email", userDetails.getEmail());
        userdetails.put("mobileNo", userDetails.getMobile());
        userdetails.put("firstName", userDetails.getFirstname());
        userdetails.put("lastName", userDetails.getLastname());
        userdetails.put("address", address);
    } catch (JSONException e) {
        e.printStackTrace();
        callback.onTaskexecuted("", "Problem forming in userdetails Json");
        return;
    }

    payment = new JSONObject();

    try {
        payment.put("returnUrl", bill.getReturnurl());

        if (bill.getNotifyurl() != null) {
            payment.put("notifyUrl", bill.getNotifyurl());
        }

        payment.put("amount", bill.getAmount());
        payment.put("merchantAccessKey", bill.getAccess_key());

        if (customParameters != null) {
            payment.put("customParameters", customParameters);
        }

        payment.put("paymentToken", paymentToken);
        payment.put("merchantTxnId", bill.getTxnId());
        payment.put("requestSignature", bill.getSignature());
        if (isTokenizedPayment) //Priyank Changes {
        {
            payment.put("requestOrigin", "MSDKW");
        } else {
            payment.put("requestOrigin", "MSDKG");
        }
        payment.put("userDetails", userdetails);
    } catch (JSONException e) {
        e.printStackTrace();
        callback.onTaskexecuted("", "Problem forming in userdetails Json");
        return;
    }

    JSONObject headers = new JSONObject();

    try {
        headers.put("Content-Type", "application/json");
    } catch (JSONException e) {
        e.printStackTrace();
    }

    //new MakePayment(payment, headers, callback).execute();
    retrofitCharge();

}

From source file:im.vector.fragments.AbsHomeFragment.java

/**
 * Apply the filter//from w w w  .j  av  a2s .co m
 *
 * @param pattern
 */
public void applyFilter(final String pattern) {
    if (TextUtils.isEmpty(pattern)) {
        if (mCurrentFilter != null) {
            onResetFilter();
            mCurrentFilter = null;
        }
    } else if (!TextUtils.equals(mCurrentFilter, pattern)) {
        onFilter(pattern, new OnFilterListener() {
            @Override
            public void onFilterDone(int nbItems) {
                mCurrentFilter = pattern;
            }
        });
    }
}

From source file:com.appsimobile.appsii.module.calls.CallLogLoader.java

private SimpleArrayMap<String, BaseContactInfo> loadContactsByNumber(Context context) {
    SimpleArrayMap<String, BaseContactInfo> result = new SimpleArrayMap<>();
    Cursor c = context.getContentResolver().query(CommonDataKinds.Phone.CONTENT_URI,
            ContactsByNumberQuery.PROJECTION, null, null, null);

    while (c.moveToNext()) {
        String normalizedNumber = c.getString(ContactsByNumberQuery.NORMALIZED_NUMBER);
        String plainNumber = c.getString(ContactsByNumberQuery.NUMBER);

        if (normalizedNumber == null && plainNumber == null)
            continue;
        if (normalizedNumber != null && result.containsKey(normalizedNumber))
            continue;
        if (plainNumber != null && result.containsKey(plainNumber))
            continue;

        BaseContactInfo info = new BaseContactInfo();
        info.mContactId = c.getLong(ContactsByNumberQuery.CONTACT_ID);
        info.mLookupKey = c.getString(ContactsByNumberQuery.LOOKUP_KEY);
        info.mContactLookupUri = ContactsContract.Contacts.getLookupUri(info.mContactId, info.mLookupKey);

        info.mDisplayName = c.getString(ContactsByNumberQuery.DISPLAY_NAME);
        info.mDisplayNameSource = c.getInt(ContactsByNumberQuery.DISPLAY_NAME_SOURCE);
        info.mPhotoUri = c.getString(ContactsByNumberQuery.PHOTO_URI);
        info.mStarred = c.getInt(ContactsByNumberQuery.STARRED) == 1;

        result.put(normalizedNumber, info);
        if (!TextUtils.equals(plainNumber, normalizedNumber)) {
            result.put(plainNumber, info);
        }/*from www.  j  a  va 2s  .  co  m*/

    }
    c.close();
    return result;
}

From source file:com.appdevper.mediaplayer.app.CastPlayback.java

private void updateMetadata() {

    try {//w w  w.j a va  2s .c om
        MediaInfo mediaInfo = mCastManager.getRemoteMediaInformation();
        if (mediaInfo == null) {
            return;
        }
        JSONObject customData = mediaInfo.getCustomData();

        if (customData != null && customData.has(ITEM_ID)) {
            String remoteMediaId = customData.getString(ITEM_ID);
            if (!TextUtils.equals(mCurrentMediaId, remoteMediaId)) {
                mCurrentMediaId = remoteMediaId;
                if (mCallback != null) {
                    mCallback.onMetadataChanged(remoteMediaId);
                }
                mCurrentPosition = getCurrentStreamPosition();
            }
        }
    } catch (TransientNetworkDisconnectionException | NoConnectionException | JSONException e) {
        LogHelper.e(TAG, e, "Exception processing update metadata");
    }

}

From source file:com.orangesoft.jook.CastPlayback.java

private void updateMetadata() {
    // Sync: We get the customData from the remote media information and update the local
    // metadata if it happens to be different from the one we are currently using.
    // This can happen when the app was either restarted/disconnected + connected, or if the
    // app joins an existing session while the Chromecast was playing a queue.
    try {//from   w  w  w . java  2s . c om
        MediaInfo mediaInfo = castManager.getRemoteMediaInformation();
        if (null == mediaInfo)
            return;

        JSONObject customData = mediaInfo.getCustomData();

        if (customData != null && customData.has(ITEM_ID)) {
            String remoteMediaId = customData.getString(ITEM_ID);
            if (!TextUtils.equals(currentMediaId, remoteMediaId)) {
                currentMediaId = remoteMediaId;
                if (callback != null)
                    callback.onMetadataChanged(remoteMediaId);
                updateLastKnownStreamPosition();
            }
        }
    } catch (TransientNetworkDisconnectionException | NoConnectionException | JSONException e) {
        Log.e(TAG, "Exception processing update metadata", e);
    }
}

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

private void updateRestaurantInfo() {
    if (HttpUtils.isNetworkConnected(getActivity())) {
        HttpUtils.get(Constant.RESTAURANT_LIST, new AsyncHttpResponseHandler() {
            @Override/*from   w  w w .  j  a  v  a  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<RestaurantInfo>>() {
                }.getType();
                JsonListResult<RestaurantInfo> jsonListResult = gson.fromJson(new String(responseBody), type);
                String status = jsonListResult.getStatus();
                restaurantList = jsonListResult.getData();
                //Log.v(TAG,data);
                if (TextUtils.equals(status, Result.SUCCESS) && restaurantList != null) {
                    //Toast.makeText(getActivity(),"?"+restaurantList.size(),Toast.LENGTH_LONG).show();
                    progressBar.setVisibility(View.GONE);
                    Log.i(TAG, new String(responseBody));
                    restaurantListAdapter = new RestaurantListAdapter(getActivity(), restaurantList, mLocation);
                    restaurantListAdapter
                            .setMyItemClickListener(new RestaurantListAdapter.MyItemClickListener() {
                                @Override
                                public void onItemClick(View view, int postion) {
                                    if (postion == 0) {
                                        Log.v(TAG, "");
                                        getActivity()
                                                .startActivity(new Intent(getActivity(), MapActivity.class));
                                        return;
                                    }
                                    Log.v(TAG, "?");
                                    Intent intent = new Intent(getActivity(), MapActivity.class);
                                    intent.putExtra("restaurantInfo",
                                            restaurantListAdapter.getRestaurantInfo(postion));
                                    getActivity().startActivity(intent);
                                }
                            });
                    restaurantListView.setAdapter(restaurantListAdapter);
                    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:com.summer.logger.LoggerPrinter.java

  private String formatTag(String tag) {
  if (!TextUtils.isEmpty(tag) && !TextUtils.equals(this.tag, tag)) {
    return this.tag + "-" + tag;
  }//w w w  .  j a  va 2 s.co  m
  return this.tag;
}

From source file:androidx.media.SessionToken2.java

private static String getSessionIdFromService(PackageManager manager, String serviceInterface,
        ComponentName serviceComponent) {
    Intent serviceIntent = new Intent(serviceInterface);
    // Use queryIntentServices to find services with MediaLibraryService2.SERVICE_INTERFACE.
    // We cannot use resolveService with intent specified class name, because resolveService
    // ignores actions if Intent.setClassName() is specified.
    serviceIntent.setPackage(serviceComponent.getPackageName());

    List<ResolveInfo> list = manager.queryIntentServices(serviceIntent, PackageManager.GET_META_DATA);
    if (list != null) {
        for (int i = 0; i < list.size(); i++) {
            ResolveInfo resolveInfo = list.get(i);
            if (resolveInfo == null || resolveInfo.serviceInfo == null) {
                continue;
            }//from  ww  w  .j  a  v a 2  s. c o  m
            if (TextUtils.equals(resolveInfo.serviceInfo.name, serviceComponent.getClassName())) {
                return getSessionId(resolveInfo);
            }
        }
    }
    return null;
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

private void searchFor(String query) {
    // ANALYTICS EVENT: Start a search on the Search activity
    // Contains: Nothing (Event params are constant:  Search query not included)
    AnalyticsHelper.sendEvent(SCREEN_LABEL, "Search", "");
    Bundle args = new Bundle(1);
    if (query == null) {
        query = "";
    }/*from  w  ww . j  a  v a2  s .c  o m*/
    args.putString(ARG_QUERY, query);
    if (TextUtils.equals(query, mQuery)) {
        getLoaderManager().initLoader(SearchTopicsSessionsQuery.TOKEN, args, this);
    } else {
        getLoaderManager().restartLoader(SearchTopicsSessionsQuery.TOKEN, args, this);
    }
    mQuery = query;
}