Java Code Examples for android.text.TextUtils#equals()

The following examples show how to use android.text.TextUtils#equals() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public String poiItemToString(PoiItem poiItem) {

        if ("regeo".equals(poiItem.getPoiId())) {
            return poiItem.getSnippet();
        }

        if (beginAddress != null) {
            return beginAddress + poiItem.getSnippet();
        }

        StringBuilder builder = new StringBuilder(poiItem.getProvinceName());

        if (!TextUtils.equals(poiItem.getProvinceName(), poiItem.getCityName())) {
            builder.append(poiItem.getCityName());
        }

        builder.append(poiItem.getAdName());

        if (!TextUtils.equals(poiItem.getAdName(), poiItem.getSnippet())) {
            builder.append(poiItem.getSnippet());
        }

        return builder.toString();
    }
 
Example 2
Source Project: HuaWeiVerifier   File: LoadedApkHuaWei.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    final String methodName = method.getName();
    if (TextUtils.equals(REGISTER_RECEIVER, methodName)) {
        if (mCurrentBroadcastCount >= MAX_BROADCAST_COUNT) {
            if (null != mCallback) {
                mCallback.tooManyBroadcast(mCurrentBroadcastCount, MAX_BROADCAST_COUNT);
            }
            return null;
        }
        mCurrentBroadcastCount++;
        if (null != mCallback) {
            mCallback.tooManyBroadcast(mCurrentBroadcastCount, MAX_BROADCAST_COUNT);
        }
    } else if (TextUtils.equals(UNREGISTER_RECEIVER, methodName)) {
        mCurrentBroadcastCount--;
        mCurrentBroadcastCount = mCurrentBroadcastCount < 0 ? 0 : mCurrentBroadcastCount;
        if (null != mCallback) {
            mCallback.tooManyBroadcast(mCurrentBroadcastCount, MAX_BROADCAST_COUNT);
        }
    }
    return method.invoke(mIActivityManagerObject, args);
}
 
Example 3
Source Project: simple-keyboard   File: KeyboardId.java    License: Apache License 2.0 6 votes vote down vote up
private boolean equals(final KeyboardId other) {
    if (other == this)
        return true;
    return other.mElementId == mElementId
            && other.mMode == mMode
            && other.mWidth == mWidth
            && other.mHeight == mHeight
            && other.passwordInput() == passwordInput()
            && other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
            && other.isMultiLine() == isMultiLine()
            && other.imeAction() == imeAction()
            && TextUtils.equals(other.mCustomActionLabel, mCustomActionLabel)
            && other.navigateNext() == navigateNext()
            && other.navigatePrevious() == navigatePrevious()
            && other.mSubtype.equals(mSubtype);
}
 
Example 4
/**
 * 检测是否拥有通知使用权
 * @return
 */
private boolean canAccessNotification() {

    if(Build.VERSION.SDK_INT < 19){

        return false;
    }

        String pkgName = mActivity.getPackageName();
    final String flat = Settings.Secure.getString(mContext.getContentResolver(),
            "enabled_notification_listeners");
    if (!TextUtils.isEmpty(flat)) {
        final String[] names = flat.split(":");
        for (int i = 0; i < names.length; i++) {
            final ComponentName cn = ComponentName.unflattenFromString(names[i]);
            if (cn != null) {
                if (TextUtils.equals(pkgName, cn.getPackageName())) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 5
@Override
public void onReceive(Context context, Intent intent) {
    if(TextUtils.equals(ACTION_FENCE, intent.getAction())) {
        FenceState fenceState = FenceState.extract(intent);

        if( TextUtils.equals(KEY_SITTING_AT_HOME, fenceState.getFenceKey() ) ) {
            if( fenceState.getCurrentState() == FenceState.TRUE ) {
                Log.e("Tuts+", "You've been sitting at home for too long");
            }
        }
    }
}
 
Example 6
Source Project: letv   File: LetvBaseParser.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isCreditTokenInvalid(JSONObject object) {
    JSONObject body = object.optJSONObject("body");
    if (isNull(body) || !TextUtils.equals(body.optString("code"), "201")) {
        return false;
    }
    return true;
}
 
Example 7
public void offer(String s) {
    if (TextUtils.isEmpty(s)) {
        return;
    }
    if (TextUtils.equals(s, mTopActivityName)) {
        return;
    }
    mTopActivityName = s;
    XLog.e(TAG, "add activity:" + s);
    if (mActivityStack.size() >= MAX_STACK_SIZE) {
        mActivityStack.poll();
    }
    mActivityStack.offer(s);
}
 
Example 8
@Subscribe public void onBufferChanged(final BufferChangedEvent event) {
    if (event.getConnection().getId() != mConnectionId) {
        return;
    }

    if (mConnectionState != TapchatService.STATE_LOADED) {
        return;
    }

    synchronized (mLock) {
        Buffer buffer = event.getBuffer();
        BufferInfo info = findBuffer(buffer.getId());
        if (info != null) {
            String newName = buffer.getDisplayName();
            int newWeight = buffer.getWeight();

            if (buffer.isArchived() && mDisplay == BuffersToDisplay.Normal) {
                mBuffers.remove(info);
                notifyDataSetChanged();
                return;
            }

            if ((!TextUtils.equals(info.mName, newName)) || info.mWeight != newWeight) {
                info.mName = newName;
                info.mWeight = newWeight;
                Collections.sort(mBuffers, BufferInfo.COMPARATOR);
                notifyDataSetChanged();
            }
        } else {
            if ((!buffer.isArchived()) || buffer.isArchived() && mDisplay == BuffersToDisplay.ShowArchived) {
                final ArrayList<BufferInfo> buffers = new ArrayList<>(mBuffers);
                buffers.add(BufferInfo.forBuffer(buffer));
                Collections.sort(buffers, BufferInfo.COMPARATOR);
                mBuffers = buffers;
                notifyDataSetChanged();
            }
        }
    }
}
 
Example 9
Source Project: android   File: MainActivity.java    License: MIT License 5 votes vote down vote up
public void updateIssue(Issue issue) {
    for (int i = 0; i < mIssues.size(); i++) {
        if (TextUtils.equals(issue.id, mIssues.get(i).id)) {
            mIssues.set(i, issue);
            notifyItemChanged(i);
            return;
        }
    }
}
 
Example 10
Source Project: SimpleProject   File: PayResultBean.java    License: MIT License 5 votes vote down vote up
public PayResultBean(Map<String, String> rawResult) {
	if (rawResult == null) {
		return;
	}

	for (String key : rawResult.keySet()) {
		if (TextUtils.equals(key, "resultStatus")) {
			resultStatus = rawResult.get(key);
		} else if (TextUtils.equals(key, "result")) {
			result = rawResult.get(key);
		} else if (TextUtils.equals(key, "memo")) {
			memo = rawResult.get(key);
		}
	}
}
 
Example 11
Source Project: NewXmPluginSDK   File: XmPluginHostApi.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * ApiLevel:68 设置定时场景
 *
 * @param model    设备model
 * @param did      设备 did
 * @param us_id    定时场景的唯一标识。创建时传"0"
 * @param name     定时器名称
 * @param setting  定时器具体内容
 * @param authed   可以为null
 * @param callback
 */
public void editTimerScene(String model, String did, String us_id, String name,
                           JSONObject setting,
                           JSONArray authed, final Callback<JSONObject> callback) {
    JSONObject dataObj = new JSONObject();
    try {
        if (!TextUtils.isEmpty(us_id) && !TextUtils.equals("0", us_id)) {
            dataObj.put("us_id", us_id);
        }
        dataObj.put("identify", did);
        dataObj.put("name", name);
        dataObj.put("st_id", 8);
        dataObj.put("setting", setting);
        dataObj.put("authed", authed);
    } catch (JSONException e) {
        if (callback != null)
            callback.onFailure(-1, e.toString());
        return;
    }

    callSmartHomeApi(model, "/scene/edit", dataObj, callback, new Parser<JSONObject>() {
        @Override
        public JSONObject parse(String result) throws JSONException {
            return new JSONObject(result);
        }
    });

}
 
Example 12
Source Project: MDPreference   File: ListPreference.java    License: Apache License 2.0 5 votes vote down vote up
public void setValue(String value) {
    final boolean changed = !TextUtils.equals(mValue, value);
    if (changed || !mValueSet) {
        mValue = value;
        mValueSet = true;
        persistString(value);
        if (changed) {
            notifyChanged();
        }
    }
}
 
Example 13
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
  if (type == WebSocket.PayloadType.TEXT) {
    String temp = payload.readUtf8();
    Log.e(TAG, "into--[onMessage] msg:" + temp);
    payload.close();

    if (TextUtils.equals("refresh", temp) && mHandler != null) {
      mHandler.obtainMessage(Constants.HOT_REFRESH_REFRESH, 0, 0, mUrl).sendToTarget();
    }
  }
}
 
Example 14
Source Project: BookReader   File: BookReviewAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
    return new BaseViewHolder<BookReviewList.ReviewsBean>(parent, R.layout.item_community_book_review_list) {
        @Override
        public void setData(BookReviewList.ReviewsBean item) {
            if (!SettingManager.getInstance().isNoneCover()) {
                holder.setRoundImageUrl(R.id.ivBookCover, Constant.IMG_BASE_URL + item.book.cover,
                        R.drawable.cover_default);
            } else {
                holder.setImageResource(R.id.ivBookCover, R.drawable.cover_default);
            }

            holder.setText(R.id.tvBookTitle, item.book.title)
                    .setText(R.id.tvBookType, String.format(mContext.getString(R.string.book_review_book_type), Constant.bookType.get(item.book.type)))
                    .setText(R.id.tvTitle, item.title)
                    .setText(R.id.tvHelpfulYes, String.format(mContext.getString(R.string.book_review_helpful_yes), item.helpful.yes));

            if (TextUtils.equals(item.state, "hot")) {
                holder.setVisible(R.id.tvHot, true);
                holder.setVisible(R.id.tvTime, false);
                holder.setVisible(R.id.tvDistillate, false);
            } else if (TextUtils.equals(item.state, "distillate")) {
                holder.setVisible(R.id.tvDistillate, true);
                holder.setVisible(R.id.tvHot, false);
                holder.setVisible(R.id.tvTime, false);
            } else {
                holder.setVisible(R.id.tvTime, true);
                holder.setVisible(R.id.tvHot, false);
                holder.setVisible(R.id.tvDistillate, false);
                holder.setText(R.id.tvTime, FormatUtils.getDescriptionTimeFromDateString(item.created));
            }
        }
    };
}
 
Example 15
Source Project: materialistic   File: SpinnerPreference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
    super.onSetInitialValue(restorePersistedValue, defaultValue);
    String value = restorePersistedValue ? getPersistedString(null) : (String) defaultValue;
    for (int i = 0; i < mEntryValues.length; i++) {
        if (TextUtils.equals(mEntryValues[i], value)) {
            mSelection = i;
            break;
        }
    }
}
 
Example 16
/**
 * If the given URL is a WebLite URL and should be overridden because the Data
 * Reduction Proxy is on, the user is in the Lo-Fi previews experiment, and the scheme of the
 * lite_url param is HTTP, returns the URL contained in the lite_url param. Otherwise returns
 * the given URL.
 *
 * @param url The URL to evaluate.
 * @return The URL to be used. Returns null if the URL param is null.
 */
public String maybeRewriteWebliteUrl(String url) {
    if (url == null || !URLUtil.isValidUrl(url) || !areLoFiPreviewsEnabled()
            || !isDataReductionProxyEnabled()) {
        return url;
    }
    String rewritten = extractUrlFromWebliteQueryParams(url);
    if (rewritten == null
            || !TextUtils.equals(Uri.parse(rewritten).getScheme(), "http")) {
        return url;
    }

    return rewritten;
}
 
Example 17
/**
 * Sets the text to be displayed.
 *
 * @param text text to be displayed
 * @see #setTextResource(int)
 * @attr ref com.google.android.material.R.styleable#Tooltip_android_text
 */
public void setText(@Nullable CharSequence text) {
  if (!TextUtils.equals(this.text, text)) {
    this.text = text;
    textDrawableHelper.setTextWidthDirty(true);
    invalidateSelf();
  }
}
 
Example 18
public boolean hasDict(final String dictType, @Nullable final String account) {
    if (Dictionary.TYPE_MAIN.equals(dictType)) {
        return mMainDict != null;
    }
    if (Dictionary.TYPE_USER_HISTORY.equals(dictType) &&
            !TextUtils.equals(account, mAccount)) {
        // If the dictionary type is user history, & if the account doesn't match,
        // return immediately. If the account matches, continue looking it up in the
        // sub dictionary map.
        return false;
    }
    return mSubDictMap.containsKey(dictType);
}
 
Example 19
private boolean isInvalidProvider(@NonNull String provider) {
    return TextUtils.equals(provider, EmailAuthProvider.PROVIDER_ID)
            || TextUtils.equals(provider, PhoneAuthProvider.PROVIDER_ID);
}
 
Example 20
Source Project: letv   File: AlbumVideoController.java    License: Apache License 2.0 4 votes vote down vote up
private void initStream() {
    if (this.mActivity.getFlow() != null) {
        AlbumPlayFlow flow = this.mActivity.getFlow();
        if (flow.isLebox()) {
            if (TextUtils.equals(flow.mBoxBean.stream, "21")) {
                this.mStreamSelectBox.setText(R.string.stream_smooth);
            } else if (TextUtils.equals(flow.mBoxBean.stream, "22")) {
                this.mStreamSelectBox.setText(R.string.stream_hd);
            } else {
                this.mStreamSelectBox.setText(R.string.stream_standard);
            }
            this.mStreamSelectBox.setEnabled(false);
            this.mMoreView.setButtonEnable(this.mStreamSelectBox, false);
            return;
        }
        this.vidForVideoShotNew = flow.mVid;
        if (this.vidForVideoShotOld == -1) {
            this.vidForVideoShotOld = this.vidForVideoShotNew;
        } else if (!(this.vidForVideoShotOld == -1 || this.vidForVideoShotOld == this.vidForVideoShotNew)) {
            FileUtils.clearPicsAfterChangeVideo(this.mActivity);
        }
        setVisibilityForVideoShot();
        flow.setCurrenStreamFromFullController();
        int playLevel = flow.mPlayLevel;
        boolean isLocalFile = flow.mIsDownloadFile;
        int downloadStreamLevel = flow.getDownloadStreamLevel();
        String[] streamLevels = PlayUtils.getStreamLevelName();
        String superHdName = streamLevels[3];
        String hdName = streamLevels[2];
        String standardName = streamLevels[1];
        String lowName = streamLevels[0];
        if (isLocalFile) {
            String downloadStreamName = hdName;
            if (downloadStreamLevel == 1) {
                downloadStreamName = superHdName;
            } else if (downloadStreamLevel == 0) {
                downloadStreamName = standardName;
            }
            this.mStreamSelectBox.setText(downloadStreamName);
        } else {
            this.mStreamSelectBox.setText(PlayUtils.getPlayLevelZh(superHdName, hdName, standardName, lowName, playLevel));
        }
        if (flow.mStreamSupporter.getStreamCount(flow.mLevelList) >= 1) {
            this.mStreamSelectBox.setEnabled(true);
            recoverFullPlayControllerHd();
            if (flow.mIsDownloadFile) {
                initStreamWhenIsLocal();
            } else {
                initStreamWhenOnline();
            }
        }
        if (flow.mLaunchMode == 0) {
            this.mStreamSelectBox.setVisibility(8);
        }
        if (mIsFirstInitLayout) {
            mIsFirstInitLayout = false;
        }
        setStreamButtonEnableByLevel(playLevel);
        if (!flow.mIsDownloadFile) {
            setStreamButtonSelectColor(playLevel);
        }
        if (playLevel == 5) {
            checkIfCanPlay1080p(false);
        }
    }
}